Use lib macro instead of libdir
[shibboleth/cpp-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 #_RHEL6_        export LD_LIBRARY_PATH=/opt/shibboleth/lib:$LD_LIBRARY_PATH
39         export SHIBD_PID=$pidfile
40         touch $pidfile
41         chown $SHIBD_USER:$SHIBD_USER $pidfile
42         if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
43                 /sbin/restorecon $pidfile
44         fi
45         daemon --user $SHIBD_USER $shibd -p $pidfile -f -w 30
46
47         RETVAL=$?
48         echo
49                 [ $RETVAL = 0 ] && touch /var/lock/subsys/shibd
50         return $RETVAL
51 }
52
53 stop() {
54         echo -n $"Stopping $prog: "
55         killproc shibd
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|status|restart}"
81         exit 1
82 esac
83
84 exit $RETVAL