Author: matik Date: Tue Mar 30 22:06:49 2010 GMT Module: packages Tag: HEAD ---- Log message: - upped to 1.5.1 - created initscript and configuration based on OpenVPN - rel 1 - should not break current usage
---- Files affected: packages/ucarp: ucarp.spec (1.12 -> 1.13) , ucarp.config.template (NONE -> 1.1) (NEW), ucarp.init (NONE -> 1.1) (NEW), ucarp.sysconfig (NONE -> 1.1) (NEW) ---- Diffs: ================================================================ Index: packages/ucarp/ucarp.spec diff -u packages/ucarp/ucarp.spec:1.12 packages/ucarp/ucarp.spec:1.13 --- packages/ucarp/ucarp.spec:1.12 Thu May 28 23:36:34 2009 +++ packages/ucarp/ucarp.spec Wed Mar 31 00:06:44 2010 @@ -8,10 +8,14 @@ Group: Applications/Networking Source0: ftp://ftp.ucarp.org/pub/ucarp/%{name}-%{version}.tar.gz # Source0-md5: 391caa69fc17ffbc8a3543d8692021c9 +Source1: %{name}.init +Source2: %{name}.sysconfig +Source3: %{name}.config.template URL: http://www.ucarp.org/ BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool +BuildRequires: libpcap-devel BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) %description @@ -55,13 +59,38 @@ %{__make} install \ DESTDIR=$RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT%{_sysconfdir}/{%{name},rc.d/init.d,sysconfig} $RPM_BUILD_ROOT/%{_varrun}/%{name} +install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/%{name} +install %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name} +install %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/config.template +install examples/linux/vip-down.sh $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/ +install examples/linux/vip-up.sh $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/ + %clean rm -rf $RPM_BUILD_ROOT +%post +/sbin/chkconfig --add ucarp +%service ucarp restart "UCARP" + +%preun +if [ "$1" = "0" ]; then + %service ucarp stop + /sbin/chkconfig --del ucarp +fi + + %files %defattr(644,root,root,755) -%doc ChangeLog README +%{_sysconfdir}/sysconfig/%{name} +%{_varrun}/%{name} +%attr(755,root,root) %{_sysconfdir}/rc.d/init.d/%{name} %attr(755,root,root) %{_sbindir}/* +%dir %{_sysconfdir}/%{name} +%attr(750,root,root) %{_sysconfdir}/%{name} +%attr(640,root,root) %{_sysconfdir}/%{name}/* +%attr(750,root,root) %{_sysconfdir}/%{name}/vip-down.sh +%attr(750,root,root) %{_sysconfdir}/%{name}/vip-up.sh %define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`) %changelog @@ -69,6 +98,12 @@ All persons listed below can be reached at <cvs_login>@pld-linux.org $Log$ +Revision 1.13 2010/03/30 22:06:44 matik +- upped to 1.5.1 +- created initscript and configuration based on OpenVPN +- rel 1 +- should not break current usage + Revision 1.12 2009/05/28 21:36:34 areq - 1.5.1 ================================================================ Index: packages/ucarp/ucarp.config.template diff -u /dev/null packages/ucarp/ucarp.config.template:1.1 --- /dev/null Wed Mar 31 00:06:49 2010 +++ packages/ucarp/ucarp.config.template Wed Mar 31 00:06:44 2010 @@ -0,0 +1,28 @@ +# options for ucarp instance +#### +# Available options (--daemonize is added by default, --addr= is generated +# from the name of this file) : +# +# --interface=<if> (-i <if>): bind interface <if> +# --srcip=<ip> (-s <ip>): source (real) IP address of that host +# --vhid=<id> (-v <id>): virtual IP identifier (1-255) +# --pass=<pass> (-p <pass>): password +# --passfile=<file> (-o <file>): read password from file +# --preempt (-P): becomes a master as soon as possible +# --neutral (-n): don't run downscript at start if backup +# --help (-h): summary of command-line options +# --advbase=<seconds> (-b <seconds>): advertisement frequency +# --advskew=<skew> (-k <skew>): advertisement skew (0-255) +# --upscript=<file> (-u <file>): run <file> to become a master +# --downscript=<file> (-d <file>): run <file> to become a backup +# --deadratio=<ratio> (-r <ratio>): ratio to consider a host as dead +# --shutdown (-z): call shutdown script at exit +# --ignoreifstate (-S): ignore interface state (down, no carrier) +# --nomcast (-M): use broadcast (instead of multicast) advertisements +# --facility=<facility> (-f): set syslog facility (default=daemon) +# --xparam=<value> (-x): extra parameter to send to up/down scripts + +# make sure to specify at least --srcip, --vhid and --pass (or --passfile), +# --upscript and --downscript + +#UCARP_OPTS="--upscript=/etc/ucarp/vip-up.sh --downscript=/etc/ucarp/vip-down.sh" ================================================================ Index: packages/ucarp/ucarp.init diff -u /dev/null packages/ucarp/ucarp.init:1.1 --- /dev/null Wed Mar 31 00:06:49 2010 +++ packages/ucarp/ucarp.init Wed Mar 31 00:06:44 2010 @@ -0,0 +1,169 @@ +#!/bin/sh +# +# ucarp Start/stop the UCARP daemon. +# +# chkconfig: 2345 11 89 +# +# description: UCARP is Common Address Redundancy Protocol (CARP) \ +# for Unix +# + +# Get service config +[ -f /etc/sysconfig/ucarp ] && . /etc/sysconfig/ucarp + +CONFIG_VIRTUAL_IPS=$VIRTUAL_IPS + +[ -n "$2" ] && VIRTUAL_IPS="$2" + +# no virtual IPs. exit silently +if [ -z "$VIRTUAL_IPS" ]; then + case "$1" in + start|stop|restart|reload|force-reload) + exit 0 + ;; + esac +fi + +# Source function library +. /etc/rc.d/init.d/functions + +# Source networking configuration. +. /etc/sysconfig/network + +# Check that networking is up. +if is_yes "${NETWORKING}"; then + if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then + msg_network_down UCARP + exit 1 + fi +else + exit 0 +fi + +# check if the virtual ip $1 s up +vipup() { + local vip="$1" + local pidfile=/var/run/ucarp/$vip.pid + local pid=$(cat $pidfile 2>/dev/null) + kill -0 $pid 2>/dev/null + return $? +} + +# check if all the configured virtual IPs are up +vipsup() { + ret=0 + for vip in $CONFIG_VIRTUAL_IPS; do + vipup $vip && continue + ret=1 + done + return $ret +} + +# check if any of the configured interfaces is up +anyvipsup() { + ret=1 + for vip in $CONFIG_VIRTUAL_IPS; do + vipup $vip && return 0 + done + return $ret +} + +start() { + # Check if the service is already running? + if ! vipsup; then + msg_starting "UCARP"; started + for vip in $VIRTUAL_IPS; do + config="/etc/ucarp/$vip.conf" + if [ ! -f "$config" ]; then + nls "Invalid virtual IP \`%s': missing config: %s" $vip "$config" + fail + RET=1 + else + UCARP_OPTS="" + . $config + show "Starting UCARP for virtual IP %s" "$vip" + if vipup $vip; then + started + continue + fi + # Needed for makepid work + RC_LOGGING=no + daemon --makepid --fork --pidfile /var/run/ucarp/$vip.pid \ + /usr/sbin/ucarp --addr=${vip} ${UCARP_OPTS} + RET=$? + fi + [ $RETVAL -eq 0 ] && RETVAL=$RET + done + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ucarp + else + msg_already_running "UCARP" + fi +} + +stop() { + if anyvipsup; then + # Stop daemons. + msg_stopping "UCARP"; started + for vip in $VIRTUAL_IPS; do + pidfile=/var/run/ucarp/$vip.pid + [ -f "$pidfile" ] || continue + pid=`cat "$pidfile"` + show "Stopping UCARP for virtual IP %s" "$vip"; busy + killproc --pidfile "$pidfile" || err=1 + rm -f "$pidfile" >/dev/null 2>&1 + done + anyvipsup || rm -f /var/lock/subsys/ucarp >/dev/null 2>&1 + else + msg_not_running "UCARP" + fi +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + reload|force-reload) + if vipsup; then + msg_reloading "UCARP"; started + for vip in $VIRTUAL_IPS; do + show "Reloading UCARP for virtual IP %s" "$vip" + killproc --pidfile ucarp/$vip.pid ucarp -HUP + [ $? -ne 0 -a $RETVAL -eq 0 ] && RETVAL=7 + done + else + msg_not_running "UCARP" + exit 7 + fi + ;; + restart) + stop + sleep 1 + start + exit $? + ;; + status) + nls "Configured virtual IPs:" + echo " $VIRTUAL_IPS" + nls "Currently active virtual IPs:" + for pidfile in /var/run/ucarp/*.pid; do + [ -f "$pidfile" ] || continue + vip=${pidfile#/var/run/ucarp/} + vip=${vip%.pid} + vipup $vip && echo -n " $vip($(cat $pidfile))" + done + echo "" + vipsup + exit $? + ;; + *) + msg_usage "$0 {start|stop|restart|reload|force-reload|status}" + exit 3 + ;; +esac + +exit $RETVAL ================================================================ Index: packages/ucarp/ucarp.sysconfig diff -u /dev/null packages/ucarp/ucarp.sysconfig:1.1 --- /dev/null Wed Mar 31 00:06:49 2010 +++ packages/ucarp/ucarp.sysconfig Wed Mar 31 00:06:44 2010 @@ -0,0 +1,2 @@ +# list of virtual IPs to manage with UCARP +#VIRTUAL_IPS="10.0.0.12" ================================================================ ---- CVS-web: http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/ucarp/ucarp.spec?r1=1.12&r2=1.13&f=u _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit