Setting tag codemux-0.1-15
[codemux.git] / codemux.initscript
1 #!/bin/sh
2 #
3 # chkconfig: 345 85 02
4 # description: codemux startup script
5 #
6
7 PROC=codemux
8
9 . /etc/rc.d/init.d/functions
10
11 RETVAL=0
12
13 pidfile=/var/run/$PROC.pid
14
15 [ -r /etc/sysconfig/codemux ] && . /etc/sysconfig/codemux
16
17 check_status() {
18     pid=`cat $pidfile 2>/dev/null`
19     #
20     # this eliminates a race condition between checking existence of pidfile
21     # and reading its value
22     #
23     [ -n "$pid" -a -d /proc/$pid ]
24 }
25
26 case "$1" in
27     start)
28         echo -n "starting $PROC:"
29         pid=`cat $pidfile 2>/dev/null`
30         if [ -n "$pid" ]; then
31             # check whether process really exists
32             # yes - don't try to start
33             [ -d /proc/$pid ] && action "already running" /bin/true && exit 1
34
35             # no - PID file is stale
36             rm -f $pidfile
37         fi
38
39         #initlog -c /usr/sbin/codemux # Depricated
40                 /usr/sbin/codemux $CODEMUX_OPTS
41
42         cmd=success
43         check_status && touch /var/lock/subsys/$PROC || cmd=failure
44         $cmd "$PROC startup"
45         echo
46         ;;
47
48     stop)
49         echo -n "shutting down $PROC: "
50         killproc $PROC
51         killproc $PROC
52         RETVAL=$?
53         echo
54         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROC
55         ;;
56
57     restart|reload)
58         $0 stop
59         $0 start
60         RETVAL=$?
61         ;;
62
63     status)
64         check_status && echo 'running' && exit 0 || \
65             echo 'not running' && exit 1
66         ;;
67
68     condrestart)
69         if test -f /var/lock/subsys/$PROC; then
70             $0 stop
71             $0 start
72             RETVAL=$?
73         fi
74         ;;
75
76     *)
77         echo "Usage: $0 {start|stop|restart|status|condrestart}"
78         RETVAL=1
79 esac
80
81 exit $RETVAL