summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2011-08-10 15:15:12 +1000
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2011-08-10 15:15:12 +1000
commit5b4b0a5e8c74607abfd4c584b2299046bbcbf260 (patch)
tree7b577251a681da9c7683b993bd713b345197df75
parente2bb73a8f398973fe3e90a09f87c34e59bff9f9f (diff)
parent3e65cdb565aa6bc8b4379a01d385089452d26a8d (diff)
downloadsamba-5b4b0a5e8c74607abfd4c584b2299046bbcbf260.tar.gz
samba-5b4b0a5e8c74607abfd4c584b2299046bbcbf260.tar.xz
samba-5b4b0a5e8c74607abfd4c584b2299046bbcbf260.zip
Merge remote branch 'martins/eventscripts_relative'
(This used to be ctdb commit cf61c5d1517d3979ce67e7b9bc836d040db8a416)
-rwxr-xr-xctdb/config/ctdb.init8
-rwxr-xr-xctdb/config/events.d/00.ctdb10
-rwxr-xr-xctdb/config/events.d/10.interface20
-rwxr-xr-xctdb/config/events.d/13.per_ip_routing6
-rwxr-xr-x[-rw-r--r--]ctdb/config/events.d/20.multipathd4
-rwxr-xr-xctdb/config/events.d/50.samba10
-rwxr-xr-x[-rw-r--r--]ctdb/config/events.d/60.ganesha4
-rwxr-xr-xctdb/config/events.d/60.nfs6
-rwxr-xr-xctdb/config/functions149
-rwxr-xr-xctdb/config/interface_modify.sh14
-rwxr-xr-xctdb/config/statd-callout16
11 files changed, 102 insertions, 145 deletions
diff --git a/ctdb/config/ctdb.init b/ctdb/config/ctdb.init
index 1dc051c7d3..9e32bac767 100755
--- a/ctdb/config/ctdb.init
+++ b/ctdb/config/ctdb.init
@@ -39,10 +39,6 @@ unset TMPDIR
export CTDB_BASE="/etc/ctdb"
}
-[ -z "$CTDB_VARDIR" ] && {
- export CTDB_VARDIR="/var/ctdb"
-}
-
. $CTDB_BASE/functions
loadconfig network
loadconfig ctdb
@@ -118,7 +114,7 @@ check_tdb () {
#
# Note tdbtool always exits with 0
#
- local OK=`/usr/bin/tdbtool $PDBASE check | grep "Database integrity is OK" | wc -l`
+ local OK=`tdbtool $PDBASE check | grep "Database integrity is OK" | wc -l`
test x"$OK" = x"1" || {
return 1;
}
@@ -126,7 +122,7 @@ check_tdb () {
return 0;
}
- /usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || {
+ tdbdump $PDBASE >/dev/null 2>/dev/null || {
return $?;
}
diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index 4f97185ab0..9df5af447c 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -33,10 +33,10 @@ update_config_from_tdb() {
case "$1" in
init)
# make sure we have a blank state directory for the scripts to work with
- /bin/rm -rf $CTDB_VARDIR/state
- /bin/mkdir -p $CTDB_VARDIR/state || {
+ rm -rf $CTDB_VARDIR/state
+ mkdir -p $CTDB_VARDIR/state || {
ret=$?
- echo "/bin/mkdir -p $CTDB_VARDIR/state - failed - $ret"
+ echo "mkdir -p $CTDB_VARDIR/state - failed - $ret"
exit $ret
}
;;
@@ -67,7 +67,7 @@ case "$1" in
# warn when we get low on memory
[ -z "$CTDB_MONITOR_FREE_MEMORY_WARN" ] || {
- FREE_MEM=`free -m | grep "buffers/cache" | while read A B C D ;do /bin/echo -n $D ; done`
+ FREE_MEM=`free -m | grep "buffers/cache" | while read A B C D ;do echo -n $D ; done`
[ `expr "$FREE_MEM" "<" "$CTDB_MONITOR_FREE_MEMORY_WARN"` != "0" ] && {
echo "Running low on memory. Free:$FREE_MEM while CTDB treshold is $CTDB_MONITOR_FREE_MEMORY_WARN"
}
@@ -75,7 +75,7 @@ case "$1" in
# monitor that we are not running out of memory
[ -z "$CTDB_MONITOR_FREE_MEMORY" ] || {
- FREE_MEM=`free -m | grep "buffers/cache" | while read A B C D ;do /bin/echo -n $D ; done`
+ FREE_MEM=`free -m | grep "buffers/cache" | while read A B C D ;do echo -n $D ; done`
[ `expr "$FREE_MEM" "<" "$CTDB_MONITOR_FREE_MEMORY"` != "0" ] && {
echo "OOM. Free:$FREE_MEM while CTDB treshold is $CTDB_MONITOR_FREE_MEMORY"
cat /proc/meminfo
diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface
index ecaa323c5e..7f79a08949 100755
--- a/ctdb/config/events.d/10.interface
+++ b/ctdb/config/events.d/10.interface
@@ -46,21 +46,21 @@ monitor_interfaces()
# When we use VLANs for bond interfaces, there will only
# be an entry in /proc for the underlying real interface
local REALIFACE=`echo $IFACE |sed -e 's/\..*$//'`
- [ -f /proc/net/bonding/$REALIFACE ] && {
- grep -q 'Currently Active Slave: None' /proc/net/bonding/$REALIFACE && {
+ bi=$(get_proc "net/bonding/$REALIFACE") 2>/dev/null && {
+ echo "$bi" | grep -q 'Currently Active Slave: None' && {
echo "ERROR: No active slaves for bond device $REALIFACE"
fail=1
ctdb setifacelink $IFACE down >/dev/null 2>/dev/null
continue;
}
- grep -q '^MII Status: up' /proc/net/bonding/$REALIFACE || {
+ echo "$bi" | grep -q '^MII Status: up' || {
echo "ERROR: public network interface $REALIFACE is down"
fail=1
ctdb setifacelink $IFACE down >/dev/null 2>/dev/null
continue;
}
- grep -q '^Bonding Mode: IEEE 802.3ad Dynamic link aggregation' /proc/net/bonding/$REALIFACE && {
- grep 'MII Status:' /proc/net/bonding/$REALIFACE | tail -n +2 | grep -q '^MII Status: up' || {
+ echo "$bi" | grep -q '^Bonding Mode: IEEE 802.3ad Dynamic link aggregation' && {
+ echo "$bi" | grep 'MII Status:' | tail -n +2 | grep -q '^MII Status: up' || {
echo No active slaves for 802.ad bond device $REALIFACE
ctdb setifacelink $IFACE down >/dev/null 2>/dev/null
fail=1
@@ -124,8 +124,8 @@ case "$1" in
init)
# make sure that we only respond to ARP messages from the NIC where
# a particular ip address is associated.
- [ -f /proc/sys/net/ipv4/conf/all/arp_filter ] && {
- echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter
+ get_proc sys/net/ipv4/conf/all/arp_filter >/dev/null 2>&1 && {
+ set_proc sys/net/ipv4/conf/all/arp_filter 1
}
;;
@@ -164,7 +164,7 @@ case "$1" in
iptables -D INPUT -i $iface -d $ip -j DROP 2> /dev/null
# flush our route cache
- echo 1 > /proc/sys/net/ipv4/route/flush
+ set_proc sys/net/ipv4/route/flush 1
;;
@@ -204,7 +204,7 @@ case "$1" in
iptables -D INPUT -i $iface -d $ip -j DROP 2> /dev/null
# flush our route cache
- echo 1 > /proc/sys/net/ipv4/route/flush
+ set_proc sys/net/ipv4/route/flush 1
;;
##################################################
@@ -248,7 +248,7 @@ case "$1" in
iptables -D INPUT -i $oiface -d $ip -j DROP 2> /dev/null
# flush our route cache
- echo 1 > /proc/sys/net/ipv4/route/flush
+ set_proc sys/net/ipv4/route/flush 1
# propagate the new mac address
ctdb gratiousarp $ip $niface
diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing
index c734bbc6e1..a0df119895 100755
--- a/ctdb/config/events.d/13.per_ip_routing
+++ b/ctdb/config/events.d/13.per_ip_routing
@@ -75,14 +75,14 @@ lock_file() {
stat -c%y "$lckf"
return 1
}
- /bin/kill -0 $pid && {
+ kill -0 $pid && {
lock_debug "lock file $lckf is valid for process $pid"
stat -c%y "$lckf"
return 1
}
lock_debug "stale lock file $lckf for $machine:$pid"
cat "$lckf"
- /bin/rm -f "$lckf"
+ rm -f "$lckf"
fi
echo "$host:$$" > "$lckf"
return 0
@@ -99,7 +99,7 @@ unlock_file() {
lock_debug "lock nesting now $locknesting"
else
lckf="$lock_root/$1"
- /bin/rm -f "$lckf"
+ rm -f "$lckf"
fi
}
diff --git a/ctdb/config/events.d/20.multipathd b/ctdb/config/events.d/20.multipathd
index 2f484a4760..73b6054f44 100644..100755
--- a/ctdb/config/events.d/20.multipathd
+++ b/ctdb/config/events.d/20.multipathd
@@ -49,7 +49,7 @@ multipathd_check()
timeleft=$(($timeleft - 1))
# see if the process still exists
- /bin/kill -0 $pid > /dev/null 2>&1 || {
+ kill -0 $pid > /dev/null 2>&1 || {
# it doesn't exist, grab its exit status
wait $pid
[ $? = 0 ] || {
@@ -78,7 +78,7 @@ case "$1" in
startup)
# create a state directory to keep/track the multipath device
# state
- /bin/mkdir -p $CTDB_VARDIR/state/multipathd
+ mkdir -p $CTDB_VARDIR/state/multipathd
exit 0
;;
diff --git a/ctdb/config/events.d/50.samba b/ctdb/config/events.d/50.samba
index 7a152b5eba..3e90742724 100755
--- a/ctdb/config/events.d/50.samba
+++ b/ctdb/config/events.d/50.samba
@@ -32,7 +32,7 @@ loadconfig
start_samba() {
# create the state directory for samba
- /bin/mkdir -p $CTDB_VARDIR/state/samba
+ mkdir -p $CTDB_VARDIR/state/samba
# make sure samba is not already started
[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
@@ -76,7 +76,7 @@ start_samba() {
# the number of smbd processes will mean that it leaves few cycles for
# anything else
[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
- /usr/bin/net serverid wipe
+ net serverid wipe
nice_service "$CTDB_SERVICE_NMB" start || {
echo failed to start nmbd
@@ -141,7 +141,7 @@ testparm_background_update() {
while [ $timeleft -gt 0 ]; do
timeleft=$(($timeleft - 1))
# see if the process still exists
- /bin/kill -0 $pid > /dev/null 2>&1 || {
+ kill -0 $pid > /dev/null 2>&1 || {
# it doesn't exist, grab its exit status
wait $pid
[ $? = 0 ] || {
@@ -167,7 +167,7 @@ testparm_background_update() {
done
# it took more than 10 seconds - kill it off
rm -f "${tmpfile}"
- /bin/kill -9 "$pid" > /dev/null 2>&1
+ kill -9 "$pid" > /dev/null 2>&1
echo "50.samba: timed out updating smbconf cache in background"
exit 1
) &
@@ -241,7 +241,7 @@ case "$1" in
[ -f $CTDB_VARDIR/state/samba/periodic_cleanup ] || {
touch $CTDB_VARDIR/state/samba/periodic_cleanup
}
- [ `/usr/bin/find $CTDB_VARDIR/state/samba/periodic_cleanup -mmin +$SAMBA_CLEANUP_PERIOD | wc -l` -eq 1 ] && {
+ [ `find $CTDB_VARDIR/state/samba/periodic_cleanup -mmin +$SAMBA_CLEANUP_PERIOD | wc -l` -eq 1 ] && {
# Cleanup the databases
periodic_cleanup
touch $CTDB_VARDIR/state/samba/periodic_cleanup
diff --git a/ctdb/config/events.d/60.ganesha b/ctdb/config/events.d/60.ganesha
index 6559dd0727..fb3b7c2e7b 100644..100755
--- a/ctdb/config/events.d/60.ganesha
+++ b/ctdb/config/events.d/60.ganesha
@@ -2,8 +2,8 @@
# script to manage nfs in a clustered environment
start_nfs() {
- /bin/mkdir -p $CTDB_VARDIR/state/nfs
- /bin/mkdir -p $CTDB_VARDIR/state/statd/ip
+ mkdir -p $CTDB_VARDIR/state/nfs
+ mkdir -p $CTDB_VARDIR/state/statd/ip
ctdb_service_stop
ctdb_service_start
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs
index 0cea531fa1..6736a9c8c0 100755
--- a/ctdb/config/events.d/60.nfs
+++ b/ctdb/config/events.d/60.nfs
@@ -2,11 +2,11 @@
# script to manage nfs in a clustered environment
start_nfs() {
- /bin/mkdir -p $CTDB_VARDIR/state/nfs
- /bin/mkdir -p $CTDB_VARDIR/state/statd/ip
+ mkdir -p $CTDB_VARDIR/state/nfs
+ mkdir -p $CTDB_VARDIR/state/statd/ip
startstop_nfs stop
startstop_nfs start
- echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
+ set_proc "sys/net/ipv4/tcp_tw_recycle" 1
}
. $CTDB_BASE/functions
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 6c44fb8d87..02c111ad43 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -1,7 +1,16 @@
+# Hey Emacs, this is a -*- shell-script -*- !!!
+
# utility functions for ctdb event scripts
PATH=/bin:/usr/bin:/usr/sbin:/sbin:$PATH
+[ -z "$CTDB_VARDIR" ] && {
+ export CTDB_VARDIR="/var/ctdb"
+}
+[ -z "$CTDB_ETCDIR" ] && {
+ export CTDB_ETCDIR="/etc"
+}
+
#######################################
# pull in a system config file, if any
_loadconfig() {
@@ -15,11 +24,10 @@ _loadconfig() {
loadconfig "ctdb"
fi
-
- if [ -f /etc/sysconfig/$1 ]; then
- . /etc/sysconfig/$1
- elif [ -f /etc/default/$1 ]; then
- . /etc/default/$1
+ if [ -f $CTDB_ETCDIR/sysconfig/$1 ]; then
+ . $CTDB_ETCDIR/sysconfig/$1
+ elif [ -f $CTDB_ETCDIR/default/$1 ]; then
+ . $CTDB_ETCDIR/default/$1
elif [ -f $CTDB_BASE/sysconfig/$1 ]; then
. $CTDB_BASE/sysconfig/$1
fi
@@ -46,7 +54,10 @@ detect_init_style() {
######################################################
# simulate /sbin/service on platforms that don't have it
-service() {
+# _service() makes it easier to hook the service() function for
+# testing.
+_service ()
+{
_service_name="$1"
_op="$2"
@@ -54,91 +65,46 @@ service() {
[ -z "$_service_name" ] && return
if [ -x /sbin/service ]; then
- /sbin/service "$_service_name" "$_op"
- elif [ -x /etc/init.d/$_service_name ]; then
- /etc/init.d/$_service_name "$_op"
- elif [ -x /etc/rc.d/init.d/$_service_name ]; then
- /etc/rc.d/init.d/$_service_name "$_op"
+ $_nice /sbin/service "$_service_name" "$_op"
+ elif [ -x $CTDB_ETCDIR/init.d/$_service_name ]; then
+ $_nice $CTDB_ETCDIR/init.d/$_service_name "$_op"
+ elif [ -x $CTDB_ETCDIR/rc.d/init.d/$_service_name ]; then
+ $_nice $CTDB_ETCDIR/rc.d/init.d/$_service_name "$_op"
fi
}
+service()
+{
+ _nice=""
+ _service "$@"
+}
+
######################################################
# simulate /sbin/service (niced) on platforms that don't have it
-nice_service() {
- _service_name="$1"
- _op="$2"
-
- # do nothing, when no service was specified
- [ -z "$_service_name" ] && return
-
- if [ -x /sbin/service ]; then
- nice /sbin/service "$_service_name" "$_op"
- elif [ -x /etc/init.d/$_service_name ]; then
- nice /etc/init.d/$_service_name "$_op"
- elif [ -x /etc/rc.d/init.d/$_service_name ]; then
- nice /etc/rc.d/init.d/$_service_name "$_op"
- fi
+nice_service()
+{
+ _nice="nice"
+ _service "$@"
}
######################################################
-# wait for a command to return a zero exit status
-# usage: ctdb_wait_command SERVICE_NAME <command>
-######################################################
-ctdb_wait_command() {
- service_name="$1"
- wait_cmd="$2"
- [ -z "$wait_cmd" ] && return;
- all_ok=0
- echo "Waiting for service $service_name to start"
- while [ $all_ok -eq 0 ]; do
- $wait_cmd > /dev/null 2>&1 && all_ok=1
- ctdb status > /dev/null 2>&1 || {
- echo "ctdb daemon has died. Exiting wait for $service_name"
- exit 1
- }
- [ $all_ok -eq 1 ] || sleep 1
- done
- echo "Local service $service_name is up"
+# wrapper around /proc/ settings to allow them to be hooked
+# for testing
+# 1st arg is relative path under /proc/, 2nd arg is value to set
+set_proc ()
+{
+ echo "$2" >"/proc/$1"
}
-
######################################################
-# wait for a set of tcp ports
-# usage: ctdb_wait_tcp_ports SERVICE_NAME <ports...>
-######################################################
-ctdb_wait_tcp_ports() {
- service_name="$1"
- shift
- wait_ports="$*"
- [ -z "$wait_ports" ] && return;
- all_ok=0
- echo "Waiting for tcp service $service_name to start"
- while [ $all_ok -eq 0 ]; do
- all_ok=1
- for p in $wait_ports; do
- if [ -x /usr/bin/netcat ]; then
- /usr/bin/netcat -z 127.0.0.1 $p > /dev/null || all_ok=0
- elif [ -x /usr/bin/nc ]; then
- /usr/bin/nc -z 127.0.0.1 $p > /dev/null || all_ok=0
- elif [ -x /usr/bin/netstat ]; then
- (netstat -a -n | egrep "0.0.0.0:$p[[:space:]]*LISTEN" > /dev/null) || all_ok=0
- elif [ -x /bin/netstat ]; then
- (netstat -a -n | egrep "0.0.0.0:$p[[:space:]]*LISTEN" > /dev/null) || all_ok=0
- else
- echo "No tool to check tcp ports availabe. can not check in ctdb_wait_tcp_ports"
- return 127
- fi
- done
- [ $all_ok -eq 1 ] || sleep 1
- ctdb status > /dev/null 2>&1 || {
- echo "ctdb daemon has died. Exiting tcp wait $service_name"
- return 1
- }
- done
- echo "Local tcp services for $service_name are up"
+# wrapper around getting file contents from /proc/ to allow
+# this to be hooked for testing
+# 1st arg is relative path under /proc/
+get_proc ()
+{
+ cat "/proc/$1"
}
-
######################################################
# check that a rpc server is registered with portmap
# and responding to requests
@@ -260,7 +226,7 @@ kill_tcp_connections() {
esac
_killcount=`expr $_killcount + 1`
done < $connfile
- /bin/rm -f $connfile
+ rm -f $connfile
[ $_failed = 0 ] || {
echo "Failed to send killtcp control"
@@ -302,7 +268,7 @@ kill_tcp_connections_local_only() {
ctdb killtcp $srcip:$srcport $destip:$destport >/dev/null 2>&1 || _failed=1
_killcount=`expr $_killcount + 1`
done < $connfile
- /bin/rm -f $connfile
+ rm -f $connfile
[ $_failed = 0 ] || {
echo "Failed to send killtcp control"
@@ -345,7 +311,7 @@ tickle_tcp_connections() {
echo "Tickle TCP connection $destip:$destport $srcip:$srcport"
ctdb tickle $destip:$destport $srcip:$srcport >/dev/null 2>&1 || _failed=1
done < $connfile
- /bin/rm -f $connfile
+ rm -f $connfile
[ $_failed = 0 ] || {
echo "Failed to send tickle control"
@@ -358,10 +324,10 @@ tickle_tcp_connections() {
########################################################
startstop_nfs() {
PLATFORM="unknown"
- [ -x /etc/init.d/nfsserver ] && {
+ [ -x $CTDB_ETCDIR/init.d/nfsserver ] && {
PLATFORM="sles"
}
- [ -x /etc/init.d/nfslock ] && {
+ [ -x $CTDB_ETCDIR/init.d/nfslock ] && {
PLATFORM="rhel"
}
@@ -375,7 +341,7 @@ startstop_nfs() {
service nfsserver stop > /dev/null 2>&1
;;
restart)
- echo 0 >/proc/fs/nfsd/threads
+ set_proc "fs/nfsd/threads" 0
service nfsserver stop > /dev/null 2>&1
pkill -9 nfsd
service nfsserver start
@@ -393,7 +359,7 @@ startstop_nfs() {
service nfslock stop > /dev/null 2>&1
;;
restart)
- echo 0 >/proc/fs/nfsd/threads
+ set_proc "fs/nfsd/threads" 0
service nfs stop > /dev/null 2>&1
service nfslock stop > /dev/null 2>&1
pkill -9 nfsd
@@ -414,10 +380,10 @@ startstop_nfs() {
########################################################
startstop_nfslock() {
PLATFORM="unknown"
- [ -x /etc/init.d/nfsserver ] && {
+ [ -x $CTDB_ETCDIR/init.d/nfsserver ] && {
PLATFORM="sles"
}
- [ -x /etc/init.d/nfslock ] && {
+ [ -x $CTDB_ETCDIR/init.d/nfslock ] && {
PLATFORM="rhel"
}
@@ -593,10 +559,9 @@ ctdb_check_counter_equal () {
########################################################
-ctdb_spool_dir="/var/spool/ctdb"
-ctdb_status_dir="$ctdb_spool_dir/status"
-ctdb_fail_dir="$ctdb_spool_dir/failcount"
-ctdb_active_dir="$ctdb_spool_dir/active"
+ctdb_status_dir="$CTDB_VARDIR/status"
+ctdb_fail_dir="$CTDB_VARDIR/failcount"
+ctdb_active_dir="$CTDB_VARDIR/active"
log_status_cat ()
{
@@ -814,7 +779,7 @@ ipv4_is_valid_addr()
# iptables doesn't like being re-entered, so flock-wrap it.
iptables()
{
- flock -w 30 /var/ctdb/iptables-ctdb.flock /sbin/iptables "$@"
+ flock -w 30 $CTDB_VARDIR/iptables-ctdb.flock /sbin/iptables "$@"
}
########################################################
diff --git a/ctdb/config/interface_modify.sh b/ctdb/config/interface_modify.sh
index 27e06ea673..041637650f 100755
--- a/ctdb/config/interface_modify.sh
+++ b/ctdb/config/interface_modify.sh
@@ -17,11 +17,11 @@ add_ip_to_iface()
local _script_dir="$_readd_base/$_ip.$_maskbits"
# we make sure the interface is up first
- /sbin/ip link set $_iface up || {
+ ip link set $_iface up || {
echo "Failed to bringup interface $_iface"
return 1;
}
- /sbin/ip addr add $_ip/$_maskbits brd + dev $_iface || {
+ ip addr add $_ip/$_maskbits brd + dev $_iface || {
echo "Failed to add $_ip/$_maskbits on dev $_iface"
return 1;
}
@@ -48,19 +48,19 @@ delete_ip_from_iface()
# this _very_ annoying behaviour we have to keep a record of the secondaries and re-add
# them afterwards. yuck
local _secondaries=""
- if /sbin/ip addr list dev $_iface primary | grep -q "inet $_ip/$_maskbits " ; then
- _secondaries=`/sbin/ip addr list dev $_iface secondary | grep " inet " | awk '{print $2}'`
+ if ip addr list dev $_iface primary | grep -q "inet $_ip/$_maskbits " ; then
+ _secondaries=`ip addr list dev $_iface secondary | grep " inet " | awk '{print $2}'`
fi
local _failed=0
- /sbin/ip addr del $_ip/$_maskbits dev $_iface || _failed=1
+ ip addr del $_ip/$_maskbits dev $_iface || _failed=1
[ -z "$_secondaries" ] || {
local _i=""
for _i in $_secondaries; do
- if /sbin/ip addr list dev $_iface | grep -q "inet $_i" ; then
+ if ip addr list dev $_iface | grep -q "inet $_i" ; then
echo "kept secondary $_i on dev $_iface"
else
echo "re-adding secondary address $_i to dev $_iface"
- /sbin/ip addr add $_i brd + dev $_iface || _failed=1
+ ip addr add $_i brd + dev $_iface || _failed=1
fi
local _s_ip=`echo "$_i" | cut -d '/' -f1`
local _s_maskbits=`echo "$_i" | cut -d '/' -f2`
diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout
index 39be9d3d4a..3078ef2fed 100755
--- a/ctdb/config/statd-callout
+++ b/ctdb/config/statd-callout
@@ -9,10 +9,6 @@
export CTDB_BASE="/etc/ctdb"
}
-[ -z "$CTDB_VARDIR" ] && {
- export CTDB_VARDIR="/var/ctdb"
-}
-
. $CTDB_BASE/functions
loadconfig ctdb
loadconfig nfs
@@ -34,7 +30,7 @@ case "$1" in
continue
}
IP=`echo $LINE | cut -f2 -d:`
- /bin/mkdir -p $CTDB_VARDIR/state/statd/ip/$IP
+ mkdir -p $CTDB_VARDIR/state/statd/ip/$IP
touch $CTDB_VARDIR/state/statd/ip/$IP/$2
done
;;
@@ -50,7 +46,7 @@ case "$1" in
}
IP=`echo $LINE | cut -f2 -d:`
mkdir -p $CTDB_VARDIR/state/statd/ip/$IP
- /bin/rm -f $CTDB_VARDIR/state/statd/ip/$IP/$2
+ rm -f $CTDB_VARDIR/state/statd/ip/$IP/$2
done
;;
updatelocal)
@@ -187,11 +183,11 @@ case "$1" in
ls $CTDB_VARDIR/state/statd/ip/$IP | while read CLIENT; do
rm $CTDB_VARDIR/state/statd/ip/$IP/$CLIENT
- /usr/bin/smnotify --client=$CLIENT --ip=$IP --server=$ip --stateval=$STATE
- /usr/bin/smnotify --client=$CLIENT --ip=$IP --server=$NFS_HOSTNAME --stateval=$STATE
+ smnotify --client=$CLIENT --ip=$IP --server=$ip --stateval=$STATE
+ smnotify --client=$CLIENT --ip=$IP --server=$NFS_HOSTNAME --stateval=$STATE
STATE=`expr "$STATE" "+" "1"`
- /usr/bin/smnotify --client=$CLIENT --ip=$IP --server=$ip --stateval=$STATE
- /usr/bin/smnotify --client=$CLIENT --ip=$IP --server=$NFS_HOSTNAME --stateval=$STATE
+ smnotify --client=$CLIENT --ip=$IP --server=$ip --stateval=$STATE
+ smnotify --client=$CLIENT --ip=$IP --server=$NFS_HOSTNAME --stateval=$STATE
done
done
;;