summaryrefslogtreecommitdiffstats
path: root/audio/clockchimes/doinst.sh
diff options
context:
space:
mode:
Diffstat (limited to 'audio/clockchimes/doinst.sh')
-rw-r--r--audio/clockchimes/doinst.sh42
1 files changed, 29 insertions, 13 deletions
diff --git a/audio/clockchimes/doinst.sh b/audio/clockchimes/doinst.sh
index 30a7850b47..8aa71f082f 100644
--- a/audio/clockchimes/doinst.sh
+++ b/audio/clockchimes/doinst.sh
@@ -1,27 +1,43 @@
# doinst.sh for clockchimes
-# focus is on making sure cron is managing clockchime script
-# negative test: check if root crontab exists
+config() {
+ NEW="$1"
+ OLD="$(dirname $NEW)/$(basename $NEW .new)"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
+ # toss the redundant copy
+ rm $NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+
+config etc/clockchimes.conf.new
+
+# root crontab missing?
if [ ! -e /var/spool/cron/crontabs/root ]; then
- # true: does not exist, create root crontab and set permissions
+ # true: crontab missing, create crontab and set permissions
touch /var/spool/cron/crontabs/root
chmod 0600 /var/spool/cron/crontabs/root
-fi
+fi # END crontab missing
-# negative test: check if root crontab previously modified
+# root crontab not updated?
grep "# clockchimes" /var/spool/cron/crontabs/root 1> /dev/null
if [ $? -ne 0 ]; then
-
-# true: not previously modified
-cat << EOF >> /var/spool/cron/crontabs/root
+ # true: crontab not updated, update with clockchimes
+ cat << EOF >> /var/spool/cron/crontabs/root
# clockchimes
-0,15,30,45 * * * * /usr/bin/clockchimes.sh 1> /dev/null
+0,15,30,45 * * * * /usr/bin/clockchimes 1> /dev/null
EOF
- # positive test: check if crond is running
+ # crond running?
ps -C crond 1>/dev/null
if [ $? -eq 0 ]; then
- # true: reload crond
+ # true: crond running, reload crond
crontab /var/spool/cron/crontabs/root 1> /dev/null
- fi
-fi
+ else
+ # false: crond not running, start crond
+ /usr/sbin/crond -l notice
+ fi # END crond running
+fi # END crontab not updated