Merge branch 'dev-3.5.4'
[packages/eventum.git] / eventum-irc.init
1 #!/bin/sh
2 #
3 # chkconfig:    345 29 71
4 # description:  Eventum IRC Notification Bot
5
6 # Source function library
7 . /etc/rc.d/init.d/functions
8
9 # Get network config
10 . /etc/sysconfig/network
11
12 PIDFILE=/var/run/eventum/irc_bot.pid
13
14 # Get service config
15 [ -f /etc/sysconfig/eventum-irc ] && . /etc/sysconfig/eventum-irc
16
17 # Check that networking is up.
18 if is_yes "${NETWORKING}"; then
19         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
20                 msg_network_down "Eventum IRC Bot"
21                 exit 1
22         fi
23 else
24         exit 0
25 fi
26
27 start() {
28         if [ -f /var/lock/subsys/eventum-irc ]; then
29                 msg_already_running "Eventum IRC Bot"
30                 return
31         fi
32
33         msg_starting "Eventum IRC Bot"
34         start-stop-daemon --start \
35                 --exec /usr/share/eventum/bin/irc-bot.php \
36                 -m \
37                 --pidfile $PIDFILE \
38                 --chuid http \
39                 --background
40
41         RETVAL=$?
42         if [ $RETVAL -eq 0 ]; then
43                 touch /var/lock/subsys/eventum-irc
44                 ok
45         else
46                 fail
47         fi
48 }
49
50 stop() {
51         if [ ! -f /var/lock/subsys/eventum-irc ]; then
52                 msg_not_running "Eventum IRC Bot"
53                 return
54         fi
55
56         msg_stopping "Eventum IRC Bot"
57         if start-stop-daemon --stop --oknodo --pidfile $PIDFILE; then
58                 rm -f $PIDFILE /var/lock/subsys/eventum-irc >/dev/null 2>&1
59                 ok
60         else
61                 fail
62         fi
63 }
64
65 condrestart() {
66         if [ ! -f /var/lock/subsys/eventum-irc ]; then
67                 msg_not_running "Eventum IRC Bot"
68                 RETVAL=$1
69                 return
70         fi
71
72         stop
73         start
74 }
75
76 RETVAL=0
77 # See how we were called.
78 case "$1" in
79   start)
80         start
81         ;;
82   stop)
83         stop
84         ;;
85   restart)
86         stop
87         start
88         ;;
89   force-reload)
90         condrestart 7
91         ;;
92   status)
93         status --pidfile $PIDFILE eventum-irc
94         exit $?
95         ;;
96   *)
97         msg_usage "$0 {start|stop|restart|force-reload|status}"
98         exit 3
99 esac
100
101 exit $RETVAL
This page took 0.046194 seconds and 3 git commands to generate.