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