~andreserl/ubuntu/lucid/keepalived/merge-from-squeeze-lp519940

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-05-12 20:26:15 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090512202615-k850bw35qpuvpq4p
Tags: 1.1.17-1ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/rules: DEB_UPDATE_RCD_PARAMS := expicit init start/stop
    parameters (don't stop at 0 and 6)
  - debian/init.d: init script header adapted to stop rule
  - debian/keepalived.postinst: Remove shutdown and reboot links

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
### BEGIN INIT INFO
 
4
# Provides:      keepalived
 
5
# Required-Start: $remote_fs $syslog
 
6
# Required-Stop : $remote_fs $syslog
 
7
# Default-Start : 3 5
 
8
# Default-Stop  : 0 1 2 6
 
9
# Description   : Start keepalived to allow XY and provide YZ
 
10
# continued on second line by '#<TAB>'
 
11
### END INIT INFO
 
12
 
 
13
 
 
14
DAEMON="Keepalived daemon"
 
15
DAEMON_BIN="/usr/local/sbin/keepalived"
 
16
DAEMON_CONF="/etc/keepalived/keepalived.conf"
 
17
DAEMON_PIDFILE="/var/run/keepalived.pid"
 
18
DAEMON_OPT="-d"
 
19
#DAEMON_USER="root"
 
20
SUPPORTS_HUP="yes"    
 
21
# "yes" if exist next values in freshclam.conf
 
22
#       PidFile /var/run/keepalived.pid
 
23
#       DatabaseOwner root
 
24
 
 
25
pid_par=${DAEMON_PIDFILE:+"-p $DAEMON_PIDFILE"}
 
26
usr_par=${DAEMON_USER:+"-u $DAEMON_USER"}
 
27
 
 
28
test -x $DAEMON_BIN || exit 5
 
29
 
 
30
# Shell functions sourced from /etc/rc.status:
 
31
#      rc_check         check and set local and overall rc status
 
32
#      rc_status        check and set local and overall rc status
 
33
#      rc_status -v     ditto but be verbose in local rc status
 
34
#      rc_status -v -r  ditto and clear the local rc status
 
35
#      rc_failed        set local and overall rc status to failed
 
36
#      rc_failed <num>  set local and overall rc status to <num><num>
 
37
#      rc_reset         clear local rc status (overall remains)
 
38
#      rc_exit          exit appropriate to overall rc status
 
39
. /etc/rc.status
 
40
 
 
41
# First reset status of this service
 
42
rc_reset
 
43
 
 
44
# Return values acc. to LSB for all commands but status:
 
45
# 0 - success
 
46
# 1 - generic or unspecified error
 
47
# 2 - invalid or excess argument(s)
 
48
# 3 - unimplemented feature (e.g. "reload")
 
49
# 4 - insufficient privilege
 
50
# 5 - program is not installed
 
51
# 6 - program is not configured
 
52
# 7 - program is not running
 
53
 
54
# Note that starting an already running service, stopping
 
55
# or restarting a not-running service as well as the restart
 
56
# with force-reload (in case signalling is not supported) are
 
57
# considered a success.
 
58
 
 
59
# remove empty pid files to avoid disturbing warnings by checkproc/killproc
 
60
# (these can occur if dhcpd does not start correctly)
 
61
test -e $DAEMON_PIDFILE && ! test -s $DAEMON_PIDFILE && rm $DAEMON_PIDFILE
 
62
 
 
63
case "$1" in
 
64
        start)
 
65
                echo -n "Starting $DAEMON "
 
66
                if test ! -f ${DAEMON_CONF}; then
 
67
                    echo -n >&2 "Configuration file, ${DAEMON_CONF} does not exist. "
 
68
                    rc_status -s
 
69
                    exit 6
 
70
                fi
 
71
                checkproc $pid_par ${DAEMON_BIN}
 
72
                case $? in
 
73
                    0) echo -n "- Warning: daemon already running. " ;;
 
74
                    1) echo -n "- Warning: ${DAEMON_PIDFILE} exists. " ;;
 
75
                esac
 
76
#               echo "startproc $usr_par $pid_par ${DAEMON_BIN} ${DAEMON_OPT}"
 
77
                startproc $usr_par $pid_par ${DAEMON_BIN} ${DAEMON_OPT}
 
78
                rc_status -v
 
79
                ;;
 
80
        stop)
 
81
                echo -n "Shutting down $DAEMON "
 
82
                checkproc $pid_par ${DAEMON_BIN} || \
 
83
                echo -n " Warning: daemon not running. "
 
84
                killproc $pid_par -t 10 ${DAEMON_BIN}
 
85
                rc_status -v
 
86
                ;;
 
87
        try-restart|condrestart)
 
88
                if test "$1" = "condrestart"; then
 
89
                        echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
 
90
                fi
 
91
                $0 status
 
92
                if test $? = 0; then
 
93
                        $0 restart
 
94
                else 
 
95
                        rc_reset
 
96
                fi
 
97
                rc_status
 
98
                ;;
 
99
        restart)
 
100
                $0 stop
 
101
                $0 start
 
102
                rc_status
 
103
                ;;
 
104
        force-reload|reload)
 
105
                if test "$SUPPORTS_HUP" = "yes"; then
 
106
                    echo -n "Reload service $DAEMON "
 
107
                    checkproc $pid_par ${DAEMON_BIN} && \
 
108
                        touch ${DAEMON_PIDFILE} || \
 
109
                        echo -n >&2 " Warning: daemon not running. "
 
110
                    killproc $pid_par -HUP ${DAEMON_BIN}
 
111
                    rc_status -v
 
112
                else
 
113
                    $0 stop  &&  sleep 3  &&  $0 start
 
114
                    rc_status
 
115
                fi
 
116
                ;;
 
117
        status)
 
118
                echo -n "Checking for $DAEMON "
 
119
                checkproc $pid_par ${DAEMON_BIN}
 
120
                rc_status -v
 
121
                ;;
 
122
        probe)
 
123
                test ${DAEMON_CONF} -nt ${DAEMON_PIDFILE} && echo reload
 
124
                ;;
 
125
        *)
 
126
                echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
 
127
                exit 1
 
128
                ;;
 
129
esac
 
130
rc_exit
 
131