Fixed a comment in redhat script, added Debian script.
[shibboleth/sp.git] / configs / shibd-redhat.in
1 #!/bin/bash
2 #
3 # Startup script for the Shibboleth Service Provider Daemon
4 #
5 # chkconfig: - 98 02
6 # description: Shibboleth 2 Service Provider Daemon
7 # processname: shibd
8 # pidfile: @-VARRUNDIR-@/shibd.pid
9 # config: @-PKGSYSCONFDIR-@/shibboleth2.xml
10
11 # Source function library.
12 . /etc/rc.d/init.d/functions
13 shibd="@-PREFIX-@/sbin/shibd"
14 SHIBD_USER=root
15 pidfile=@-VARRUNDIR-@/shibd.pid
16 prog=shibd
17 RETVAL=0
18
19 start() {
20         echo -n $"Starting $prog: "
21         if [ -f /var/lock/subsys/shibd ] ; then
22                 if [ -f $pidfile ]; then
23                         read kpid < $pidfile
24                         if checkpid $kpid 2>&1; then
25                                 echo "process already running"
26                                         return -1
27                         else
28                                         echo "lock file found but no process running for pid $kpid, continuing"
29                         fi
30                 fi
31         fi
32  
33         export SHIBD_PID=$pidfile
34         touch $pidfile
35         chown $SHIBD_USER:$SHIBD_USER $pidfile
36         # daemon function just hangs, so I'm using su directly
37         su - $SHIBD_USER -c "$shibd -p $pidfile -f &"
38
39         RETVAL=$?
40         echo
41                 [ $RETVAL = 0 ] && touch /var/lock/subsys/shibd
42         return $RETVAL
43 }
44
45 stop() {
46         echo -n $"Stopping $prog: "
47         if [ -f $pidfile ]; then
48                 read kpid < $pidfile
49                 kill $kpid
50         else
51             killproc shibd
52         fi
53
54         RETVAL=$?
55         echo
56         [ $RETVAL = 0 ] && rm -f /var/lock/subsys/shibd $pidfile
57 }
58
59 # See how we were called.
60 case "$1" in
61   start)
62         start
63         ;;
64   stop)
65         stop
66         ;;
67   status)
68         status $shibd
69         RETVAL=$?
70         ;;
71   restart)
72         stop
73         sleep 5
74         start
75         ;;
76   *)
77         echo $"Usage: $prog {start|stop|restart}"
78         exit 1
79 esac
80
81 exit $RETVAL