aboutsummaryrefslogtreecommitdiffstats
path: root/main/ucarp/ucarp.initd
blob: 66031260e328a3b7327d0df2e7b45b424b978221 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/sbin/openrc-run
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/ucarp/files/ucarp.initd-r1,v 1.1 2013/03/25 10:32:03 dev-zero Exp $

description="UCARP is a portable implementation of the CARP protocol"
description_logstatus="Logs the status of ${SVCNAME} to syslog"
description_demote="Demotes ${SVCNAME} from master to backup"

extra_started_commands="logstatus demote"

command="/usr/sbin/ucarp"
command_args="--interface=${UCARP_INTERFACE} \
              --srcip=${UCARP_SOURCEADDRESS} \
              --vhid=${UCARP_VHID} \
              --passfile=${UCARP_PASSFILE} \
              --addr=${UCARP_VIRTUALADDRESS} \
              --upscript=${UCARP_UPSCRIPT} \
              --downscript=${UCARP_DOWNSCRIPT} \
              --xparam=${UCARP_VIRTUALPREFIX} \
              ${UCARP_OPTS}"

pidfile="/var/run/${SVCNAME}.pid"
command_background="yes"

required_files="${UCARP_PASSFILE} ${UCARP_UPSCRIPT} ${UCARP_DOWNSCRIPT}"

depend() {
        need net
        use logger
        provide ucarp
}

start_pre() {
        local required_vars='UCARP_INTERFACE UCARP_SOURCEADDRESS UCARP_VHID
                             UCARP_PASSFILE UCARP_VIRTUALADDRESS UCARP_UPSCRIPT
                             UCARP_DOWNSCRIPT UCARP_VIRTUALPREFIX'

        local config_var=''
        for config_var in $required_vars; do
                if test -z  "$(eval echo \$$config_var)"; then
                        eerror "Missing or empty config variable '$config_var'"
                        ewarn  "You have to edit /etc/conf.d/${SVCNAME} first"
                        return 1
                fi
        done
}

logstatus() {
        ebegin "Logging status of ${SVCNAME} to syslog"
        start-stop-daemon --signal SIGUSR1 --pidfile "${pidfile}"
        eend $?
}

demote() {
        ebegin "Demote ${SVCNAME} from master to backup"
        start-stop-daemon --signal SIGUSR2 --pidfile "${pidfile}"
        eend $?
}