~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

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

  • Committer: Dimitri John Ledkov
  • Date: 2014-05-06 18:45:46 UTC
  • Revision ID: dimitri.ledkov@canonical.com-20140506184546-5toyx56xxrue0f0v
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
#
 
3
# keepalived   LVS cluster monitor daemon.
 
4
#
 
5
#              Written by Andres Salomon <dilinger@voxel.net>
 
6
#
 
7
### BEGIN INIT INFO
 
8
# Provides:          keepalived
 
9
# Required-Start:    $syslog $network $remote_fs
 
10
# Required-Stop:     $syslog $network $remote_fs
 
11
# Default-Start:     2 3 4 5
 
12
# Default-Stop:      1
 
13
# Short-Description: Starts keepalived
 
14
# Description:       Starts keepalived lvs loadbalancer
 
15
### END INIT INFO
 
16
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
17
DAEMON=/usr/sbin/keepalived
 
18
NAME=keepalived
 
19
DESC=keepalived
 
20
CONFIG=/etc/keepalived/keepalived.conf
 
21
TMPFILES="/tmp/.vrrp /tmp/.healthcheckers"
 
22
 
 
23
#includes lsb functions 
 
24
. /lib/lsb/init-functions
 
25
 
 
26
test -f $CONFIG || exit 0 
 
27
test -f $DAEMON || exit 0
 
28
 
 
29
 
 
30
# Read configuration variable file if it is present
 
31
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
32
 
 
33
case "$1" in
 
34
  start)
 
35
        log_daemon_msg "Starting $DESC" "$NAME"
 
36
        for file in $TMPFILES
 
37
        do 
 
38
                test -e $file && test ! -L $file && rm $file
 
39
        done
 
40
        if start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
 
41
               --exec $DAEMON -- $DAEMON_ARGS; then
 
42
                log_end_msg 0
 
43
        else
 
44
                log_end_msg 1
 
45
        fi
 
46
       ;;
 
47
  stop)
 
48
        log_daemon_msg "Stopping $DESC" "$NAME"
 
49
        if start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
 
50
                --exec $DAEMON; then
 
51
                log_end_msg 0
 
52
        else
 
53
                log_end_msg 1
 
54
        fi
 
55
       ;;
 
56
  reload|force-reload)
 
57
        log_action_begin_msg "Reloading $DESC configuration..."
 
58
        if start-stop-daemon --stop --quiet --signal 1 --pidfile \
 
59
               /var/run/$NAME.pid --exec $DAEMON; then
 
60
               log_end_msg 0
 
61
        else
 
62
                log_action_end_msg 1
 
63
        fi
 
64
       ;;
 
65
  restart)
 
66
        log_action_begin_msg "Restarting $DESC" "$NAME"
 
67
 
 
68
        start-stop-daemon --stop --quiet --pidfile \
 
69
                /var/run/$NAME.pid --exec $DAEMON || true 
 
70
       sleep 1
 
71
       if start-stop-daemon --start --quiet --pidfile \
 
72
               /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_ARGS; then
 
73
               log_end_msg 0
 
74
        else
 
75
                log_end_msg 1
 
76
        fi
 
77
       ;;
 
78
  *)
 
79
       echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}" >&2
 
80
       exit 1
 
81
       ;;
 
82
esac
 
83
 
 
84
exit 0