diff options
author | Stu Miller <slackbuilds@go4it2day.com> | 2018-05-13 09:05:20 +0700 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2018-05-17 07:09:19 +0700 |
commit | 06c80b46e8de66ec4b3fd8bd600a9664990e6289 (patch) | |
tree | 92544abf18347152fb702575e2d441d79ff3962b /audio/clockchimes/doinst.sh | |
parent | e2fc5acba828aea7c48abc0d844287e9fea9c462 (diff) |
audio/clockchimes: Updated for version 0.2.
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'audio/clockchimes/doinst.sh')
-rw-r--r-- | audio/clockchimes/doinst.sh | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/audio/clockchimes/doinst.sh b/audio/clockchimes/doinst.sh index 30a7850b470b..8aa71f082f8e 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 |