~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

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

  • 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:          ipband
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: ipband daemon
9
 
# Description:       This is a daemon which can monitor as many different subnets (or individual
10
 
#                    hosts, by specifying a "subnet" of /32) as you'd like.
11
 
### END INIT INFO
12
 
 
13
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
14
 
DAEMON=/usr/sbin/ipband
15
 
NAME=ipband
16
 
DESC=ipband
17
 
PIDDIR=/var/run/ipband
18
 
 
19
 
set -e
20
 
 
21
 
test -x $DAEMON || exit 0
22
 
 
23
 
if [ -r /etc/default/ipband ]; then
24
 
    . /etc/default/ipband
25
 
else
26
 
    printf "/etc/default/ipband is not readable, not starting ipband.\n"
27
 
    exit 0
28
 
fi
29
 
 
30
 
case "$1" in
31
 
  start)
32
 
        printf "Starting $DESC:"
33
 
        mkdir -p $PIDDIR
34
 
        for config_file in $CONFIG_FILES; do
35
 
            if [ ! -r "$config_file" ]; then
36
 
                [ "$CONFIG" = "true" ] || CONFIG="false"
37
 
            else
38
 
                CONFIG="true"
39
 
                IDENTIFIER="$(printf "$config_file" | tr / _)"
40
 
                start-stop-daemon --start --background --make-pidfile \
41
 
                    --quiet --pidfile "$PIDDIR/$IDENTIFIER.pid" \
42
 
                    --exec $DAEMON -- $FLAGS -c "$config_file"
43
 
                printf " $config_file"
44
 
            fi
45
 
        done
46
 
        [ "$CONFIG" = "false" ] && printf " no configuration files found"
47
 
        printf ".\n"
48
 
        ;;
49
 
  stop)
50
 
        printf "Stopping $DESC: "
51
 
        for pid_file in $PIDDIR/*.pid; do
52
 
            if [ ! -f "$pid_file" ]; then continue; fi
53
 
            start-stop-daemon --oknodo --stop --quiet --pidfile "$pid_file" \
54
 
                                --exec $DAEMON -- $FLAGS && \
55
 
                rm -f $pid_file
56
 
 
57
 
        done
58
 
        printf "$NAME.\n"
59
 
        ;;
60
 
  restart|force-reload)
61
 
        $0 stop || true
62
 
        $0 start
63
 
        ;;
64
 
  status)
65
 
        count=$(ls -1 $PIDDIR/*.pid 2>/dev/null | wc -l)
66
 
        if [ $count -gt 0 ]; then
67
 
            echo -n "ipband is running $count configuration"
68
 
            [ $count -eq 1 ] || echo -n "s"
69
 
            echo "."
70
 
        else
71
 
            echo "Ipband is not running."
72
 
        fi
73
 
        ;;
74
 
  *)
75
 
        N=/etc/init.d/$NAME
76
 
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
77
 
        exit 1
78
 
        ;;
79
 
esac
80
 
 
81
 
exit 0