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