~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init.d/ahcpd

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
### BEGIN INIT INFO
3
 
# Provides:          ahcpd
4
 
# Required-Start:    $remote_fs $syslog
5
 
# Required-Stop:     $remote_fs $syslog
6
 
# Default-Start:     2 3 4 5
7
 
# Default-Stop:      0 1 6
8
 
# Short-Description: Initscript for ahcpd
9
 
# Description:       Initscript for Ad-Hoc Configuration Protocol daemon
10
 
### END INIT INFO
11
 
 
12
 
# Author: Stéphane Glondu <glondu@debian.org>
13
 
 
14
 
# Based on /etc/init.d/skeleton from initscripts_2.87dsf-10 and an
15
 
# initscript provided by Juliusz Chroboczek.
16
 
 
17
 
# Do NOT "set -e"
18
 
 
19
 
# PATH should only include /usr/* if it runs after the mountnfs.sh script
20
 
PATH=/sbin:/usr/sbin:/bin:/usr/bin
21
 
DESC="Ad-Hoc Configuration Protocol daemon"
22
 
NAME=ahcpd
23
 
DAEMON=/usr/sbin/$NAME
24
 
PIDFILE=/var/run/$NAME.pid
25
 
SCRIPTNAME=/etc/init.d/$NAME
26
 
 
27
 
# Exit if the package is not installed
28
 
[ -x "$DAEMON" ] || exit 0
29
 
 
30
 
# Read configuration variable file if it is present
31
 
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
32
 
 
33
 
# Exit if there is no interfaces
34
 
if [ -z "$INTERFACES" ]; then
35
 
  echo "$DESC: no interfaces to operate on"
36
 
  exit 0
37
 
fi
38
 
 
39
 
# Load the VERBOSE setting and other rcS variables
40
 
. /lib/init/vars.sh
41
 
 
42
 
# Define LSB log_* functions.
43
 
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
44
 
. /lib/lsb/init-functions
45
 
 
46
 
do_start()
47
 
{
48
 
        # Return
49
 
        #   0 if daemon has been started
50
 
        #   1 if daemon was already running
51
 
        #   2 if daemon could not be started
52
 
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
53
 
                || return 1
54
 
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
55
 
                -D -I $PIDFILE $DAEMON_ARGS $INTERFACES \
56
 
                || return 2
57
 
        # Wait for the daemon to be ready
58
 
        sleep 1
59
 
        [ -e $PIDFILE ] || sleep 4
60
 
        [ -e $PIDFILE ] || return 2
61
 
}
62
 
 
63
 
do_stop()
64
 
{
65
 
        # Return
66
 
        #   0 if daemon has been stopped
67
 
        #   1 if daemon was already stopped
68
 
        #   2 if daemon could not be stopped
69
 
        #   other if a failure occurred
70
 
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
71
 
}
72
 
 
73
 
case "$1" in
74
 
  start)
75
 
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
76
 
        do_start
77
 
        case "$?" in
78
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
79
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
80
 
        esac
81
 
        ;;
82
 
  stop)
83
 
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
84
 
        do_stop
85
 
        case "$?" in
86
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
87
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
88
 
        esac
89
 
        ;;
90
 
  status)
91
 
       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
92
 
       ;;
93
 
  restart|force-reload)
94
 
        log_daemon_msg "Restarting $DESC" "$NAME"
95
 
        do_stop
96
 
        case "$?" in
97
 
          0|1)
98
 
                do_start
99
 
                case "$?" in
100
 
                        0) log_end_msg 0 ;;
101
 
                        1) log_end_msg 1 ;; # Old process is still running
102
 
                        *) log_end_msg 1 ;; # Failed to start
103
 
                esac
104
 
                ;;
105
 
          *)
106
 
                # Failed to stop
107
 
                log_end_msg 1
108
 
                ;;
109
 
        esac
110
 
        ;;
111
 
  *)
112
 
        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
113
 
        exit 3
114
 
        ;;
115
 
esac
116
 
 
117
 
: