62a16193a7d5c7905a9f82eeb7d739b271bfbfdc
[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 # Specify wait time to use
37 DAEMON_OPTS="$DAEMON_OPTS -w 30"
38  
39 # Exit if the package is not installed.
40 test -x "$DAEMON" || exit 5
41  
42 . /etc/rc.status
43  
44 # First reset status of this service
45 rc_reset
46  
47 case "$1" in
48     start)
49         echo -n "Starting $DESC ($NAME)"
50         ## Start daemon with startproc(8). If this fails
51         ## the echo return value is set appropriate.
52  
53         # NOTE: startproc return 0, even if service is
54         # already running to match LSB spec.
55         /sbin/startproc -p $PID_FILE $DAEMON $DAEMON_OPTS > /dev/null 2>&1
56  
57         # Remember status and be verbose
58         rc_status -v
59         ;;
60     stop)
61         echo -n "Shutting down $DESC ($NAME)"
62         ## Stop daemon with killproc(8) and if this fails
63         ## set echo the echo return value.
64  
65         /sbin/killproc -p $PID_FILE -TERM $DAEMON > /dev/null 2>&1
66  
67         # Remember status and be verbose
68         rc_status -v
69         ;;
70     try-restart)
71         ## Stop the service and if this succeeds (i.e. the
72         ## service was running before), start it again.
73         ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
74         $0 status >/dev/null &&  $0 restart
75  
76         # Remember status and be quiet
77         rc_status
78         ;;
79     restart)
80         ## Stop the service and regardless of whether it was
81         ## running or not, start it again.
82         $0 stop
83         $0 start
84  
85         # Remember status and be quiet
86         rc_status
87         ;;
88     configtest)
89         ## Check config files
90  
91         echo -n "Checking config for $DESC ($NAME): "
92         $DAEMON $DAEMON_OPTS -t
93         rc_status -v
94         ;;
95     status)
96         echo -n "Checking for service $DESC ($NAME)"
97         ## Check status with checkproc(8), if process is running
98         ## checkproc will return with exit status 0.
99  
100         # Status has a slightly different for the status command:
101         # 0 - service running
102         # 1 - service dead, but /var/run/  pid  file exists
103         # 2 - service dead, but /var/lock/ lock file exists
104         # 3 - service not running
105  
106         # NOTE: checkproc returns LSB compliant status values.
107         /sbin/checkproc -p $PID_FILE $DAEMON
108         rc_status -v
109         ;;
110     *)
111         echo "Usage: $0 {start|stop|status|configtest|try-restart|restart}"
112         exit 1
113         ;;
114 esac
115 rc_exit