add systemd timer

This commit is contained in:
Matthew Saunders Brown 2021-04-20 14:46:05 -07:00
parent 93239f93d5
commit b0afa59758
6 changed files with 63 additions and 1 deletions

View File

@ -7,3 +7,6 @@ git clone https://git.stack-source.com/msb/vmail-stack.git
cd vmail-stack cd vmail-stack
bash install.sh bash install.sh
``` ```

View File

@ -15,7 +15,7 @@ if ! grep -q "Ubuntu 20.04" /etc/issue; then
fi fi
# check if install is already in place # 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." echo "vmail-stack is already installed, bailing out."
exit exit
fi fi
@ -127,6 +127,17 @@ systemctl restart dovecot
chmod 755 bin/* chmod 755 bin/*
cp bin/* /usr/local/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 # download and install roundcubemail
# cd /usr/local/src/ # cd /usr/local/src/
# wget --continue --quiet https://github.com/roundcube/roundcubemail/releases/download/1.4.11/roundcubemail-1.4.11-complete.tar.gz # wget --continue --quiet https://github.com/roundcube/roundcubemail/releases/download/1.4.11/roundcubemail-1.4.11-complete.tar.gz

4
sbin/vmail-cron.sh Executable file
View File

@ -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

View File

@ -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

14
systemd/vmail-cron.timer Normal file
View File

@ -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

View File

@ -25,6 +25,23 @@ for bin_script in "${bin_script_array[@]}"; do
fi fi
done 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 # check etc configs for diffs
readarray -t etc_configs_array < <(find etc/ -type f) readarray -t etc_configs_array < <(find etc/ -type f)
for etc_config in "${etc_configs_array[@]}"; do for etc_config in "${etc_configs_array[@]}"; do