]> git.pld-linux.org Git - packages/eventum.git/blob - eventum-irc.init
- config and initscript for eventum irc bot
[packages/eventum.git] / eventum-irc.init
1 #!/bin/sh
2 #
3 # chkconfig:    345 29 69
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 PHP=/usr/bin/php4
13 PIDFILE=/usr/share/eventum/locks/irc_bot.pid
14
15 # Get service config
16 [ -f /etc/sysconfig/eventum-irc ] && . /etc/sysconfig/eventum-irc
17
18 # Check that networking is up.
19 if is_yes "${NETWORKING}"; then
20         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
21                 msg_network_down eventum-irc
22                 exit 1
23         fi
24 else
25         exit 0
26 fi
27
28 RETVAL=0
29 # See how we were called.
30 case "$1" in
31 start)
32         if [ ! -f /var/lock/subsys/eventum-irc ]; then
33                 msg_starting eventum-irc
34                 start-stop-daemon --start \
35                          --exec $PHP \
36                          --pidfile $PIDFILE \
37                          --chuid http \
38                          --chdir /usr/share/eventum/misc/irc \
39                          --background -- -q bot.php
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         else
49                 msg_already_running eventum-irc
50         fi
51 ;;
52 stop)
53         if [ -f /var/lock/subsys/eventum-irc ]; then
54                 msg_stopping eventum-irc
55                 if start-stop-daemon --stop --pidfile $PIDFILE; then
56                         rm -f $PIDFILE /var/lock/subsys/eventum-irc >/dev/null 2>&1
57                         ok
58                 else
59                         fail
60                 fi
61         else
62                 msg_not_running eventum-irc
63         fi
64 ;;
65 restart)
66         $0 stop
67         $0 start
68         exit $?
69 ;;
70 status)
71         status eventum-irc
72         exit $?
73 ;;
74 *)
75         msg_usage "$0 {start|stop|restart|status}"
76         exit 3
77 esac
78
79 exit $RETVAL
This page took 0.101778 seconds and 4 git commands to generate.