~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init.d/ez-ipupdate

  • 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
 
 
3
### BEGIN INIT INFO
 
4
# Provides:          ez-ipupdate
 
5
# Required-Start:    $local_fs $remote_fs $network
 
6
# Required-Stop:     $local_fs $remote_fs $network
 
7
# Default-Start:     2 3 4 5
 
8
# Default-Stop:      0 1 6
 
9
# Short-Description: ez-ipupdate client for dynamic DNS services
 
10
### END INIT INFO
 
11
 
 
12
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
13
DAEMON=/usr/sbin/ez-ipupdate
 
14
NAME=ez-ipupdate
 
15
DESC="Dynamic DNS client"
 
16
 
 
17
test -f "$DAEMON" || exit 0
 
18
 
 
19
set -e
 
20
 
 
21
# Create the directory where the PID file will be stored
 
22
if [ ! -d "/var/run/$NAME" ]; then
 
23
  mkdir -p "/var/run/$NAME"
 
24
  chown ez-ipupd "/var/run/$NAME"
 
25
fi
 
26
 
 
27
case "$1" in
 
28
  start)
 
29
    echo -n "Starting $DESC:"
 
30
    configs=`find "/etc/$NAME/" -name '*.conf' | \
 
31
            sed -e 's,.*/\(.*\).conf,\1,'`
 
32
    if [ x"$configs" = x ]
 
33
    then
 
34
        echo " no .conf file in /etc/$NAME."
 
35
        exit 0
 
36
    fi
 
37
 
 
38
    echo -n " $NAME"
 
39
    for config in `echo "$configs"`
 
40
    do
 
41
        # Don't run configurations that are not daemons
 
42
        if ! grep -q '^ *daemon' "/etc/$NAME/$config.conf"; then continue; fi
 
43
        # Don't run configurations that run in the foreground
 
44
        if grep -q '^ *foreground' "/etc/$NAME/$config.conf"; then continue; fi
 
45
        # Ok, launch an ez-ipupdate instance
 
46
        if start-stop-daemon --start --quiet \
 
47
            --pidfile "/var/run/$NAME/$config.pid" \
 
48
            --exec "$DAEMON" \
 
49
                -- -d -c "/etc/$NAME/$config.conf" \
 
50
                -F "/var/run/$NAME/$config.pid"
 
51
        then
 
52
            echo -n " $config"
 
53
        fi
 
54
    done
 
55
    echo "."
 
56
    ;;
 
57
  stop)
 
58
    echo -n "Stopping $DESC:"
 
59
    pidfiles=`find "/var/run/$NAME/" -name "*.pid" | \
 
60
            sed -e 's,.*/\(.*\).pid,\1,'`
 
61
    if [ x"$pidfiles" = x ]
 
62
    then
 
63
        echo " no $NAME running."
 
64
        exit 0
 
65
    fi
 
66
 
 
67
    echo -n " $NAME"
 
68
    for pidfile in `echo "$pidfiles"`
 
69
    do
 
70
        if start-stop-daemon --stop --signal 3 --quiet \
 
71
            --pidfile "/var/run/$NAME/$pidfile.pid"
 
72
        then
 
73
            echo -n " $pidfile"
 
74
        fi
 
75
    done
 
76
    echo "."
 
77
    ;;
 
78
  reload)
 
79
    echo -n "Reloading $DESC configuration files:"
 
80
    pidfiles=`find "/var/run/$NAME" -name "*.pid" | \
 
81
            sed -e 's,.*/\(.*\).pid,\1,'`
 
82
    if [ x"$pidfiles" = x ]
 
83
    then
 
84
        echo " no $NAME running."
 
85
        exit 0
 
86
    fi
 
87
 
 
88
    echo -n " $NAME"
 
89
    for pidfile in `echo "$pidfiles"`
 
90
    do
 
91
        if start-stop-daemon --stop --signal 1 --quiet \
 
92
            --pidfile "/var/run/$NAME/$pidfile.pid"
 
93
        then
 
94
            echo -n " $pidfile"
 
95
        fi
 
96
    done
 
97
    echo "."
 
98
    ;;
 
99
  restart|force-reload)
 
100
    $0 stop
 
101
    sleep 1
 
102
    $0 start
 
103
    ;;
 
104
  *)
 
105
    N="/etc/init.d/$NAME"
 
106
    echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
 
107
    exit 1
 
108
    ;;
 
109
esac
 
110
 
 
111
exit 0