4
# Required-Start: $network $local_fs
5
# Required-Stop: $network $local_fs
6
# Default-Start: 2 3 4 5
8
# Short-Description: Strongswan IPsec services
11
# Author: Rene Mayrhofer <rene@mayrhofer.eu.org>
13
# PATH should only include /usr/* if it runs after the mountnfs.sh script
14
PATH=/sbin:/usr/sbin:/bin:/usr/bin
15
DESC="strongswan IPsec services"
17
DAEMON=/usr/sbin/$NAME
18
PIDFILE=/var/run/$NAME.pid
19
SCRIPTNAME=/etc/init.d/$NAME
21
# Exit if the package is not installed
22
[ -x "$DAEMON" ] || exit 0
24
# Read configuration variable file if it is present
25
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
27
# Load the VERBOSE setting and other rcS variables
30
# Define LSB log_* functions.
31
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
32
. /lib/lsb/init-functions
35
# Function that starts the daemon/service
40
# 0 if daemon has been started
41
# 1 if daemon was already running
42
# 2 if daemon could not be started
43
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
45
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- start \
50
# Function that stops the daemon/service
55
# 0 if daemon has been stopped
56
# 1 if daemon was already stopped
57
# 2 if daemon could not be stopped
58
# other if a failure occurred
59
# give the proper signal to stop
60
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- stop \
62
# but kill if that didn't work
63
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
65
[ "$RETVAL" = 2 ] && return 2
66
# Wait for children to finish too if this is a daemon that forks
67
# and if the daemon is only ever run from this initscript.
68
# If the above conditions are not satisfied then add some other code
69
# that waits for the process to drop all resources that could be
70
# needed by services started subsequently. A last resort is to
71
# sleep for some time.
72
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
73
[ "$?" = 2 ] && return 2
74
# Many daemons don't delete their pidfiles when they exit.
86
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
89
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
90
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
94
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
97
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
98
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
105
log_daemon_msg "Reloading $DESC" "$NAME"
110
log_daemon_msg "Restarting $DESC" "$NAME"
117
1) log_end_msg 1 ;; # Old process is still running
118
*) log_end_msg 1 ;; # Failed to start
128
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2