First stab at SuSE init script.
authorScott Cantor <cantor.2@osu.edu>
Mon, 10 Aug 2009 14:56:05 +0000 (14:56 +0000)
committerScott Cantor <cantor.2@osu.edu>
Mon, 10 Aug 2009 14:56:05 +0000 (14:56 +0000)
configs/Makefile.am
configs/shibd-suse.in [new file with mode: 0644]
shibboleth.spec.in

index 02b2e77..4dbcb18 100644 (file)
@@ -11,6 +11,7 @@ pkgrundir = $(localstatedir)/run/@PACKAGE@
 pkgsysconfdir = $(sysconfdir)/@PACKAGE@
 pkgsysconf_DATA = \
        shibd-redhat \
+       shibd-suse \
        shibd-debian \
        shibd-osx.plist \
        apache.config \
@@ -76,6 +77,9 @@ apache22.config: ${srcdir}/apache22.config.in Makefile ${top_builddir}/config.st
 shibd-redhat: ${srcdir}/shibd-redhat.in Makefile ${top_builddir}/config.status
        $(MAKE) do-build-file FILE=$@
 
+shibd-suse: ${srcdir}/shibd-suse.in Makefile ${top_builddir}/config.status
+    $(MAKE) do-build-file FILE=$@
+
 shibd-debian: ${srcdir}/shibd-debian.in Makefile ${top_builddir}/config.status
        $(MAKE) do-build-file FILE=$@
 
@@ -123,6 +127,7 @@ CLEANFILES = \
        apache2.config \
        apache22.config \
        shibd-redhat \
+       shibd-suse \
        shibd-debian \
        shibd-osx.plist \
        shibd.logger \
@@ -135,6 +140,7 @@ EXTRA_DIST = \
        apache2.config.in \
        apache22.config.in \
        shibd-redhat.in \
+       shibd-suse.in \
        shibd-debian.in \
        shibd-osx.plist.in \
        keygen.bat \
diff --git a/configs/shibd-suse.in b/configs/shibd-suse.in
new file mode 100644 (file)
index 0000000..5b2c285
--- /dev/null
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Author: Peter Schober <peter.schober@univie.ac.at> and many others
+# based on shibd-debian (from Shibboleth's 1.3.1 SP source distribution)
+# and SUSE's /etc/init.d/cyrus
+#
+# /etc/init.d/shibd
+#
+### BEGIN INIT INFO
+# Provides: shibd
+# Required-Start: network
+# Required-Stop:
+# Default-Start: 3 5
+# Default-Stop:
+# Short-Description: Shibboleth 2.x Service Provider Daemon
+# Description: Starts the separate daemon used by the Shibboleth
+# Apache module to manage state and SAML interactions.
+### END INIT INFO
+#
+DESC="Shibboleth 2 daemon"
+NAME=shibd
+SHIB_CONFIG=@-PKGSYSCONFDIR-@/shibboleth2.xml
+DAEMON=@-PREFIX-@/sbin/$NAME
+SCRIPTNAME=/etc/init.d/$NAME
+PID_FILE=@-PKGRUNDIR-@/shibd.pid
+DAEMON_OPTS=""
+# Force removal of socket
+DAEMON_OPTS="$DAEMON_OPTS -f"
+# Use defined configuration file
+DAEMON_OPTS="$DAEMON_OPTS -c $SHIB_CONFIG"
+# Specify pid file to use
+DAEMON_OPTS="$DAEMON_OPTS -p $PID_FILE"
+# Exit if the package is not installed.
+test -x "$DAEMON" || exit 5
+. /etc/rc.status
+# First reset status of this service
+rc_reset
+case "$1" in
+    start)
+        echo -n "Starting $DESC ($NAME)"
+        ## Start daemon with startproc(8). If this fails
+        ## the echo return value is set appropriate.
+        # NOTE: startproc return 0, even if service is
+        # already running to match LSB spec.
+        /sbin/startproc -p $PID_FILE $DAEMON $DAEMON_OPTS > /dev/null 2>&1
+        # Remember status and be verbose
+        rc_status -v
+        ;;
+    stop)
+        echo -n "Shutting down $DESC ($NAME)"
+        ## Stop daemon with killproc(8) and if this fails
+        ## set echo the echo return value.
+        /sbin/killproc -p $PID_FILE -TERM $DAEMON > /dev/null 2>&1
+        # Remember status and be verbose
+        rc_status -v
+        ;;
+    try-restart)
+        ## Stop the service and if this succeeds (i.e. the
+        ## service was running before), start it again.
+        ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
+        $0 status >/dev/null &&  $0 restart
+        # Remember status and be quiet
+        rc_status
+        ;;
+    restart)
+        ## Stop the service and regardless of whether it was
+        ## running or not, start it again.
+        $0 stop
+        $0 start
+        # Remember status and be quiet
+        rc_status
+        ;;
+    configtest)
+        ## Check config files
+        echo -n "Checking config for $DESC ($NAME): "
+        $DAEMON $DAEMON_OPTS -t
+        rc_status -v
+        ;;
+    status)
+        echo -n "Checking for service $DESC ($NAME)"
+        ## Check status with checkproc(8), if process is running
+        ## checkproc will return with exit status 0.
+        # Status has a slightly different for the status command:
+        # 0 - service running
+        # 1 - service dead, but /var/run/  pid  file exists
+        # 2 - service dead, but /var/lock/ lock file exists
+        # 3 - service not running
+        # NOTE: checkproc returns LSB compliant status values.
+        /sbin/checkproc -p $PID_FILE $DAEMON
+        rc_status -v
+        ;;
+    *)
+        echo "Usage: $0 {start|stop|status|configtest|try-restart|restart}"
+        exit 1
+        ;;
+esac
+rc_exit
index e0fd291..7a12633 100644 (file)
@@ -119,7 +119,7 @@ if [ "$APACHE_CONFIG" != "no" ] ; then
     fi
 fi
 
-%if "%{_vendor}" == "redhat"
+%if "%{_vendor}" == "redhat" || "%{_vendor}" == "suse"
        # %{_initddir} not yet in RHEL5, use deprecated %{_initrddir}
        mkdir -p $RPM_BUILD_ROOT%{_initrddir}
        %{__cp} -p $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/shibd-%{_vendor} $RPM_BUILD_ROOT%{_initrddir}/shibd
@@ -150,10 +150,13 @@ sh ./keygen.sh -b
         %{!?_without_builtinapache:/etc/init.d/httpd status 1>/dev/null && /etc/init.d/httpd restart 1>/dev/null}
     fi
 %endif
-
 %if "%{_vendor}" == "suse"
+    # This adds the proper /etc/rc*.d links for the script
+    /sbin/chkconfig --add shibd
+    cd /usr/sbin && ln -s /etc/init.d/shibd rcshibd
     # On upgrade, restart components if they're already running.
     if [ "$1" -gt "1" ] ; then
+        /etc/init.d/shibd status 1>/dev/null && /etc/init.d/shibd restart 1>/dev/null
         %{!?_without_builtinapache:/etc/init.d/apache2 status 1>/dev/null && /etc/init.d/apache2 restart 1>/dev/null}
     fi
 %endif
@@ -165,6 +168,13 @@ sh ./keygen.sh -b
                /sbin/chkconfig --del shibd
        fi
 %endif
+%if "%{_vendor}" == "suse"
+    if [ "$1" = 0 ] ; then
+        /sbin/service shibd stop >/dev/null 2>&1
+        /sbin/chkconfig --del shibd
+        cd /usr/sbin && %{__rm} -f rcshibd
+    fi
+%endif
 
 %ifnos solaris2.8 solaris2.9 solaris2.10
 %postun -p /sbin/ldconfig
@@ -203,6 +213,9 @@ sh ./keygen.sh -b
 %if "%{_vendor}" == "redhat"
 %attr(755, root, root) %{_initrddir}/shibd
 %endif
+%if "%{_vendor}" == "suse"
+%attr(755, root, root) %{_initddir}/shibd
+%endif
 %{_sysconfdir}/%{name}/*.dist
 %{_sysconfdir}/%{name}/apache*.config
 %{_sysconfdir}/%{name}/shibd-*
@@ -220,8 +233,9 @@ sh ./keygen.sh -b
 %doc %{pkgdocdir}/api
 
 %changelog
-* Sat Aug 8 2009 Scott Cantor  <cantor.2@osu.edu>  - 2.2.1-1
+* Mon Aug 10 2009 Scott Cantor  <cantor.2@osu.edu>  - 2.2.1-1
 - Doc handling changes
+- SuSE init script
 
 * Tue Aug 4 2009 Scott Cantor  <cantor.2@osu.edu>  - 2.2.1-1
 - Initial version for 2.2.1, with shibd/httpd restart on upgrade