https://issues.shibboleth.net/jira/browse/SSPCPP-261
[shibboleth/cpp-sp.git] / configs / shibd-suse.in
1 #! /bin/sh
2 # Author: Peter Schober <peter.schober@univie.ac.at> and many others
3 # based on shibd-debian (from Shibboleth's 1.3.1 SP source distribution)
4 # and SUSE's /etc/init.d/cyrus
5 #
6 # /etc/init.d/shibd
7 #
8 ### BEGIN INIT INFO
9 # Provides: shibd
10 # Required-Start: $local_fs $remote_fs $network
11 # Should-Start: $time
12 # Should-Stop: $time
13 # Required-Stop: $local_fs $remote_fs $network
14 # Default-Start: 3 5
15 # Default-Stop: 0 1 2 6 
16 # Short-Description: Shibboleth 2.x Service Provider Daemon
17 # Description: Starts the separate daemon used by the Shibboleth
18 # Apache module to manage state and SAML interactions.
19 ### END INIT INFO
20 #
21  
22 DESC="Shibboleth 2 daemon"
23 NAME=shibd
24 SHIB_CONFIG=@-PKGSYSCONFDIR-@/shibboleth2.xml
25 DAEMON=@-PREFIX-@/sbin/$NAME
26 SCRIPTNAME=/etc/init.d/$NAME
27 PID_FILE=@-PKGRUNDIR-@/shibd.pid
28 DAEMON_OPTS=""
29  
30 # Force removal of socket
31 DAEMON_OPTS="$DAEMON_OPTS -f"
32  
33 # Use defined configuration file
34 DAEMON_OPTS="$DAEMON_OPTS -c $SHIB_CONFIG"
35  
36 # Specify pid file to use
37 DAEMON_OPTS="$DAEMON_OPTS -p $PID_FILE"
38
39 # Specify wait time to use
40 DAEMON_OPTS="$DAEMON_OPTS -w 30"
41  
42 # Exit if the package is not installed.
43 test -x "$DAEMON" || exit 5
44  
45 . /etc/rc.status
46  
47 # First reset status of this service
48 rc_reset
49  
50 case "$1" in
51     start)
52         echo -n "Starting $DESC ($NAME)"
53         ## Start daemon with startproc(8). If this fails
54         ## the echo return value is set appropriate.
55  
56         # NOTE: startproc return 0, even if service is
57         # already running to match LSB spec.
58         /sbin/startproc -p $PID_FILE $DAEMON $DAEMON_OPTS > /dev/null 2>&1
59  
60         # Remember status and be verbose
61         rc_status -v
62         ;;
63     stop)
64         echo -n "Shutting down $DESC ($NAME)"
65         ## Stop daemon with killproc(8) and if this fails
66         ## set echo the echo return value.
67  
68         /sbin/killproc -p $PID_FILE -TERM $DAEMON > /dev/null 2>&1
69  
70         # Remember status and be verbose
71         rc_status -v
72         ;;
73     try-restart)
74         ## Stop the service and if this succeeds (i.e. the
75         ## service was running before), start it again.
76         ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
77         $0 status >/dev/null &&  $0 restart
78  
79         # Remember status and be quiet
80         rc_status
81         ;;
82     restart)
83         ## Stop the service and regardless of whether it was
84         ## running or not, start it again.
85         $0 stop
86         $0 start
87  
88         # Remember status and be quiet
89         rc_status
90         ;;
91     configtest)
92         ## Check config files
93  
94         echo -n "Checking config for $DESC ($NAME): "
95         $DAEMON $DAEMON_OPTS -t
96         rc_status -v
97         ;;
98     status)
99         echo -n "Checking for service $DESC ($NAME)"
100         ## Check status with checkproc(8), if process is running
101         ## checkproc will return with exit status 0.
102  
103         # Status has a slightly different for the status command:
104         # 0 - service running
105         # 1 - service dead, but /var/run/  pid  file exists
106         # 2 - service dead, but /var/lock/ lock file exists
107         # 3 - service not running
108  
109         # NOTE: checkproc returns LSB compliant status values.
110         /sbin/checkproc -p $PID_FILE $DAEMON
111         rc_status -v
112         ;;
113     *)
114         echo "Usage: $0 {start|stop|status|configtest|try-restart|restart}"
115         exit 1
116         ;;
117 esac
118 rc_exit