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