aboutsummaryrefslogtreecommitdiffstats
path: root/main/ucarp/ucarp.initd
diff options
context:
space:
mode:
authorLeonardo Arena <rnalrd@gmail.com>2009-12-28 13:20:29 +0000
committerLeonardo Arena <rnalrd@gmail.com>2009-12-28 13:20:29 +0000
commit7355868966657a48aae3266d9d23ebccd87f638f (patch)
tree62f9443b654ae966b7c2351b754a865cb3c339a8 /main/ucarp/ucarp.initd
parentb452ef351f0b3c652436ba1a747aa1f6dfcba4af (diff)
downloadaports-7355868966657a48aae3266d9d23ebccd87f638f.tar.bz2
aports-7355868966657a48aae3266d9d23ebccd87f638f.tar.xz
testing/ucarp: moved to main
Diffstat (limited to 'main/ucarp/ucarp.initd')
-rwxr-xr-xmain/ucarp/ucarp.initd62
1 files changed, 62 insertions, 0 deletions
diff --git a/main/ucarp/ucarp.initd b/main/ucarp/ucarp.initd
new file mode 100755
index 0000000000..ff101fce47
--- /dev/null
+++ b/main/ucarp/ucarp.initd
@@ -0,0 +1,62 @@
+#!/sbin/runscript
+# Copyright 1999-2008 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" )
+}
+
+if [ -z "$REALIP" ]; then
+ REALIP=$( get_first_ip $IFACE )
+fi
+
+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 $?
+}
+
+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
+}
+
+stop () {
+ ebegin "Shutting down ucarp $IFACE"
+ start-stop-daemon --stop --exec $DAEMON \
+ -p /var/run/ucarp-$IFACE.pid
+ eend $?
+}
+