aboutsummaryrefslogtreecommitdiff
path: root/audio/clockchimes/doinst.sh
blob: 30a7850b470b402ccefb392665dfa68c2b5d9a24 (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
# doinst.sh for clockchimes
# focus is on making sure cron is managing clockchime script

# negative test: check if root crontab exists
if [ ! -e /var/spool/cron/crontabs/root ]; then
  # true: does not exist, create root crontab and set permissions
  touch /var/spool/cron/crontabs/root
  chmod 0600 /var/spool/cron/crontabs/root
fi

# negative test: check if root crontab previously modified
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
# clockchimes
0,15,30,45 * * * * /usr/bin/clockchimes.sh 1> /dev/null
EOF

  # positive test: check if crond is running
  ps -C crond 1>/dev/null
  if [ $? -eq 0 ]; then
    # true: reload crond
    crontab /var/spool/cron/crontabs/root 1> /dev/null
  fi
fi