Imported Upstream version 2.2.1+dfsg
[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: @-PKGRUNDIR-@/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=@-PKGRUNDIR-@/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         if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
37                 /sbin/restorecon $pidfile
38         fi
39         daemon --user $SHIBD_USER --pidfile $pidfile $shibd -p $pidfile -f -w 3
40
41         RETVAL=$?
42         echo
43                 [ $RETVAL = 0 ] && touch /var/lock/subsys/shibd
44         return $RETVAL
45 }
46
47 stop() {
48         echo -n $"Stopping $prog: "
49         if [ -f $pidfile ]; then
50                 killproc -p $pidfile shibd
51         else
52         killproc shibd
53         fi
54
55         RETVAL=$?
56         echo
57         [ $RETVAL = 0 ] && rm -f /var/lock/subsys/shibd $pidfile
58 }
59
60 # See how we were called.
61 case "$1" in
62   start)
63         start
64         ;;
65   stop)
66         stop
67         ;;
68   status)
69         status $shibd
70         RETVAL=$?
71         ;;
72   restart)
73         stop
74         sleep 5
75         start
76         ;;
77   *)
78         echo $"Usage: $prog {start|stop|status|restart}"
79         exit 1
80 esac
81
82 exit $RETVAL