~ubuntu-branches/ubuntu/utopic/strongswan/utopic

« back to all changes in this revision

Viewing changes to packages/strongswan/debian/strongswan-starter.ipsec.init

  • Committer: Package Import Robot
  • Author(s): Jonathan Davies
  • Date: 2014-01-20 19:00:59 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20140120190059-z8e4dl3g8cd09yi5
Tags: 5.1.2~dr3+git20130120-0ubuntu1
* Upstream Git snapshot for build fixes with regards to entropy.
* debian/rules:
  - Enforcing DEB_BUILD_OPTIONS=nostrip for library integrity checking.
  - Set TESTS_REDUCED_KEYLENGTHS to one generate smallest key-lengths in
    tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
### BEGIN INIT INFO
 
3
# Provides:          vpn
 
4
# Required-Start:    $network $local_fs
 
5
# Required-Stop:     $network $local_fs
 
6
# Default-Start:     2 3 4 5
 
7
# Default-Stop:      0 1 6
 
8
# Short-Description: Strongswan IPsec services
 
9
### END INIT INFO
 
10
 
 
11
# Author: Rene Mayrhofer <rene@mayrhofer.eu.org>
 
12
 
 
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"
 
16
NAME=ipsec
 
17
DAEMON=/usr/sbin/$NAME
 
18
PIDFILE=/var/run/$NAME.pid
 
19
SCRIPTNAME=/etc/init.d/$NAME
 
20
 
 
21
# Exit if the package is not installed
 
22
[ -x "$DAEMON" ] || exit 0
 
23
 
 
24
# Read configuration variable file if it is present
 
25
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
26
 
 
27
# Load the VERBOSE setting and other rcS variables
 
28
. /lib/init/vars.sh
 
29
 
 
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
 
33
 
 
34
#
 
35
# Function that starts the daemon/service
 
36
#
 
37
do_start()
 
38
{
 
39
        # Return
 
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 \
 
44
                || return 1
 
45
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- start \
 
46
                || return 2
 
47
}
 
48
 
 
49
#
 
50
# Function that stops the daemon/service
 
51
#
 
52
do_stop()
 
53
{
 
54
        # Return
 
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 \
 
61
                || return 2
 
62
        # but kill if that didn't work
 
63
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
 
64
        RETVAL="$?"
 
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.
 
75
        rm -f $PIDFILE
 
76
        return "$RETVAL"
 
77
}
 
78
 
 
79
do_reload() {
 
80
        $DAEMON reload
 
81
        return 0
 
82
}
 
83
 
 
84
case "$1" in
 
85
  start)
 
86
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
 
87
        do_start
 
88
        case "$?" in
 
89
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
 
90
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 
91
        esac
 
92
        ;;
 
93
  stop)
 
94
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
 
95
        do_stop
 
96
        case "$?" in
 
97
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
 
98
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 
99
        esac
 
100
        ;;
 
101
  status)
 
102
        $DAEMON status
 
103
        ;;
 
104
  reload|force-reload)
 
105
        log_daemon_msg "Reloading $DESC" "$NAME"
 
106
        do_reload
 
107
        log_end_msg $?
 
108
        ;;
 
109
  restart)
 
110
        log_daemon_msg "Restarting $DESC" "$NAME"
 
111
        do_stop
 
112
        case "$?" in
 
113
          0|1)
 
114
                do_start
 
115
                case "$?" in
 
116
                        0) log_end_msg 0 ;;
 
117
                        1) log_end_msg 1 ;; # Old process is still running
 
118
                        *) log_end_msg 1 ;; # Failed to start
 
119
                esac
 
120
                ;;
 
121
          *)
 
122
                # Failed to stop
 
123
                log_end_msg 1
 
124
                ;;
 
125
        esac
 
126
        ;;
 
127
  *)
 
128
        echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
 
129
        exit 3
 
130
        ;;
 
131
esac
 
132
 
 
133
: