4
# Required-Start: $local_fs $remote_fs $network
5
# Required-Stop: $local_fs $remote_fs
6
# Default-Start: 2 3 4 5
8
# Short-Description: Shibboleth 2 Service Provider Daemon
9
# Description: Starts the separate daemon used by the Shibboleth
10
# Apache module to manage sessions and to retrieve
11
# attributes from Shibboleth Identity Providers.
14
# Written by Quanah Gibson-Mount <quanah@stanford.edu>
15
# Modified by Lukas Haemmerle <lukas.haemmerle@switch.ch> for Shibboleth 2
16
# Updated to use the LSB init functions by Russ Allbery <rra@debian.org>
18
# Based on the dh-make template written by:
20
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
22
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
24
PATH=/sbin:/bin:/usr/sbin:/usr/bin
25
DESC="Shibboleth 2 daemon"
28
SHIBSP_CONFIG=/etc/shibboleth/shibboleth2.xml
29
LD_LIBRARY_PATH=/usr/lib
30
DAEMON=/usr/sbin/$NAME
31
SCRIPTNAME=/etc/init.d/$NAME
32
PIDFILE=/var/run/shibboleth/$NAME.pid
36
# Force removal of socket
37
DAEMON_OPTS="$DAEMON_OPTS -f"
39
# Use defined configuration file
40
DAEMON_OPTS="$DAEMON_OPTS -c $SHIBSP_CONFIG"
42
# Specify pid file to use
43
DAEMON_OPTS="$DAEMON_OPTS -p $PIDFILE"
45
# Specify wait time to use
46
DAEMON_OPTS="$DAEMON_OPTS -w 30"
48
# Exit if the package is not installed.
49
[ -x "$DAEMON" ] || exit 0
51
# Read configuration if it is present.
52
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
54
# Load the VERBOSE setting and other rcS variables
57
# Define LSB log_* functions.
58
. /lib/lsb/init-functions
60
prepare_environment () {
61
# Ensure /var/run/shibboleth exists. /var/run may be on a tmpfs file system.
62
[ -d '/var/run/shibboleth' ] || mkdir -p '/var/run/shibboleth'
64
# If $DAEMON_USER is set, try to run shibd as that user. However,
65
# versions of the Debian package prior to 2.3+dfsg-1 ran shibd as root,
66
# and the local administrator may not have made the server's private key
67
# readable by $DAEMON_USER. We therefore test first by running shibd -t
68
# and looking for the error code indicating that the private key could not
69
# be read. If we get that error, we fall back on running shibd as root.
70
if [ -n "$DAEMON_USER" ]; then
71
DIAG=$(su -s $DAEMON $DAEMON_USER -- -t $DAEMON_OPTS 2>/dev/null)
73
# openssl errstr 200100D (hex for 33558541) says:
74
# error:0200100D:system library:fopen:Permission denied
75
ERROR='ERROR OpenSSL : error code: 33558541 '
76
if echo "$DIAG" | fgrep -q "$ERROR" ; then
78
log_warning_msg "$NAME: file permissions require running as" \
81
chown -Rh "$DAEMON_USER" '/var/run/shibboleth' '/var/log/shibboleth'
85
log_warning_msg "$NAME: unable to run config check as user" \
95
# 0 if daemon has been started
96
# 1 if daemon was already running
97
# 2 if daemon could not be started
98
start-stop-daemon --start --quiet ${DAEMON_USER:+--chuid $DAEMON_USER} \
99
--pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
101
start-stop-daemon --start --quiet ${DAEMON_USER:+--chuid $DAEMON_USER} \
102
--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS \
109
# 0 if daemon has been stopped
110
# 1 if daemon was already stopped
111
# 2 if daemon could not be stopped
112
# other if a failure occurred
113
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
114
--pidfile $PIDFILE --name $NAME
123
# Don't start shibd if NO_START is set.
124
if [ "$NO_START" = 1 ] ; then
125
if [ "$VERBOSE" != no ] ; then
126
echo "Not starting $DESC (see /etc/default/$NAME)"
130
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
133
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
134
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
138
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
141
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
142
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
145
restart|force-reload)
148
log_daemon_msg "Restarting $DESC" "$NAME"
155
1) log_end_msg 1 ;; # Old process is still running
156
*) log_end_msg 1 ;; # Failed to start
166
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
169
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2