More untested eventscript factorisation.
authorMartin Schwenke <martin@meltin.net>
Thu, 19 Nov 2009 04:00:17 +0000 (15:00 +1100)
committerMartin Schwenke <martin@meltin.net>
Thu, 19 Nov 2009 04:00:17 +0000 (15:00 +1100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
16 files changed:
config/events.d/00.ctdb
config/events.d/01.reclock
config/events.d/10.interface
config/events.d/11.natgw
config/events.d/11.routing
config/events.d/20.multipathd
config/events.d/31.clamd
config/events.d/40.vsftpd
config/events.d/41.httpd
config/events.d/60.nfs
config/events.d/61.nfstickle
config/events.d/70.iscsi
config/events.d/91.lvs
config/events.d/99.timeout
config/functions
config/statd-callout

index 90fd92f8b5dac5d3d89de1d827d6d66f0fa3cd93..f2ec5e85b8379f0453bade7c7f09f0d9fc8164b5 100755 (executable)
 #     recovered  : called when ctdb has finished a recovery event
 
 . $CTDB_BASE/functions
-loadconfig ctdb
-
-# ensure we have /bin and /usr/bin in the path
-PATH=/bin:/usr/bin:$PATH
-
-cmd="$1"
-shift
+loadconfig
 
 case $cmd in 
      startup)
index 281c0896b7fcc075c7913113dcf093493de6b345..3d335507ddde76164001d8dc3b87b1c3b0dc73fa 100755 (executable)
@@ -2,55 +2,43 @@
 # script to check accessibility to the reclock file on a node
 
 . $CTDB_BASE/functions
-loadconfig ctdb
-
-cmd="$1"
-shift
-
-PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
-
-# Count the number of intervals that have passed when we have tried to
-# but failed to stat the reclock file.  after third failure the node
-# becomes unhealthy after the twentieth failure the node we shutdown
-# ctdbd
-RECLOCKCOUNT="fail-count"
+loadconfig
 
 case $cmd in 
-     startup)
-       ctdb_counter_init "$RECLOCKCOUNT"
+    startup)
+       ctdb_counter_init
        ;;
-
-      monitor)
-       ctdb_counter_incr "$RECLOCKCOUNT"
-       ctdb_counter_limit "$RECLOCKCOUNT" 200 && {
-               echo "Reclock file \"$RECLOCKFILE\" can not be accessed. Shutting down."
-               df
-               sleep 1
-               ctdb shutdown
+    
+    monitor)
+       ctdb_counter_incr
+       (ctdb_counter_limit 200 >/dev/null 2>&1) || {
+           echo "Reclock file \"$RECLOCKFILE\" can not be accessed. Shutting down."
+           df
+           sleep 1
+           ctdb shutdown
        }
 
-       RECLOCKFILE=`ctdb -Y getreclock`
+       RECLOCKFILE=$(ctdb -Y getreclock)
        [ -z "$RECLOCKFILE" ] && {
-               # we are not using a reclock file
-               ctdb_counter_init "$RECLOCKCOUNT"
-               exit 0
+           # we are not using a reclock file
+           ctdb_counter_init
+           exit 0
        }
 
        # try stat the reclock file as a background process
        # so that we dont block in case the cluster filesystem is unavailable
        (
-               stat $RECLOCKFILE && {
-                       # we could stat the file, reset the counter
-                       ctdb_counter_init "$RECLOCKCOUNT"
-               }
+           stat $RECLOCKFILE && {
+               # we could stat the file, reset the counter
+               ctdb_counter_init
+           }
        ) >/dev/null 2>/dev/null &
 
 
-       ctdb_counter_limit "$RECLOCKCOUNT" 3 && {
-               echo "Reclock file \"$RECLOCKFILE\" can not be accessed. Mark node UNHEALTHY."
-               df
-               exit 1;
-       }
+       ctdb_counter_limit 3
+       ;;
+    status)
+       ctdb_checkstatus || exit $?
        ;;
 esac
 
index 9a02b15fd938fcb5090faf71b2f091d21b985f58..da6d903d53bf65be161a725bf926bfd1f714071f 100755 (executable)
@@ -6,10 +6,7 @@
 # public interface
 
 . $CTDB_BASE/functions
-loadconfig ctdb
-
-cmd="$1"
-shift
+loadconfig
 
 [ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
        CTDB_PUBLIC_ADDRESSES=$CTDB_BASE/public_addresses
@@ -177,10 +174,10 @@ case $cmd in
            esac
        done
        ;;
-
+    status)
+       ctdb_checkstatus || exit $?
+       ;;
 esac
 
 exit 0
 
-
-
index 4ef651dfdcf969bd3a49360f5572578c017a6135..3a350942f9c683fa227ca347109eb79a0d7343c8 100644 (file)
@@ -6,15 +6,10 @@
 #
 
 . $CTDB_BASE/functions
-loadconfig ctdb
+loadconfig
 
 [ -z "$CTDB_NATGW_PUBLIC_IFACE" ] && exit 0
 
-cmd="$1"
-shift
-PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
-
-
 delete_all() {
        remove_ip $CTDB_NATGW_PUBLIC_IP $CTDB_NATGW_PUBLIC_IFACE
        remove_ip $CTDB_NATGW_PUBLIC_IP_HOST lo
@@ -28,7 +23,7 @@ delete_all() {
 }
 
 case $cmd in 
-     startup)
+    startup)
        # do not respond to ARPs that are for ip addresses with scope 'host'
        echo 3 > /proc/sys/net/ipv4/conf/all/arp_ignore
        # do not send out arp requests from loopback addresses
@@ -37,13 +32,13 @@ case $cmd in
        ctdb setnatgwstate on
        ;;
 
-     recovered|updatenatgw)
+    recovered|updatenatgw)
        MYPNN=`ctdb pnn | cut -d: -f2`
        NATGWMASTER=`ctdb natgwlist | head -1 | sed -e "s/ .*//"`
        NATGWIP=`ctdb natgwlist | head -1 | sed -e "s/^[^ ]* *//"`
 
        CTDB_NATGW_PUBLIC_IP_HOST=`echo $CTDB_NATGW_PUBLIC_IP | sed -e "s/\/.*/\/32/"`
-       if [ "$NATGWMASTER" = "-1" ]; then
+       if [ "$NATGWMASTER" == "-1" ]; then
                echo "There is not NATGW master node"
                exit 1
        fi
@@ -71,7 +66,7 @@ case $cmd in
        echo 1 > /proc/sys/net/ipv4/route/flush
        ;;
 
-     shutdown|removenatgw)
+    shutdown|removenatgw)
        delete_all
        ;;
 
index 06741939e53c832b320c81f916c9c8144f12f9ea..cb34e417a8f197fcf1a10893bbbd62b12d8e1169 100755 (executable)
 # bond1 10.3.3.0/24 10.0.0.1
 
 . $CTDB_BASE/functions
-loadconfig ctdb
+loadconfig
 
 [ -f $CTDB_BASE/static-routes ] || {
     exit 0
 }
 
-cmd="$1"
-shift
-PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
-
 case $cmd in 
      takeip|releaseip)
        iface=$1
index c740d69a7a1fa65ee14aac0a8fd757976354b0a0..24f8f7aa9849ae10e420dc0de39c83e159c7fba2 100644 (file)
@@ -6,14 +6,10 @@
 #   CTDB_MONITOR_MPDEVICES="device1 device2 ..."
 #
 
-PATH=/bin:/usr/bin:$PATH
+service_name="multipathd"
 
 . $CTDB_BASE/functions
-loadconfig ctdb
-loadconfig multipathd
-
-cmd="$1"
-shift
+loadconfig 
 
 [ -z "$CTDB_MONITOR_MPDEVICES" ] && {
        exit 0
index 842096a9924f96e3f4b81d6cdd2c7d3396f4b61b..a6515a96d7e4b93bfe626cf101467e1bbd806be5 100644 (file)
@@ -2,52 +2,45 @@
 # event script to manage clamd in a cluster environment
 
 . $CTDB_BASE/functions
-loadconfig ctdb
 
 detect_init_style
 
 case $CTDB_INIT_STYLE in
        redhat)
-               CTDB_SERVICE_CLAMD="clamd"
-               CTDB_CONFIG_CLAMD="clamd"
-               ;;
-       suse)
-               CTDB_SERVICE_CLAMD="clamav"
-               CTDB_CONFIG_CLAMD="clamav"
-               ;;
-       debian)
-               CTDB_SERVICE_CLAMD="clamav"
-               CTDB_CONFIG_CLAMD="clamav"
+               service_name="clamd"
+               service_config="clamd"
                ;;
        *)
-               # should not happen.
-               # for now use red hat style as default
-               CTDB_SERVICE_CLAMD="clamd"
-               CTDB_CONFIG_CLAMD="clamd"
+               service_name="clamav"
+               service_config="clamav"
                ;;
 esac
 
-loadconfig "${CTDB_CONFIG_CLAMD}"
+service_start="service $service_name stop > /dev/null 2>&1 ; service $service_name start"
+service_stop="service $service_name stop"
+
+loadconfig
 
-[ "$CTDB_MANAGES_CLAMD" = "yes" ] || exit 0
+ctdb_start_stop_service
 
-cmd="$1"
-shift
+is_ctdb_managed_service || exit 0
 
 case $cmd in 
      startup)
-        service "${CTDB_SERVICE_CLAMD}" stop > /dev/null 2>&1
-        service "${CTDB_SERVICE_CLAMD}" start
+       ctdb_service_start
         ;;
 
      shutdown)
-        service "${CTDB_SERVICE_CLAMD}" stop
+        ctdb_service_stop
         ;;
 
      monitor)
-        ctdb_check_unix_socket "clamd" ${CTDB_CLAMD_SOCKET}
+        ctdb_check_unix_socket ${CTDB_CLAMD_SOCKET} || exit $?
         ;;
+
+    status)
+       ctdb_checkstatus || exit $?
+       ;;
 esac
 
 exit 0
-
index a87b07b1e663cf44a9005f6c19ec61d9b2925ad4..d231690a2350b4b32a9910c0212c83d436995b71 100755 (executable)
@@ -3,8 +3,8 @@
 
 service_name="vsftpd"
 # make sure the service is stopped first
-service_start="service vsftpd stop > /dev/null 2>&1 ; service vsftpd start"
-service_stop="service vsftpd stop"
+service_start="service $service_name stop > /dev/null 2>&1 ; service $service_name start"
+service_stop="service $service_name stop"
 service_reconfigure="service $service_name restart"
 service_fail_limit=2
 service_tcp_ports=21
@@ -54,6 +54,7 @@ case $cmd in
            fi
        fi      
        ;;
+
     status)
        ctdb_checkstatus || exit $?
        ;;
index 421f42a86526449fde565c614c8f9acf0f52113d..3e43f0f2127c26e10ee74a2827a9452a0cf88a09 100755 (executable)
@@ -35,6 +35,8 @@ loadconfig
 
 ctdb_start_stop_service
 
+is_ctdb_managed_service || exit 0
+
 case $cmd in
     startup)
        ctdb_service_start
@@ -56,6 +58,10 @@ case $cmd in
            exit 1
        fi
        ;;
+
+    status)
+       ctdb_checkstatus || exit $?
+       ;;
 esac
 
 exit 0
index 0d59c7a7004af2283ec3743b7991d06d6b20a259..f6f02e5ceee07aed1e83ec73f312f7990a043acd 100755 (executable)
@@ -1,71 +1,69 @@
 #!/bin/sh
 # script to manage nfs in a clustered environment
 
-. $CTDB_BASE/functions
-loadconfig ctdb
-loadconfig nfs
+start_nfs() {
+       /bin/mkdir -p $CTDB_BASE/state/nfs
+       /bin/mkdir -p $CTDB_BASE/state/statd/ip
+       /bin/mkdir -p $STATD_SHARED_DIRECTORY
+       startstop_nfs stop
+       startstop_nfs start
+}
 
-[ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
-[ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
+reconfigure_nfs() {
+       # always restart the lockmanager so that we start with a clusterwide
+       # graceperiod when ip addresses has changed
+       [ -x $CTDB_BASE/statd-callout ] && {
+               $CTDB_BASE/statd-callout notify &
+       } >/dev/null 2>&1
 
-cmd="$1"
-shift
+}
 
-PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
+. $CTDB_BASE/functions
 
+service_name="nfs"
+service_start="start_nfs"
+service_stop="startstop_nfs stop"
+service_reconfigure="reconfigure_nfs"
 
+loadconfig
+
+[ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
+
+ctdb_start_stop_service
 
 case $cmd in 
      startup)
-       /bin/mkdir -p $CTDB_BASE/state/nfs
-       /bin/mkdir -p $CTDB_BASE/state/statd/ip
-       /bin/mkdir -p $STATD_SHARED_DIRECTORY
-
-       # make sure nfs is stopped before we start it, or it may get a bind error
-       startstop_nfs stop
-       startstop_nfs start
+       ctdb_service_start
        ;;
 
      shutdown)
-       startstop_nfs stop
-       exit 0
+       ctdb_service_stop
        ;;
 
      takeip)
-       ip=$2
-
-       echo $ip >> $CTDB_BASE/state/statd/restart
-
-       # having a list of what IPs we have allows statd to do the right 
-       # thing via $CTDB_BASE/statd-callout
-       touch $CTDB_BASE/state/statd/ip/$ip
-       exit 0
+       ctdb_service_set_reconfigure
+       touch $CTDB_BASE/state/statd/ip/$2
        ;;
 
      releaseip)
-       iface=$1
-       ip=$2
-       maskbits=$3
-
-       echo $ip >> $CTDB_BASE/state/statd/restart
-       /bin/rm -f $CTDB_BASE/state/statd/ip/$ip
-       exit 0
+       ctdb_service_set_reconfigure
+       /bin/rm -f $CTDB_BASE/state/statd/ip/$2
        ;;
 
      recovered)
-       # if no IPs have changed then don't need to restart statd 
-       [ -f $CTDB_BASE/state/statd/restart ] || exit 0;
-
-       # always restart the lockmanager so that we start with a clusterwide
-       # graceperiod when ip addresses has changed
-       [ -x $CTDB_BASE/statd-callout ] && {
-               $CTDB_BASE/statd-callout notify &
-       } >/dev/null 2>&1
-
-       /bin/rm -f $CTDB_BASE/state/statd/restart
+       # if we have taken or released any ips we must 
+       # restart the lock manager so that we enter a clusterwide grace period
+       if ctdb_service_needs_reconfigure ; then
+           ctdb_service_reconfigure
+       fi
        ;;
 
       monitor)
+       if ctdb_service_needs_reconfigure ; then
+           ctdb_service_reconfigure
+           exit 0
+       fi
+
        # check that statd responds to rpc requests
        # if statd is not running we try to restart it
        rpcinfo -u localhost 100024 1 > /dev/null || {
@@ -103,6 +101,9 @@ case $cmd in
        }
                ;;
 
+    status)
+       ctdb_checkstatus || exit $?
+       ;;
 esac
 
 exit 0
index 332d0062db1c2dab49a10323e53c11bcb03291c3..e2bde52da612153b14c00985e7efd7279bb4315c 100755 (executable)
@@ -1,25 +1,21 @@
 #!/bin/sh
 # ctdb event script for NFS tickle acks
 
-PATH=/bin:/usr/bin:$PATH
-
 . $CTDB_BASE/functions
-loadconfig ctdb
-loadconfig nfs
 
-cmd="$1"
-shift
+service_name="nfs"
+service_start="mkdir -p $CTDB_BASE/state/nfstickle;mkdir -p $NFS_TICKLE_SHARED_DIRECTORY/`hostname`;echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle"
+service_reconfigure=$service_start
+
+loadconfig
+
+ctdb_start_stop_service
 
-[ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
 [ -z "$NFS_TICKLE_SHARED_DIRECTORY" ] && exit 0
 
 case $cmd in 
      startup)
-       mkdir -p $CTDB_BASE/state/nfstickle
-       mkdir -p $NFS_TICKLE_SHARED_DIRECTORY/`hostname`
-       # we rely on fast tcp wait1 recycling
-       echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
-       exit 0
+       ctdb_service_start
        ;;
        
      takeip)
@@ -31,46 +27,25 @@ case $cmd in
        # send tickle acks for all the connections the old server had
        for f in $NFS_TICKLE_SHARED_DIRECTORY/*/$ip; do
                [ -f $f ] && cat $f | while read dest; do
-                       dip=`echo $dest | cut -d: -f1`
-                       dport=`echo $dest | cut -d: -f2`
                        # send three, in case of lost packets
-                       echo "Sending NFS tickle ack for $ip to $dip:$dport"
+                       echo "Sending NFS tickle ack for $ip to $dest"
                        for i in `seq 1 3`; do
-                               ctdb tickle $dip:$dport $ip:2049
+                               ctdb tickle $dest $ip:2049
                        done
                done
        done
-       exit 0
-       ;;
-
-     releaseip)
-       exit 0
-       ;;
-
-     recovered)
-       exit 0
-       ;;
-
-     shutdown)
-       exit 0
        ;;
 
      monitor)
-        # always create these direcotries since NFS might be enabled at runtime
-       # and we dont want to restart ctdbd
-       mkdir -p $CTDB_BASE/state/nfstickle
-       mkdir -p $NFS_TICKLE_SHARED_DIRECTORY/`hostname`
-
        mydir=$NFS_TICKLE_SHARED_DIRECTORY/`hostname`
        rm -f $mydir/*
        # record our connections to shared storage
        netstat -tn |egrep '^tcp[[:space:]]+[0-9]+[[:space:]]+[0-9]+[[:space:]]+[0-9\.]+:2049.*ESTABLISHED' |
                awk '{print $4" "$5}' | 
                while read dest src; do
-                       ip=`echo $dest | cut -d: -f1`
+                       ip=${dest%:*}
                        echo $src >> $mydir/$ip
                done
-       exit 0
        ;;
 
 esac
index b32494bc37c0bf4417da371eeff87c971e3487f3..2ab34aca3fa51eb6001bd13d18f1c236ca9e5de1 100755 (executable)
@@ -5,10 +5,7 @@ service_name="iscsi"
 
 . $CTDB_BASE/functions
 
-cmd="$1"
-shift
-
-[ "$CTDB_MANAGES_ISCSI" = "yes" ] || exit 0
+ctdb_start_stop_service
 
 [ -z "$CTDB_START_ISCSI_SCRIPTS" ] && {
        echo "No iscsi start script directory found"
@@ -16,15 +13,6 @@ shift
 }
 
 case $cmd in 
-     startup)
-       ;;
-
-     takeip)
-       ;;
-
-     releaseip)
-       ;;
-
      recovered)
        # block the iscsi port
        iptables -I INPUT 1 -p tcp --dport 3260 -j DROP
@@ -49,8 +37,8 @@ case $cmd in
        done
 
        # remove all iptables rules
-       while `iptables -D INPUT -p tcp --dport 3260 -j DROP 2>/dev/null >/dev/null` ;  do
-               true;
+       while iptables -D INPUT -p tcp --dport 3260 -j DROP 2>/dev/null >/dev/null ;  do
+           :
        done
 
        ;;
@@ -61,9 +49,11 @@ case $cmd in
        ;;
 
      monitor)
-       [ -f $CTDB_BASE/state/iscsi/iscsi_active ] && {
-               ctdb_check_tcp_ports 3260 || exit $?
-       }
+       ctdb_check_tcp_ports 3260 || exit $?
+       ;;
+
+    status)
+       ctdb_checkstatus || exit $?
        ;;
 esac
 
index 6d7891fb58d172affab36a798502c906aa2ef4fc..3bc316fa6814c6b0013a4a60c5caf1c0e106ebff 100755 (executable)
@@ -2,6 +2,7 @@
 # script to manage the lvs ip multiplexer for a single public address cluster
 
 . $CTDB_BASE/functions
+
 loadconfig ctdb
 
 [ -z "$CTDB_LVS_PUBLIC_IP" ] && exit 0
@@ -12,12 +13,6 @@ loadconfig ctdb
     exit 0
 }
 
-
-cmd="$1"
-shift
-
-PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
-
 case $cmd in 
      startup)
        ipvsadm -D -t $CTDB_LVS_PUBLIC_IP:0
@@ -42,12 +37,6 @@ case $cmd in
        echo 1 > /proc/sys/net/ipv4/route/flush
        ;;
 
-     takeip)
-       ;;
-
-     releaseip)
-       ;;
-
      recovered|stopped)
        # kill off any tcp connections
        ipvsadm -D -t $CTDB_LVS_PUBLIC_IP:0
@@ -89,9 +78,6 @@ case $cmd in
        echo 1 > /proc/sys/net/ipv4/route/flush
        ;;
 
-      monitor)
-       ;;
-
 esac
 
 exit 0
index 9ef24e618b5d6f1f7bdb0fd0dd7d9a3a7db45e92..6a5aed05a38a1599619b4e8c9e2e58d3c938e1af 100755 (executable)
@@ -9,15 +9,12 @@ loadconfig ctdb
 
 [ "x$CTDB_RUN_TIMEOUT_MONITOR" = "xyes" ] || exit 0
 
-cmd="$1"
-shift
-
 case $cmd in
-       monitor)
-               TIMEOUT=$(ctdb listvars | grep EventScriptTimeout | awk '{print $3}')
-               echo "sleeping for $((TIMEOUT * 2)) seconds..."
-               sleep $((TIMEOUT * 2))
-               ;;
+    monitor)
+       TIMEOUT=$(ctdb listvars | awk '$1 == "EventScriptTimeout" {print $3}')
+       echo "sleeping for $((TIMEOUT * 2)) seconds..."
+       sleep $((TIMEOUT * 2))
+       ;;
 esac
 
 exit 0
index 2b2f6b32babafdaad25402cedba1783e4f72375d..d68f6073765f35d292421b0495d740fa080f46a6 100644 (file)
@@ -1,15 +1,20 @@
 # utility functions for ctdb event scripts
 
-PATH=/bin:/usr/bin:$PATH
+PATH=/bin:/usr/bin:/usr/sbin:/sbin:$PATH
 
 #######################################
 # pull in a system config file, if any
 loadconfig() {
     name="$1"
 
-    if [ -n "$name" ] ; then
-       loadconfig ctdb
-       loadconfig "${service_config:-${service_name}}"
+    if [ "$name" != "ctdb" ] ; then
+       loadconfig "ctdb"
+    fi
+    if [ -z "$name" ] ; then
+       foo="${service_config:-${service_name}}"
+       if [ -n "$foo" ] ; then
+           loadconfig "$foo"
+       fi
     fi
 
     if [ -f /etc/sysconfig/$name ]; then
@@ -236,7 +241,7 @@ ctdb_check_tcp_ports() {
 
       [ $all_ok -eq 1 ] || {
          echo "ERROR: $service_name tcp port $p is not responding"
-         exit 1
+         return 1
       }
   done
 }
@@ -246,8 +251,7 @@ ctdb_check_tcp_ports() {
 # usage: ctdb_check_unix_socket SERVICE_NAME <socket_path>
 ######################################################
 ctdb_check_unix_socket() {
-  service_name="$1"
-  socket_path="$2"
+  socket_path="$1"
   [ -z "$socket_path" ] && return;
 
   # check availability of netstat first
@@ -273,7 +277,7 @@ ctdb_check_unix_socket() {
 
   [ $all_ok -eq 1 ] || {
     echo "ERROR: $service_name socket $socket_path not found"
-    exit 1
+    return 1
   }
 }
 
@@ -493,15 +497,13 @@ remove_ip() {
 
 ########################################################
 # some simple logic for counting events - per eventscript
-# usage: ctdb_counter_init <tag>
-#        ctdb_counter_incr <tag>
-#        ctdb_counter_limit <tag> <limit>
-#        e.g. <tag> = "fail-count"
-# ctdb_counter_limit succeeds when count >= <limit>
+# usage: ctdb_counter_init
+#        ctdb_counter_incr
+#        ctdb_check_counter_limit <limit>
+# ctdb_check_counter_limit succeeds when count >= <limit>
 ########################################################
 _ctdb_counter_common () {
-    _eventscript="${0##*/}" # basename
-    _counter_file="$ctdb_fail_dir/${service_name:-${_eventscript}}"
+    _counter_file="$ctdb_fail_dir/$service_name"
     mkdir -p "${_counter_file%/*}" # dirname
 }
 ctdb_counter_init () {
@@ -669,5 +671,8 @@ ctdb_service_stop ()
        done
 }
 
+# A reasonable default is the basename of the eventscript.
+service_name="${0##*/}" # basename
+
 ctdb_event="$1" ; shift
 cmd="$ctdb_event"
index a18890bf000e1931007a02977bdba3666f051336..e31530aeda3b066793754981f0b69e119200d7f7 100755 (executable)
@@ -28,7 +28,7 @@ case "$1" in
   add-client)
        # the callout does not tell us to which ip the client connected
        # so we must add it to all the ips that we serve
-        for f in `/bin/ls $CTDB_BASE/state/statd/ip/*`; do
+        for f in $CTDB_BASE/state/statd/ip/*; do
            ip=`basename $f`
            [ -d $STATD_SHARED_DIRECTORY/$ip ] || /bin/mkdir $STATD_SHARED_DIRECTORY/$ip
            touch $STATD_SHARED_DIRECTORY/$ip/$2
@@ -37,7 +37,7 @@ case "$1" in
   del-client)
        # the callout does not tell us to which ip the client connected
        # so we must add it to all the ips that we serve
-        for f in `/bin/ls $CTDB_BASE/state/statd/ip/*`; do
+        for f in $CTDB_BASE/state/statd/ip/*; do
            ip=`basename $f`
            /bin/rm -f $STATD_SHARED_DIRECTORY/$ip/$2
        done