a526cbdcc0d6ff61613c177b22e25c56d5d0d466
[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 #VER=`cat /etc/redhat-release | awk '{print $3}' | awk -F . '{print $1}'`
18 RETVAL=0
19
20 start() {
21         echo -n $"Starting $prog: "
22         if [ -f /var/lock/subsys/shibd ] ; then
23                 if [ -f $pidfile ]; then
24                         read kpid < $pidfile
25                         if checkpid $kpid 2>&1; then
26                                 echo "process already running"
27                                         return -1
28                                 else
29                                         echo "lock file found but no process running for pid $kpid, continuing"
30                         fi
31                 fi
32         fi
33  
34         export SHIBD_PID=$pidfile
35         touch $pidfile
36         chown $SHIBD_USER:$SHIBD_USER $pidfile
37         if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
38                 /sbin/restorecon $pidfile
39         fi
40         daemon --user $SHIBD_USER $shibd -p $pidfile -f -w 30
41
42         RETVAL=$?
43         echo
44                 [ $RETVAL = 0 ] && touch /var/lock/subsys/shibd
45         return $RETVAL
46 }
47
48 stop() {
49         echo -n $"Stopping $prog: "
50         killproc shibd
51
52         RETVAL=$?
53         echo
54         [ $RETVAL = 0 ] && rm -f /var/lock/subsys/shibd $pidfile
55 }
56
57 # See how we were called.
58 case "$1" in
59   start)
60         start
61         ;;
62   stop)
63         stop
64         ;;
65   status)
66         status $shibd
67         RETVAL=$?
68         ;;
69   restart)
70         stop
71         sleep 5
72         start
73         ;;
74   *)
75         echo $"Usage: $prog {start|stop|status|restart}"
76         exit 1
77 esac
78
79 exit $RETVAL