aboutsummaryrefslogtreecommitdiffstats
path: root/community/keepalived/keepalived.initd
blob: ce3d1a3b792aac5f8da4cd9b8e9ec07482b50101 (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
#!/sbin/openrc-run

extra_started_commands="data reload stats"
description_data="Write configuration data to /tmp/keepalived.data"
description_reload="Close down all interfaces, reload its configuration, and start up with new configuration"
description_stats="Print statistics info"

: ${cfgfile:="/etc/keepalived/keepalived.conf"}

command="/usr/sbin/keepalived"
# Note: KEEPALIVED_OPTS is for backward compatibility.
command_args="
	--dont-fork
	--use-file=$cfgfile
	${config_id:+"--config-id=$config_id"}
	${command_args:-${KEEPALIVED_OPTS:-}}"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"

required_files="$cfgfile"

depend() {
	use logger
	# The interfaces do not actually need to exist to start,
	# it handles them gracefully.
	use net
}

data() {
	ebegin "Writing configuration data to /tmp/keepalived.data"
	start-stop-daemon --pidfile $pidfile --signal USR1
	eend $?
}

reload() {
	ebegin "Reloading keepalived.conf"
	start-stop-daemon --pidfile $pidfile --signal HUP
	eend $?
}

stats() {
	ebegin "Dumping stats"
	start-stop-daemon --pidfile $pidfile --signal USR2
	eend $?

	cat /tmp/keepalived.stats
}