Fix backslashes in SHIBSP_PREFIX variable by manually creating it during the 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: @-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 function just hangs, so I'm using su directly
40         su - $SHIBD_USER -c "$shibd -p $pidfile -f &"
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         if [ -f $pidfile ]; then
51                 read kpid < $pidfile
52                 kill $kpid
53         else
54             killproc shibd
55         fi
56
57         RETVAL=$?
58         echo
59         [ $RETVAL = 0 ] && rm -f /var/lock/subsys/shibd $pidfile
60 }
61
62 # See how we were called.
63 case "$1" in
64   start)
65         start
66         ;;
67   stop)
68         stop
69         ;;
70   status)
71         status $shibd
72         RETVAL=$?
73         ;;
74   restart)
75         stop
76         sleep 5
77         start
78         ;;
79   *)
80         echo $"Usage: $prog {start|stop|restart}"
81         exit 1
82 esac
83
84 exit $RETVAL