community/keepalived: improve runscript, run with --dont-fork

This commit is contained in:
Jakub Jirutka 2017-11-11 21:42:46 +01:00
parent 88e4d967f8
commit a49eca1d4d
4 changed files with 65 additions and 11 deletions

View File

@ -3,7 +3,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=keepalived
pkgver=1.3.9
pkgrel=1
pkgrel=2
pkgdesc="Health Checking for Linux Virtual Server & High-Availability"
url="http://www.keepalived.org/"
arch="all"
@ -15,6 +15,7 @@ install="$pkgname.post-upgrade"
subpackages="$pkgname-doc $pkgname-sample-config:samples:noarch
$pkgname-common $pkgname-snmp"
source="http://www.keepalived.org/software/$pkgname-$pkgver.tar.gz
always-use-pid-dir.patch
$pkgname.initd
$pkgname.confd
"
@ -103,5 +104,6 @@ samples() {
}
sha512sums="283bfb35052c8f742050c03ce1b24c3db19fb43fbee9307b50ae719b5d06e461dfa4fda3a167afddd2aae216a97f6e84f79c5f0bdbe5c439f339b0f41fa83cd7 keepalived-1.3.9.tar.gz
12361313dd044269150c9ea1a4ffc6987075b0106dfdd4b3804b1852d2a47f608d954ab473419474747b475c98fade3779800be8147134969016817cfa050ee4 keepalived.initd
413cb05aa2d1d8c0f552398bb5d511ee022b4d07f5b18217350c1159d013f2d26d87ae63d2977329ec78d7416760e84c4048a5ad20a1f63ef2bc3a1a84c3a41a keepalived.confd"
469458b60c90948dff39fc587dbe076bece3ee5f834461110996c27802bd3690008e0034a9566648816f43cf8cc058cb7d1760358b81bbd070544e77f14391fa always-use-pid-dir.patch
4f1a3fdb0a936707a234efa063296f575fa8168551c87d2f9d43b7681d24605f852b4ddb2c674d1e311111f85232a708939a71cf128eb57c940ccb6927518dd4 keepalived.initd
2e6a9411d78fb954b5ede75d04225bf3f37d9ef4773c2b3587e1de1a0795f61a1ed784fa229854c2ee97f153205c3f76b3ff79cd55ede07f211731f0d17569cb keepalived.confd"

View File

@ -0,0 +1,17 @@
keepalived insists on creating PID files, so at least don't let it create in
/run (to avoid clash with OpenRC), but /run/keepalived. keepalived will
automatically create and delete this directory.
This is a downstream patch.
--- a/keepalived/core/main.c
+++ b/keepalived/core/main.c
@@ -87,7 +87,7 @@
#endif
static char *syslog_ident; /* syslog ident if not default */
char *instance_name; /* keepalived instance name */
-bool use_pid_dir; /* Put pid files in /var/run/keepalived or @localstatedir@/run/keepalived */
+bool use_pid_dir = true; /* Put pid files in /var/run/keepalived or @localstatedir@/run/keepalived */
unsigned os_major; /* Kernel version */
unsigned os_minor;

View File

@ -1,2 +1,13 @@
# Keepalived options, see keepalived(8) man page.
#KEEPALIVED_OPTS="-D"
# Configuration for /etc/init.d/keepalived
# Path of the configuration file.
#cfgfile="/etc/keepalived/keepalived.conf"
# Skip any configuration lines beginning '@' that don't match this id
# or any lines beginning @^ that do match.
# The config-id defaults to the node name if option not used.
#config_id=
# Additional options to pass to the keepalived command.
# See keepalived(8) man page.
#command_args=""

View File

@ -1,13 +1,23 @@
#!/sbin/openrc-run
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_commands="reload"
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"
command_args="${KEEPALIVED_OPTS}"
pidfile="/run/keepalived.pid"
required_files="/etc/keepalived/keepalived.conf"
# 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
@ -16,8 +26,22 @@ depend() {
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
}