1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

Dont store temporary runtime data in $CTDB_BASE/state

since that will usually be /etc/ctdb/state and storing this under /etc is just
wrong.

Add a new variable CTDB_VARDIR that defaults to /var/ctdb and store the data there instead.

(This used to be ctdb commit 516423c25afa9861d9988096efa8a4a2b12b31b1)
This commit is contained in:
Ronnie Sahlberg 2010-09-03 12:35:25 +10:00
parent 7c682dda59
commit dc2f87737d
10 changed files with 60 additions and 52 deletions

View File

@ -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

View File

@ -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 &
}

View File

@ -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"

View File

@ -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
;;

View File

@ -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" ] && {

View File

@ -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 &
}

View File

@ -5,7 +5,7 @@
loadconfig
STATEDIR=$CTDB_BASE/state/gpfs
STATEDIR=$CTDB_VARDIR/state/gpfs
# filesystems needed by nfs

View File

@ -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.

View File

@ -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 ()

View File

@ -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"`