3
# Works for Ubuntu. Check before using on other distributions
6
# Provides: usrmgt-server
7
# Required-Start: $syslog $networking $urandom
8
# Required-Stop: $syslog
9
# Default-Start: 2 3 4 5
11
# Short-Description: IVLE user management server
12
# Description: Daemon connecting to the IVLE user management database.
15
PATH=/sbin:/bin:/usr/sbin:/usr/bin
16
DESC="IVLE user management server"
18
DAEMON=/usr/local/share/ivle/services/$NAME
19
PIDFILE=/var/run/$NAME.pid
20
SCRIPTNAME=/etc/init.d/usrmgt-server
22
# Exit if the daemon does not exist
23
test -f $DAEMON || exit 0
25
# Load the VERBOSE setting and other rcS variables
26
[ -f /etc/default/rcS ] && . /etc/default/rcS
28
# Define LSB log_* functions.
29
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
30
. /lib/lsb/init-functions
33
# Function that starts the daemon/service
38
# 0 if daemon has been started
39
# 1 if daemon was already running
40
# 2 if daemon could not be started
41
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1
42
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON || return 2
43
# Add code here, if necessary, that waits for the process to be ready
44
# to handle requests from services started subsequently which depend
45
# on this one. As a last resort, sleep for some time.
49
# Function that stops the daemon/service
54
# 0 if daemon has been stopped
55
# 1 if daemon was already stopped
56
# 2 if daemon could not be stopped
57
# other if a failure occurred
58
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
60
[ "$RETVAL" = 2 ] && return 2
61
# Wait for children to finish too if this is a daemon that forks
62
# and if the daemon is only ever run from this initscript.
63
# If the above conditions are not satisfied then add some other code
64
# that waits for the process to drop all resources that could be
65
# needed by services started subsequently. A last resort is to
66
# sleep for some time.
67
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
68
[ "$?" = 2 ] && return 2
69
# Many daemons don't delete their pidfiles when they exit.
75
# Function that sends a SIGHUP to the daemon/service
79
# If the daemon can reload its configuration without
80
# restarting (for example, when it is sent a SIGHUP),
81
# then implement that here.
83
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
89
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
92
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
93
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
97
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
100
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
101
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
104
#reload|force-reload)
106
# If do_reload() is not implemented then leave this commented out
107
# and leave 'force-reload' as an alias for 'restart'.
109
#log_daemon_msg "Reloading $DESC" "$NAME"
113
restart|force-reload)
115
# If the "reload" option is implemented then remove the
116
# 'force-reload' alias
118
log_daemon_msg "Restarting $DESC" "$NAME"
125
1) log_end_msg 1 ;; # Old process is still running
126
*) log_end_msg 1 ;; # Failed to start
136
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
137
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2