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