Set LD_LIBRARY_PATH for overridden libcurl on RHEL6.
[shibboleth/cpp-sp.git] / configs / shibd-redhat.in
index e8e9774..d3c0205 100644 (file)
@@ -5,17 +5,22 @@
 # chkconfig: - 98 02
 # description: Shibboleth 2 Service Provider Daemon
 # processname: shibd
-# pidfile: @-VARRUNDIR-@/shibd.pid
+# pidfile: @-PKGRUNDIR-@/shibd.pid
 # config: @-PKGSYSCONFDIR-@/shibboleth2.xml
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 shibd="@-PREFIX-@/sbin/shibd"
 SHIBD_USER=root
-pidfile=@-VARRUNDIR-@/shibd.pid
+pidfile=@-PKGRUNDIR-@/shibd.pid
 prog=shibd
+#VER=`cat /etc/redhat-release | awk '{print $3}' | awk -F . '{print $1}'`
 RETVAL=0
 
+if [ -f /etc/sysconfig/shibd ] ; then
+    . /etc/sysconfig/shibd
+fi
+
 start() {
        echo -n $"Starting $prog: "
        if [ -f /var/lock/subsys/shibd ] ; then
@@ -24,17 +29,20 @@ start() {
                        if checkpid $kpid 2>&1; then
                                echo "process already running"
                                        return -1
-                       else
+                               else
                                        echo "lock file found but no process running for pid $kpid, continuing"
                        fi
                fi
        fi
+
+#_RHEL6_       export LD_LIBRARY_PATH=/opt/shibboleth/lib:$LD_LIBRARY_PATH
        export SHIBD_PID=$pidfile
-       touch $pidfile
-       chown $SHIBD_USER:$SHIBD_USER $pidfile
-       # daemon function just hangs, so I'm using su directly
-       su - $SHIBD_USER -c "$shibd -p $pidfile -f &"
+       touch $pidfile
+       chown $SHIBD_USER:$SHIBD_USER $pidfile
+       if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+               /sbin/restorecon $pidfile
+       fi
+       daemon --user $SHIBD_USER $shibd -p $pidfile -f -w 30
 
        RETVAL=$?
        echo
@@ -44,12 +52,7 @@ start() {
 
 stop() {
        echo -n $"Stopping $prog: "
-       if [ -f $pidfile ]; then
-               read kpid < $pidfile
-               kill $kpid
-       else
-           killproc shibd
-       fi
+       killproc shibd
 
        RETVAL=$?
        echo
@@ -65,7 +68,7 @@ case "$1" in
        stop
        ;;
   status)
-        status $shibd
+       status $shibd
        RETVAL=$?
        ;;
   restart)
@@ -74,7 +77,7 @@ case "$1" in
        start
        ;;
   *)
-       echo $"Usage: $prog {start|stop|restart}"
+       echo $"Usage: $prog {start|stop|status|restart}"
        exit 1
 esac