diff --git a/ctdb/config/ctdb.init b/ctdb/config/ctdb.init index fc66ab2fbd3..25e158fcc53 100755 --- a/ctdb/config/ctdb.init +++ b/ctdb/config/ctdb.init @@ -39,6 +39,10 @@ unset TMPDIR export CTDB_BASE="/etc/ctdb" } +[ -z "$CTDB_VARDIR" ] && { + export CTDB_VARDIR="/var/ctdb" +} + . $CTDB_BASE/functions loadconfig network loadconfig ctdb diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb index 7e9e3869dfd..8ff6488e5f9 100755 --- a/ctdb/config/events.d/00.ctdb +++ b/ctdb/config/events.d/00.ctdb @@ -15,10 +15,10 @@ loadconfig case "$1" in init) # make sure we have a blank state directory for the scripts to work with - /bin/rm -rf $CTDB_BASE/state - /bin/mkdir -p $CTDB_BASE/state || { + /bin/rm -rf $CTDB_VARDIR/state + /bin/mkdir -p $CTDB_VARDIR/state || { ret=$? - echo "/bin/mkdir -p $CTDB_BASE/state - failed - $ret" + echo "/bin/mkdir -p $CTDB_VARDIR/state - failed - $ret" exit $ret } ;; @@ -37,15 +37,15 @@ case "$1" in startup) # Pull optional ctdb configuration data out of config.tdb PUBLICADDRESSESKEY='public-addresses:node#'`ctdb -t 1 xpnn|sed -e "s/.*://"` - rm -f $CTDB_BASE/state/public_addresses - ctdb pfetch config.tdb $PUBLICADDRESSESKEY $CTDB_BASE/state/public_addresses + rm -f $CTDB_VARDIR/state/public_addresses + ctdb pfetch config.tdb $PUBLICADDRESSESKEY $CTDB_VARDIR/state/public_addresses [ "$?" = "0" ] && [ `stat --format="%s" /etc/ctdb/state/public_addresses` != "0" ] && [ ! -z "$CTDB_PUBLIC_ADDRESSES" ] && { - diff $CTDB_BASE/state/public_addresses $CTDB_PUBLIC_ADDRESSES >/dev/null 2>/dev/null + diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES >/dev/null 2>/dev/null [ $? = "0" ] || { echo CTDB public address configuration had been updated. echo Extracting new configuration from database. - diff $CTDB_BASE/state/public_addresses $CTDB_PUBLIC_ADDRESSES - cp $CTDB_BASE/state/public_addresses $CTDB_PUBLIC_ADDRESSES + diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES + cp $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES echo Restarting CTDB service ctdb restart & } diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing index 6b51b05662b..c734bbc6e12 100755 --- a/ctdb/config/events.d/13.per_ip_routing +++ b/ctdb/config/events.d/13.per_ip_routing @@ -4,7 +4,7 @@ loadconfig [ -z "$CTDB_PER_IP_ROUTING_STATE" ] && { - CTDB_PER_IP_ROUTING_STATE="$CTDB_BASE/state/per_ip_routing" + CTDB_PER_IP_ROUTING_STATE="$CTDB_VARDIR/state/per_ip_routing" } AUTO_LINK_LOCAL="no" diff --git a/ctdb/config/events.d/20.multipathd b/ctdb/config/events.d/20.multipathd index 091a7739b69..2f484a47609 100644 --- a/ctdb/config/events.d/20.multipathd +++ b/ctdb/config/events.d/20.multipathd @@ -16,7 +16,7 @@ loadconfig exit 0 } -MPFAILURE=$CTDB_BASE/state/multipathd/failure +MPFAILURE=$CTDB_VARDIR/state/multipathd/failure multipathd_check_background() { @@ -78,7 +78,7 @@ case "$1" in startup) # create a state directory to keep/track the multipath device # state - /bin/mkdir -p $CTDB_BASE/state/multipathd + /bin/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 23dd060682a..047f9e0bb44 100755 --- a/ctdb/config/events.d/50.samba +++ b/ctdb/config/events.d/50.samba @@ -34,7 +34,7 @@ loadconfig start_samba() { # create the state directory for samba - /bin/mkdir -p $CTDB_BASE/state/samba + /bin/mkdir -p $CTDB_VARDIR/state/samba # make sure samba is not already started [ "$CTDB_MANAGES_SAMBA" = "yes" ] && { @@ -101,13 +101,13 @@ stop_samba() { } # we keep a cached copy of smb.conf here -smbconf_cache="$CTDB_BASE/state/samba/smb.conf.cache" +smbconf_cache="$CTDB_VARDIR/state/samba/smb.conf.cache" ############################################# # update the smb.conf cache in the foreground testparm_foreground_update() { - mkdir -p "$CTDB_BASE/state/samba" || exit 1 + mkdir -p "$CTDB_VARDIR/state/samba" || exit 1 testparm -s 2> /dev/null | egrep -v 'registry.shares.=|include.=' > "$smbconf_cache" } @@ -215,13 +215,13 @@ case "$1" in monitor) # Create a dummy file to track when we need to do periodic cleanup # of samba databases - [ -f $CTDB_BASE/state/samba/periodic_cleanup ] || { - touch $CTDB_BASE/state/samba/periodic_cleanup + [ -f $CTDB_VARDIR/state/samba/periodic_cleanup ] || { + touch $CTDB_VARDIR/state/samba/periodic_cleanup } - [ `/usr/bin/find $CTDB_BASE/state/samba/periodic_cleanup -mmin +$SAMBA_CLEANUP_PERIOD | wc -l` -eq 1 ] && { + [ `/usr/bin/find $CTDB_VARDIR/state/samba/periodic_cleanup -mmin +$SAMBA_CLEANUP_PERIOD | wc -l` -eq 1 ] && { # Cleanup the databases periodic_cleanup - touch $CTDB_BASE/state/samba/periodic_cleanup + touch $CTDB_VARDIR/state/samba/periodic_cleanup } [ "$CTDB_MANAGES_SAMBA" = "yes" ] && { diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs index 35f96c261fb..60de41e51a1 100755 --- a/ctdb/config/events.d/60.nfs +++ b/ctdb/config/events.d/60.nfs @@ -2,8 +2,8 @@ # script to manage nfs in a clustered environment start_nfs() { - /bin/mkdir -p $CTDB_BASE/state/nfs - /bin/mkdir -p $CTDB_BASE/state/statd/ip + /bin/mkdir -p $CTDB_VARDIR/state/nfs + /bin/mkdir -p $CTDB_VARDIR/state/statd/ip startstop_nfs stop startstop_nfs start echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle @@ -25,7 +25,7 @@ case "$1" in ;; startup) ctdb_service_start - touch $CTDB_BASE/state/statd/update-trigger + touch $CTDB_VARDIR/state/statd/update-trigger ;; shutdown) @@ -103,11 +103,11 @@ case "$1" in # once every 60 seconds, update the statd state database for which # clients need notifications - LAST_UPDATE=`stat --printf="%Y" $CTDB_BASE/state/statd/update-trigger` + LAST_UPDATE=`stat --printf="%Y" $CTDB_VARDIR/state/statd/update-trigger` CURRENT_TIME=`date +"%s"` expr "$CURRENT_TIME" ">" "(" "$LAST_UPDATE" "+" "60" ")" >/dev/null 2>/dev/null [ $? = "0" ] && { - touch $CTDB_BASE/state/statd/update-trigger + touch $CTDB_VARDIR/state/statd/update-trigger $CTDB_BASE/statd-callout updatelocal & $CTDB_BASE/statd-callout updateremote & } diff --git a/ctdb/config/events.d/62.cnfs b/ctdb/config/events.d/62.cnfs index 25776758fc2..e0af722f4e6 100755 --- a/ctdb/config/events.d/62.cnfs +++ b/ctdb/config/events.d/62.cnfs @@ -5,7 +5,7 @@ loadconfig -STATEDIR=$CTDB_BASE/state/gpfs +STATEDIR=$CTDB_VARDIR/state/gpfs # filesystems needed by nfs diff --git a/ctdb/config/events.d/README b/ctdb/config/events.d/README index ef345b58a87..c05a1fdd5eb 100644 --- a/ctdb/config/events.d/README +++ b/ctdb/config/events.d/README @@ -29,7 +29,7 @@ init and prepare the basic setup. At this stage 'ctdb' commands won't work. - Example: 00.ctdb cleans up $CTDB_BASE/state + Example: 00.ctdb cleans up $CTDB_VARDIR/state setup This event does not take any additional arguments. @@ -37,7 +37,7 @@ setup This event is used to do some cleanup work from earlier runs and prepare the basic setup. - Example: 00.ctdb cleans up $CTDB_BASE/state + Example: 00.ctdb cleans up $CTDB_VARDIR/state startup This event does not take any additional arguments. diff --git a/ctdb/config/functions b/ctdb/config/functions index a20cadf0ce8..9771905e34a 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -231,7 +231,7 @@ kill_tcp_connections() { _failed=0 _killcount=0 - connfile="$CTDB_BASE/state/connections.$_IP" + connfile="$CTDB_VARDIR/state/connections.$_IP" netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile netstat -tn |egrep "^tcp.*[[:space:]]+::ffff:$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' >> $connfile @@ -281,7 +281,7 @@ kill_tcp_connections_local_only() { _failed=0 _killcount=0 - connfile="$CTDB_BASE/state/connections.$_IP" + connfile="$CTDB_VARDIR/state/connections.$_IP" netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile netstat -tn |egrep "^tcp.*[[:space:]]+::ffff:$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' >> $connfile @@ -323,7 +323,7 @@ tickle_tcp_connections() { _failed=0 _killcount=0 - connfile="$CTDB_BASE/state/connections.$_IP" + connfile="$CTDB_VARDIR/state/connections.$_IP" netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile netstat -tn |egrep "^tcp.*[[:space:]]+::ffff:$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' >> $connfile @@ -453,7 +453,7 @@ add_ip_to_iface() local _iface=$1 local _ip=$2 local _maskbits=$3 - local _state_dir="$CTDB_BASE/state/interface_modify" + local _state_dir="$CTDB_VARDIR/state/interface_modify" local _lockfile="$_state_dir/$_iface.flock" local _readd_base="$_state_dir/$_iface.readd.d" @@ -476,7 +476,7 @@ delete_ip_from_iface() local _iface=$1 local _ip=$2 local _maskbits=$3 - local _state_dir="$CTDB_BASE/state/interface_modify" + local _state_dir="$CTDB_VARDIR/state/interface_modify" local _lockfile="$_state_dir/$_iface.flock" local _readd_base="$_state_dir/$_iface.readd.d" @@ -500,7 +500,7 @@ setup_iface_ip_readd_script() local _ip=$2 local _maskbits=$3 local _readd_script=$4 - local _state_dir="$CTDB_BASE/state/interface_modify" + local _state_dir="$CTDB_VARDIR/state/interface_modify" local _lockfile="$_state_dir/$_iface.flock" local _readd_base="$_state_dir/$_iface.readd.d" @@ -779,7 +779,7 @@ iptables() ######################################################## # Temporary directory for tickles. -tickledir="$CTDB_BASE/state/tickles" +tickledir="$CTDB_VARDIR/state/tickles" mkdir -p "$tickledir" update_tickles () diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index 9808cb941ea..39be9d3d4a1 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -9,6 +9,10 @@ export CTDB_BASE="/etc/ctdb" } +[ -z "$CTDB_VARDIR" ] && { + export CTDB_VARDIR="/var/ctdb" +} + . $CTDB_BASE/functions loadconfig ctdb loadconfig nfs @@ -30,8 +34,8 @@ case "$1" in continue } IP=`echo $LINE | cut -f2 -d:` - /bin/mkdir -p $CTDB_BASE/state/statd/ip/$IP - touch $CTDB_BASE/state/statd/ip/$IP/$2 + /bin/mkdir -p $CTDB_VARDIR/state/statd/ip/$IP + touch $CTDB_VARDIR/state/statd/ip/$IP/$2 done ;; del-client) @@ -45,8 +49,8 @@ case "$1" in continue } IP=`echo $LINE | cut -f2 -d:` - mkdir -p $CTDB_BASE/state/statd/ip/$IP - /bin/rm -f $CTDB_BASE/state/statd/ip/$IP/$2 + mkdir -p $CTDB_VARDIR/state/statd/ip/$IP + /bin/rm -f $CTDB_VARDIR/state/statd/ip/$IP/$2 done ;; updatelocal) @@ -59,25 +63,25 @@ case "$1" in } IP=`echo $LINE | cut -f2 -d:` - mkdir -p $CTDB_BASE/state/statd/ip/$IP + mkdir -p $CTDB_VARDIR/state/statd/ip/$IP - rm -f $CTDB_BASE/state/statd/ip/$IP.tar - tar cfP $CTDB_BASE/state/statd/ip/$IP.tar $CTDB_BASE/state/statd/ip/$IP + rm -f $CTDB_VARDIR/state/statd/ip/$IP.tar + tar cfP $CTDB_VARDIR/state/statd/ip/$IP.tar $CTDB_VARDIR/state/statd/ip/$IP - rm -f $CTDB_BASE/state/statd/ip/$IP.rec - ctdb pfetch ctdb.tdb statd-state:$IP $CTDB_BASE/state/statd/ip/$IP.rec 2>/dev/null + rm -f $CTDB_VARDIR/state/statd/ip/$IP.rec + ctdb pfetch ctdb.tdb statd-state:$IP $CTDB_VARDIR/state/statd/ip/$IP.rec 2>/dev/null [ "$?" = "0" ] || { # something went wrong, try storing this data echo No record. Store STATD state data for $IP - ctdb pstore ctdb.tdb statd-state:$IP $CTDB_BASE/state/statd/ip/$IP.tar 2>/dev/null + ctdb pstore ctdb.tdb statd-state:$IP $CTDB_VARDIR/state/statd/ip/$IP.tar 2>/dev/null continue } - cmp $CTDB_BASE/state/statd/ip/$IP.tar $CTDB_BASE/state/statd/ip/$IP.rec >/dev/null 2>/dev/null + cmp $CTDB_VARDIR/state/statd/ip/$IP.tar $CTDB_VARDIR/state/statd/ip/$IP.rec >/dev/null 2>/dev/null [ "$?" = "0" ] || { # something went wrong, try storing this data echo Updated record. Store STATD state data for $IP - ctdb pstore ctdb.tdb statd-state:$IP $CTDB_BASE/state/statd/ip/$IP.tar 2>/dev/null + ctdb pstore ctdb.tdb statd-state:$IP $CTDB_VARDIR/state/statd/ip/$IP.tar 2>/dev/null continue } done @@ -93,16 +97,16 @@ case "$1" in } IP=`echo $LINE | cut -f2 -d:` - mkdir -p $CTDB_BASE/state/statd/ip/$IP + mkdir -p $CTDB_VARDIR/state/statd/ip/$IP - rm -f $CTDB_BASE/state/statd/ip/$IP.rec - ctdb pfetch ctdb.tdb statd-state:$IP $CTDB_BASE/state/statd/ip/$IP.rec 2>/dev/null + rm -f $CTDB_VARDIR/state/statd/ip/$IP.rec + ctdb pfetch ctdb.tdb statd-state:$IP $CTDB_VARDIR/state/statd/ip/$IP.rec 2>/dev/null [ "$?" = "0" ] || { continue } - rm -f $CTDB_BASE/state/statd/ip/$IP/* - tar xfP $CTDB_BASE/state/statd/ip/$IP.rec + rm -f $CTDB_VARDIR/state/statd/ip/$IP/* + tar xfP $CTDB_VARDIR/state/statd/ip/$IP.rec done ;; @@ -181,8 +185,8 @@ case "$1" in } IP=`echo $LINE | cut -f2 -d:` - ls $CTDB_BASE/state/statd/ip/$IP | while read CLIENT; do - rm $CTDB_BASE/state/statd/ip/$IP/$CLIENT + 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 STATE=`expr "$STATE" "+" "1"`