aboutsummaryrefslogtreecommitdiff
path: root/audio/clockchimes/doinst.sh
blob: 58ef63dfcefe6ea293cb150533796101ecf789c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# doinst.sh for clockchimes

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
config etc/cron.d/clockchimes.new

# clean root crontab from versions before v0.3
grep 'clockchimes' /var/spool/cron/crontabs/root 1>/dev/null
if [ $? -eq 0 ]; then
  grep -v 'clockchimes' > /var/spool/cron/crontabs/root
fi # END clean root crontab

# kill crond if running
ps -C crond 1>/dev/null
if [ $? -eq 0 ]; then
  # true: kill crond
  killall crond 1>/dev/null
fi # END crond running

# start crond if not running
ps -C crond 1>/dev/null
if [ $? -ne 0 ]; then
  # true: start crond
  /usr/sbin/crond -l notice
fi # END crond running