diff --git a/README.md b/README.md index 819a55e..83f211f 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,6 @@ git clone https://git.stack-source.com/msb/vmail-stack.git cd vmail-stack bash install.sh ``` + + + diff --git a/install.sh b/install.sh index 42254f4..6d00cbe 100755 --- a/install.sh +++ b/install.sh @@ -15,7 +15,7 @@ if ! grep -q "Ubuntu 20.04" /etc/issue; then fi # check if install is already in place -if [ -f "/etc/vmail.conf" ] || [ -d "/var/vmail/" ]; then +if [ -d "/var/vmail/" ]; then echo "vmail-stack is already installed, bailing out." exit fi @@ -127,6 +127,17 @@ systemctl restart dovecot chmod 755 bin/* cp bin/* /usr/local/bin/ +# install & enable vmail systemd cron +cp sbin/vmail-cron.sh /usr/local/sbin/ +chmod 755 /usr/local/sbin/vmail-cron.sh +cp systemd/vmail-cron.* /usr/lib/systemd/system/ +chmod 644 /usr/lib/systemd/system/vmail-cron.* +systemctl daemon-reload +systemctl start vmail-cron.timer + +chmod 755 sbin/* +cp sbin/* /usr/local/sbin/ + # download and install roundcubemail # cd /usr/local/src/ # wget --continue --quiet https://github.com/roundcube/roundcubemail/releases/download/1.4.11/roundcubemail-1.4.11-complete.tar.gz diff --git a/sbin/vmail-cron.sh b/sbin/vmail-cron.sh new file mode 100755 index 0000000..cda7f81 --- /dev/null +++ b/sbin/vmail-cron.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# purge Junk & Trash of messages older than 30 days for all mailboxes +/usr/local/bin/vmail-purge-dirs.sh diff --git a/systemd/vmail-cron.service b/systemd/vmail-cron.service new file mode 100644 index 0000000..19a8d03 --- /dev/null +++ b/systemd/vmail-cron.service @@ -0,0 +1,13 @@ +# vmail-stack +# https://git.stack-source.com/msb/vmail-stack +# MIT License Copyright (c) 2021 Matthew Saunders Brown +# +[Unit] +Description=vmail-stack cron + +[Service] +Type=simple +ExecStart=/usr/local/sbin/vmail-cron.sh + +[Install] +WantedBy=multi-user.target diff --git a/systemd/vmail-cron.timer b/systemd/vmail-cron.timer new file mode 100644 index 0000000..91414fe --- /dev/null +++ b/systemd/vmail-cron.timer @@ -0,0 +1,14 @@ +# vmail-stack +# https://git.stack-source.com/msb/vmail-stack +# MIT License Copyright (c) 2021 Matthew Saunders Brown +# +[Unit] +Description=vmail-stack cron once per day + +[Timer] +OnCalendar=daily +Unit=vmail-cron.service +AccuracySec=6h + +[Install] +WantedBy=multi-user.target diff --git a/update.sh b/update.sh index 9cd989a..f56f055 100755 --- a/update.sh +++ b/update.sh @@ -25,6 +25,23 @@ for bin_script in "${bin_script_array[@]}"; do fi done +# update scripts in sbin +chmod 755 sbin/* +readarray -t s_script_array < <(ls -1 sbin/) +for sbin_script in "${sbin_script_array[@]}"; do + if [ -f /usr/local/sbin/$sbin_script ]; then + if ! diff -q sbin/$sbin_script /usr/local/sbin/$sbin_script ; then + echo "Updating /usr/local/sbin/$sbin_script" + cp sbin/$sbin_script /usr/local/sbin/$sbin_script + echo + fi + else + echo "Adding new script /usr/local/sbin/$sbin_script" + cp sbin/$sbin_script /usr/local/sbin/$sbin_script + echo + fi +done + # check etc configs for diffs readarray -t etc_configs_array < <(find etc/ -type f) for etc_config in "${etc_configs_array[@]}"; do