reformat
[svn42.git] / tuer_status.initscript
1 #!/bin/sh
2 # Start/stop the tuer status updater.
3 #
4 ### BEGIN INIT INFO
5 # Provides:          tuer_status
6 # Required-Start:    $remote_fs $syslog $time tuer_core tuer_presence
7 # Required-Stop:     $remote_fs $syslog $time tuer_core tuer_presence
8 # Default-Start:     2 3 4 5
9 # Default-Stop:      0 1 6
10 ### END INIT INFO
11
12 EXE_UWEB=/flash/tuer/r3-netstatus
13 STATE_DIR=/flash/var/lib/r3netstatus/
14 CFG_UWEB="-syslog"
15
16 . /etc/default/tuer
17
18 [ -n "$XMPPJID" ] && CFG_UWEB="$CFG_UWEB --xjid $XMPPJID"
19 [ -n "$XMPPPASS" ] && CFG_UWEB="$CFG_UWEB --xpass $XMPPPASS"
20 [ -n "$XMPPBOTAUTH" ] && CFG_UWEB="$CFG_UWEB --xbotauth $XMPPBOTAUTH"
21
22
23 PIDFILE_UWEB=${DIR_RUN}/r3-netstatus.pid
24
25 test -f $EXE_UWEB  || exit 1
26 if [ ! -d $DIR_RUN ]; then
27         mkdir -p $DIR_RUN || exit 2
28         chown -R $DOOR_USR:$DOOR_GRP $DIR_RUN
29 fi
30
31 if [ ! -d $STATE_DIR ]; then
32         mkdir -p $STATE_DIR || exit 2
33         chown -R $DOOR_USR:$DOOR_GRP $STATE_DIR
34 fi
35
36 . /lib/lsb/init-functions
37
38 # Read the system's locale and set cron's locale. This locale
39 # will be inherited by cron (used to set charset of emails)
40 # and tasks running under it.
41
42 case "$1" in
43 start)
44   log_daemon_msg "Starting xmpp and web status daemon" r3-netstatus
45   start-stop-daemon --start --quiet --pidfile $PIDFILE_UWEB -b -m -c $DOOR_USR --startas $EXE_UWEB  -- $CFG_UWEB
46   log_end_msg $?
47         ;;
48 stop)
49   log_daemon_msg "Stopping xmpp and web status daemon" r3-netstatus
50   start-stop-daemon --stop --quiet --pidfile $PIDFILE_UWEB -m --retry TERM/1/TERM/1/KILL
51   log_end_msg $?
52         ;;
53 restart)
54         $0 stop
55         $0 start
56         ;;
57 *)      log_action_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
58         exit 2
59         ;;
60 esac
61 exit 0