(no commit message)
[vsys.git] / vsys-initscript
1 #!/bin/bash
2 #
3 # chkconfig: 345 84 02
4 # description: Vsys file descriptor abritrator startup.
5 #
6 # Sapan Bhatia <sapanb@cs.princeton.edu>
7 #
8 # $Id$
9 # $HeadURL$
10 #
11 name="vsys"
12
13 # Source function library.
14 . /etc/rc.d/init.d/functions
15
16 if [ -f /etc/sysconfig/$name ]; then
17     . /etc/sysconfig/$name
18 fi
19
20 backend=${BACKEND-/vsys}
21
22 conf=${CONF-/etc/$name.conf}
23 pidfile=${PIDFILE-/var/run/$name.pid}
24 lockfile=${LOCKFILE-/var/lock/subsys/$name}
25 RETVAL=0
26
27 vsys=${VSYS- "/usr/bin/vsys -failsafe -backend $backend -conffile $conf -daemon"}
28
29 case "$1" in
30     start)
31         echo -n "Starting $name:"
32         if [ ! -d $backend ]; then mkdir $backend; fi
33         daemon --check=vsys $vsys 
34         RETVAL=$?
35         echo
36         [ $RETVAL -eq 0 ] && touch ${lockfile}
37         ;;
38     stop)
39         echo -n "Stopping $name:"
40         killproc $name
41         #killproc $name - Why were there 2 instances of this? :-|
42         RETVAL=$?
43         echo
44         [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile}
45         ;;
46     restart)
47         $0 stop
48         $0 start
49         RETVAL=$?
50         ;;
51     *)
52         echo $"Usage: $0 {start|stop|restart}"
53         exit 1
54         ;;
55 esac
56