Your message dated Sat, 27 May 2023 05:04:07 +0000
with message-id <[email protected]>
and subject line Bug#1036316: Removed package(s) from unstable
has caused the Debian Bug report #226915,
regarding vrrpd : could be usefull to launch commands when switching state
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
226915: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=226915
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: vrrpd
Version: 0.7-2
Severity: normal

having vrrpd launch an external script when switching state (master / slave) would allow administrators of the systems to send alarm in the monitoring or reload services that bind to IP adresses ... whatever.


Attached is a patch (diff -Naur) that will add this feature.
The patch adds also an example script and a startup script that will
make use of this. (beware that all this is tested on RedHat and startup
script might not be *that* usefull on Debian ...)

Pascal Lengard

diff -Naur vrrpd-0.7b-syslog/Changes vrrpd-0.7c-script/Changes
--- vrrpd-0.7b-syslog/Changes   2004-01-09 13:39:46.000000000 +0100
+++ vrrpd-0.7c-script/Changes   2004-01-09 13:47:09.000000000 +0100
@@ -1,3 +1,20 @@
+- Pascal Lengard : Launch an external script on state switch.
+       modified files : vrrpd.c vrrpd.h vrrp_switch /var/lib/vrrpd 
+       doc:
+               vrrpd will launch /etc/vrrpd/vrrp_switch when changing state.
+               this will provide a way to administrators to reload services
+               that depend on the IP address when starting, or do all other
+               nifty tricks I don't even think of now.
+               The script is called with 2 arguments:
+                       $1 -> "master" or "slave" (new state)
+                       $2 -> vrid (so that you might run several vrid on the
+                             same host).
+               /etc/vrrpd/vrrp_switch example in the package maintains a
+               state file that other scripts can read to know the state of
+               the node. /etc/init.d/vrrpd in the package knows how to use
+               this to get a status ...
+
+
 - Pascal Lengard : Make syslog log with LOG_DAEMON and be used for all errors
                    after startup.
                    Can give a name to a VRID to be displayed in the logs, handy
diff -Naur vrrpd-0.7b-syslog/init.d/vrrpd vrrpd-0.7c-script/init.d/vrrpd
--- vrrpd-0.7b-syslog/init.d/vrrpd      1970-01-01 01:00:00.000000000 +0100
+++ vrrpd-0.7c-script/init.d/vrrpd      2004-01-09 11:19:48.000000000 +0100
@@ -0,0 +1,186 @@
+#!/bin/bash
+#
+# vrrpd:       Starts the vrrpd Daemon
+#
+# Version:     @(#)$Id: vrrpd,v 1.4 2003/10/27 16:11:36 plg Exp $
+#
+# chkconfig: 345 89 11 
+# description: This is an implementation of VRRP 2.0 protocol for linux.
+#              - It has been extended to run  /etc/vrrpd/vrrp_switch when 
changing state.
+#                vrrp_switch is called with 2 arguments:
+#                  $1 = slave  when becoming slave
+#                  $1 = master when becoming master
+#                  $2 = VRID concerned
+#
+#                with this you can make it reload daemons and other nifty 
tricks when
+#                the VRRP switch from one host to the other.
+#              - Plus we now log VRRP actions via syslog (daemon facility).
+#
+# processname: vrrpd
+# config: /etc/vrrpd
+
+PATH=/sbin:/bin:/usr/bin:/usr/sbin
+
+# Source function library.
+. /etc/init.d/functions
+
+# Get config.
+test -f /etc/sysconfig/network && . /etc/sysconfig/network
+
+# Check that networking is up.
+[ ${NETWORKING} = "yes" ] || exit 0
+
+[ -f /usr/sbin/vrrpd ] || exit 1
+
+
+#setup VRRP IP address, interface and group here
+export VRRP_IP=10.0.1.100
+export VRRP_IFACE=eth1
+export VRRP_VRID=50
+export VRID_NAME="test"
+
+#where we find state file
+STATEFILEPATH=/var/lib/vrrpd
+
+# Priority is different on all the nodes
+# Setup VRRP priority for all hostnames here and duplicate this
+# vrrp service file on all nodes.
+HOSTNAME=`/bin/hostname --short`
+case "$HOSTNAME" in
+       lnxtest-node1) export VRRP_PRIORITY=90
+               
+               ;;
+       lnxtest-node2) export VRRP_PRIORITY=50
+               ;;
+       *) echo "vrrp: HOSTNAME not found !!"
+          exit 1
+               ;;
+esac
+
+RETVAL=0
+
+#normal "status" function from RedHat doesnt work here
+#it does not support multiple process of same name ...
+vrrpstatus() {
+       local process="vrrpd"
+        local running
+       local pid
+                                                                               
                  
+        # Test syntax.
+        if [ "$#" = 0 ] ; then
+                echo $"Usage: status {iface} {vrid}"
+                return 1
+        fi
+       local iface=$1
+       local vrid=$2
+                                                                               
                  
+        # First get "pidof"
+        running=`pidof -o $$ -o $PPID -o %PPID -x ${process}`
+ 
+        # Next try "/var/run/*.pid" files
+        if [ -f /var/run/${process}_${iface}_${vrid}.pid ] ; then
+                read pid < /var/run/${process}_${iface}_${vrid}.pid
+               
+                if [ -n "$pid" ]; then
+                       if [ `echo $running | grep -c $pid` -eq 0 ]
+                       then
+                               echo $"${process}_${iface}_${vrid} file exists 
but process is dead"
+                               return 1
+                       else
+                               echo $"${process} for ${iface} vrid ${vrid} 
running ($pid)"
+                               return 0
+                       fi
+               else
+                        echo $"${process}_${iface}_${vrid} pid file exists but 
is empty"
+                fi
+        fi
+
+        # See if /var/lock/subsys/${process}_${iface}_${vrid} exists
+        if [ -f /var/lock/subsys/${process}_${iface}_${vrid}.pid ]; then
+                echo $"cannot tell ... but subsys locked"
+                return 2
+        fi
+        echo $"$process for ${iface} vrid ${vrid} is stopped"
+        return 3
+}
+
+
+
+
+start(){
+    echo -n "Starting vrrpd: "
+    /usr/sbin/vrrpd -n -i ${VRRP_IFACE} -v ${VRRP_VRID} -p ${VRRP_PRIORITY} -l 
${VRID_NAME} ${VRRP_IP} &>/dev/null &
+    RETVAL=$?
+    echo
+    touch /var/lock/subsys/vrrpd_${VRRP_IFACE}_${VRRP_VRID}
+    return $RETVAL
+}
+
+stop(){
+    echo -n "Stopping vrrpd: "
+    ps auxwww |  grep vrrpd | awk -v IP=${VRRP_IP} '{ if (index($0,IP)!=0) 
system("kill " $2);}'
+    RETVAL=$?
+    echo
+    rm -f /var/lock/subsys/vrrpd_${VRRP_IFACE}_${VRRP_VRID}
+    return $RETVAL
+
+}
+
+reload(){
+    echo -n "reload not supported. call start/stop but it might make the VRRP 
switch ..."      
+}
+
+restart(){
+    stop
+    start
+}
+
+condrestart(){
+    [ -e /var/lock/subsys/vrrpd_${VRRP_IFACE}_${VRRP_VRID} ] && restart
+    return 0
+}
+
+
+# See how we were called.
+case "$1" in
+    start)
+       start
+       ;;
+    stop)
+       stop
+       ;;
+    status)
+
+       vrrpstatus ${VRRP_IFACE} ${VRRP_VRID}
+       if [ -f "${STATEFILEPATH}/state.${VRRP_VRID}" ]
+       then
+               STATE=`cat "${STATEFILEPATH}/state.${VRRP_VRID}"`
+               echo "cluster state ${STATE}"
+               case "$STATE" in
+                       "master" ) RETVAL=1
+                               ;;
+                       "slave"  ) RETVAL=2
+                               ;;
+                       * )        RETVAL=128
+                               ;;
+               esac
+       else
+               echo "cluster state unknown"
+               RETVAL=0;
+       fi
+       ;;
+    restart)
+       restart
+       ;;
+    reload)
+       reload
+       ;;
+    condrestart)
+       condrestart
+       ;;
+    *)
+       echo "Usage: vrrpd {start|stop|status|restart|condrestart}"
+       RETVAL=1
+esac
+
+exit $RETVAL
diff -Naur vrrpd-0.7b-syslog/vrrpd.c vrrpd-0.7c-script/vrrpd.c
--- vrrpd-0.7b-syslog/vrrpd.c   2004-01-08 22:22:10.000000000 +0100
+++ vrrpd-0.7c-script/vrrpd.c   2004-01-09 13:47:41.000000000 +0100
@@ -12,6 +12,11 @@
  * Contributor: David Hunter, <[email protected]>
  *
  * Changes:
+ *              Pascal Lengard
+ *               <+> Launch a script ( /etc/vrrpd/vrrp_switch )
+ *                   when switching state. script get 2 arguments:
+ *                     $1 = new state (master or slave)
+ *                     $2 = vrid
  *              David Hunter : 2002/02/04 :
  *               <+> Added Monitored Interface functionality using code
  *                   from Donald Becker's <[email protected]> mii-diag.c
@@ -149,6 +154,41 @@
 }
 
 /****************************************************************
+ NAME  : external_script       
+ AIM   : 
+ REMARK        : 
+****************************************************************/
+void external_script(char * state_string, int vrid )
+{
+       char command[EXTERNAL_SCRIPT_MAX];
+       int errorcode=0;
+       int fork_rc;
+
+       fork_rc = fork();       
+       if ( fork_rc == -1 ) {
+               syslog (LOG_ERR,"could not fork to launch vrrp_switch !!!\n");
+       } else if ( fork_rc == 0 ) {
+               // FIXME: will have to watch scheduling and signals that are 
inherited here.
+
+               // restore default since otherwise behaviour is not defined by 
POSIX
+               // (SIGCHLD is set to SIG_IGN in main process)
+               signal( SIGCHLD, SIG_DFL );
+
+               if (snprintf(command, (size_t) EXTERNAL_SCRIPT_MAX,
+               "%s %s %i", EXTERNAL_SCRIPT, state_string, vrid) < 
EXTERNAL_SCRIPT_MAX ) {
+                       errorcode = system(command);
+                       if (errorcode != 0) {
+                               syslog (LOG_ERR,"error: system(%s) returned 
%i\n",
+                               command, errorcode);
+                       }
+               } else {
+                       syslog (LOG_ERR,"internal error , increase 
EXTERNAL_SCRIPT_MAX !!\n");
+               }
+               // child get out of the way asap
+               exit(0);
+       }
+}
+/****************************************************************
  NAME  : get_pid_name        00/10/04 21:06:44
  AIM  : 
  REMARK  :
@@ -1300,6 +1340,7 @@
   vsrv->state = VRRP_STATE_MAST;
   //
   syslog(LOG_NOTICE, "Gone to master...(prio: %d / vrid: %d)", 
vsrv->priority,vsrv->vrid);
+  external_script("master",vsrv->vrid);
 }
 
 /****************************************************************
@@ -1336,6 +1377,7 @@
       send_gratuitous_arp( vsrv, addr[i], 0 );
   }
   syslog(LOG_NOTICE, "Left master...(prio: %d / vrid: %d)", vsrv->priority, 
vsrv->vrid);
+  external_script("slave",vsrv->vrid);
 }
 
 /****************************************************************
@@ -1622,6 +1664,7 @@
   signal( SIGTERM, signal_end );
   signal( SIGUSR1, signal_user );
   signal( SIGUSR2, signal_user );
+  signal( SIGCHLD, SIG_IGN);
 
   /* try to write a pid file */
   if( pidfile_exist( vsrv ) )  return -1;
diff -Naur vrrpd-0.7b-syslog/vrrpd.h vrrpd-0.7c-script/vrrpd.h
--- vrrpd-0.7b-syslog/vrrpd.h   2004-01-08 22:16:13.000000000 +0100
+++ vrrpd-0.7c-script/vrrpd.h   2004-01-08 23:59:35.000000000 +0100
@@ -71,6 +71,8 @@
 #define VRRP_PIDDIR_DFL        "/var/run"              /* dir to store the pid 
file */
 #define VRRP_PID_FORMAT        "vrrpd_%s_%d.pid"       /* pid file format */
 #define VRIDNAME_MAX 20                                /* name for logging */
+#define EXTERNAL_SCRIPT "/etc/vrrpd/vrrp_switch"
+#define EXTERNAL_SCRIPT_MAX 40                 /* size of external script WITH 
ARGS */
 
 typedef struct {       /* parameters per interface -- rfc2338.6.1.1 */
        int             auth_type;      /* authentification type. VRRP_AUTH_* */
diff -Naur vrrpd-0.7b-syslog/vrrp_switch vrrpd-0.7c-script/vrrp_switch
--- vrrpd-0.7b-syslog/vrrp_switch       1970-01-01 01:00:00.000000000 +0100
+++ vrrpd-0.7c-script/vrrp_switch       2004-01-09 11:20:17.000000000 +0100
@@ -0,0 +1,27 @@
+#!/bin/bash
+# @(#)$Id: vrrp_switch,v 1.1 2003/10/03 13:33:23 plg Exp $
+# This script is called when VRRP state switch
+# $1 = master / slave (new state)
+# $2 = VRID concerned
+#
+# you can reload services that need the IP address to be configured
+# when they initialise,  ....
+
+#this will make it possible to test the state with scripts ...
+#just reading the STATEFILE to know.
+STATEFILE="/var/lib/vrrpd/state"
+echo "$1" > "${STATEFILE}.$2"
+
+case "$1" in
+       "master" )
+               echo "VRID $2 is becoming master !"
+               ;;
+       "slave"  )
+               echo "VRID $2 is becoming slave  !"
+               ;;
+       * )
+               echo "Waouh ! did not understand this !!"
+               exit 1
+               ;;
+esac
+exit 0

--- End Message ---
--- Begin Message ---
Version: 1.0-2+rm

Dear submitter,

as the package vrrpd has just been removed from the Debian archive
unstable we hereby close the associated bug reports.  We are sorry
that we couldn't deal with your issue properly.

For details on the removal, please see https://bugs.debian.org/1036316

The version of this package that was in Debian prior to this removal
can still be found using https://snapshot.debian.org/.

Please note that the changes have been done on the master archive and
will not propagate to any mirrors until the next dinstall run at the
earliest.

This message was generated automatically; if you believe that there is
a problem with it please contact the archive administrators by mailing
[email protected].

Debian distribution maintenance software
pp.
Scott Kitterman (the ftpmaster behind the curtain)

--- End Message ---

Reply via email to