Merge branch 'master' of mathias-kettner.de:omd
[omd.git] / packages / maintenance / skel / etc / init.d / crontab
blob517e816b21feb7d96476018d732d596defb13177
1 #!/bin/bash
2 #
3 # Start only if Crontab is enabled
4 . ###ROOT###/etc/omd/site.conf
5 if [ "$CONFIG_CRONTAB" != on ] ; then
6 exit 5
7 fi
9 NAME="crontab"
10 MERGECRONTABS="###ROOT###/bin/merge-crontabs"
11 CROND="###ROOT###/etc/cron.d/*"
12 CRONTAB=`which crontab`
13 CRONTAB_OPTS=""
14 USER="###SITE###"
16 # check for root
17 # Workaround for http://omdistro.org/issues/157
18 if [ `id -u` -eq "0" ]; then
19 CRONTAB_OPTS="-u ###SITE###"
22 # See how we were called.
23 case "$1" in
25 start)
26 echo -en "Initializing Crontab..."
27 ${MERGECRONTABS} ${CROND} | $CRONTAB $CRONTAB_OPTS - > /dev/null
28 if [ $? -eq 0 ]; then
29 echo "OK"
30 exit 0
31 else
32 echo "ERROR"
33 exit 1
37 stop)
38 echo -n "Removing Crontab..."
39 $CRONTAB $CRONTAB_OPTS -r || exit 0
40 echo OK
41 exit 0
44 restart|reload)
45 $0 stop
46 $0 start
48 status)
49 $CRONTAB $CRONTAB_OPTS -l >/dev/null 2>&1
50 if [ $? -eq 0 ]; then
51 echo "crontab initialized"
52 exit 0
53 else
54 echo "crontab is empty"
55 exit 1
59 echo "Usage: crontab {start|stop|restart|reload|status}"
60 exit 1
63 esac
65 # End of this script