Commit 119c3b8f authored by Natanael Copa's avatar Natanael Copa
Browse files

main/ucarp: sync initscript with gentoo

parent 4a6f7e78
# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer:
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ucarp
pkgver=1.5.2
pkgrel=4
pkgrel=5
pkgdesc="Share common IP and do fail over"
url="http://www.ucarp.org"
arch="all"
......@@ -13,7 +13,10 @@ install=
subpackages=""
source="http://download.pureftpd.org/pub/ucarp/$pkgname-$pkgver.tar.gz
ucarp.initd
ucarp.confd"
ucarp.confd
vip-up-default.sh
vip-down-default.sh
"
build() {
cd "$srcdir/$pkgname-$pkgver"
......@@ -31,8 +34,24 @@ package() {
make DESTDIR="$pkgdir" install || return 1
install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
install -d "$pkgdir"/etc/ucarp
for i in vip-up-default.sh vip-down-default.sh; do
install -m755 -D "$srcdir"/$i "$pkgdir"/etc/ucarp/$i || return 1
done
}
md5sums="e3caa733316a32c09e5d3817617e9145 ucarp-1.5.2.tar.gz
f73f9da77f874a3cd6b4e48ba6094363 ucarp.initd
bf914f6ce4fe4fea33a45d4d5b2c1fff ucarp.confd"
f3880270bd0f0d42273b2e1d4823cddc ucarp.initd
286e614e50a24632b34226ce3eddf027 ucarp.confd
d040d0f4449742e95fa9c03411e23741 vip-up-default.sh
4453c2bd2a27d6ee23897d8fb61f4f7d vip-down-default.sh"
sha256sums="f3cc77e28481fd04f62bb3d4bc03104a97dd316c80c0ed04ad7be24b544112f3 ucarp-1.5.2.tar.gz
12dc534631477e9ca8c680ae3b2aa5fda4a7e5b2e4b13ebb9180d933b066b0fb ucarp.initd
3767e5d33cf43ca4f05d01e32683c0c8b4a737a5c7c00d55ec8b389f4fea22f2 ucarp.confd
41cdfdf20f802dcdf7bed9206752d9f232fdc47891ee5103a10a8344131a555f vip-up-default.sh
864b62a05eadf0b1bcd097d31803ba019ad5e6e8e3776bd38c56e073ab4b7f00 vip-down-default.sh"
sha512sums="568ff2061e59d314c72a160ccb42eb099bf7cdf04bc30f405b5b62322dff3ceb4fa037c2b430fdb4cee25f0dcacf9309a15bd814b4b70b640840400bda20b253 ucarp-1.5.2.tar.gz
59a9f9ff9ea550015f305327a26e21001464d4337d322f7357c0ad38a8296656afb931e4ebf07f300ab496a7eb3a58af84aa89e8cef2f3bd338a44dda175e7ad ucarp.initd
854b25e99896ba165919916ff31103717e539c0c3a933f451428f62a9c3eee0367787ff8deb4d582156fa4a6be620412aa98fdb615c269d178d606ac1bce818e ucarp.confd
4db8a047c39671578d0fa0e0dfadf3ce6e4f5881a85811c5c8e986f26c97b5de64cc58578cd77ba9ee93e2c6659b178c69575d3006934da56736441c30c703ce vip-up-default.sh
026988d259ab07568995e0609ee0b22245abcf26c65e7c3ddeea8efc801a78eb2796e7423c52731b8070db99e410db4de8217d0a3b7b8681d399fef25c64e56f vip-down-default.sh"
# Things you can set here
# REALIP - if not set, will be first addr on iface
# VHID - Virtual Server ID
# VIP - The Virtual IP
# PASSWORD - The password for the carp announcements
# EXTRA_ARGS - extra arguments
REALIP=
VHID=2
VIP=127.0.0.1
PASSWORD=SecretPassword
#EXTRA_ARGS="--neutral --advbase=3"
# /etc/conf.d/ucarp: config file for /etc/init.d/ucarp
# The network interface to bind to, for example 'eth0'
UCARP_INTERFACE=
# The persistent source address, (real IP), associated with this interface.
UCARP_SOURCEADDRESS=
# The IP address of the virtual server.
UCARP_VIRTUALADDRESS=
# The prefix length of the virtual server IP address
# For example 24 for a netmask of 255.255.255.0
UCARP_VIRTUALPREFIX=
# The id of the virtual server [1-255].
UCARP_VHID=123
# File to read the shared password from.
UCARP_PASSFILE=/etc/ucarp/ucarp.pass
# Specifies the command to run after ucarp has successfully become master.
UCARP_UPSCRIPT=/etc/ucarp/vip-up-default.sh
# Specifies the command that is run after ucarp has transitioned to the backup
# state.
UCARP_DOWNSCRIPT=/etc/ucarp/vip-down-default.sh
# Additional ucarp options to pass
UCARP_OPTS="--shutdown"
#!/sbin/runscript
# Copyright 1999-2008 Gentoo Foundation
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# A simple script to start and stop a ucarp instance
DAEMON=/usr/sbin/ucarp
IFACE="${SVCNAME#*.}"
if [ -n "$IFACE" ] && [ "${SVCNAME}" != "ucarp" ]; then
UP="/etc/ucarp/vip-up-$IFACE.sh"
DOWN="/etc/ucarp/vip-down-$IFACE.sh"
. /etc/conf.d/ucarp.$IFACE
else
UP="/etc/ucarp/vip-up.sh"
DOWN="/etc/ucarp/vip-down.sh"
fi
# Get the primary ip address for a given interface
get_first_ip() {
local foo=$( ip addr show $1 )
[ $? != 0 ] && foo=""
echo $( echo "$foo" | grep "inet " | head -n1 | \
sed "s+^.*inet ++g; s+/.*$++g" )
# $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
}
if [ -z "$REALIP" ]; then
REALIP=$( get_first_ip $IFACE )
fi
depend () {
need net
after firewall
}
start () {
ebegin "Starting ucarp $IFACE"
start-stop-daemon --start --exec $DAEMON \
--background -m -p /var/run/ucarp-$IFACE.pid -- \
-i $IFACE -s $REALIP -v $VHID -p $PASSWORD -a $VIP \
-u $UP -d $DOWN $EXTRA_ARGS -z
eend $?
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
}
status () {
ebegin "ucarp $IFACE is ..."
PIDS=$( pidof $( basename $DAEMON ))
PID=$( cat /var/run/ucarp-$IFACE.pid 2>/dev/null )
[ -n "$PID" ] && OK=$( echo "$PIDS" | grep "$PID" )
if [ -n "$OK" ]; then
echo "running"
exit 0
else
echo "not running"
exit 1
fi
logstatus() {
ebegin "Logging status of ${SVCNAME} to syslog"
start-stop-daemon --signal SIGUSR1 --pidfile "${pidfile}"
eend $?
}
stop () {
ebegin "Shutting down ucarp $IFACE"
start-stop-daemon --stop --exec $DAEMON \
-p /var/run/ucarp-$IFACE.pid
eend $?
demote() {
ebegin "Demote ${SVCNAME} from master to backup"
start-stop-daemon --signal SIGUSR2 --pidfile "${pidfile}"
eend $?
}
#! /bin/sh
exec 2> /dev/null
/sbin/ip addr del "$2"/"$3" dev "$1"
# or alternatively:
# /sbin/ifconfig "$1":254 down
#! /bin/sh
exec 2> /dev/null
/sbin/ip addr add "$2"/"$3" dev "$1"
# or alternatively:
# /sbin/ifconfig "$1":254 "$2" netmask "$3"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment