2 ############################
3 # main event script for ctdb
5 # This script is called with one of the following sets of arguments
6 # startup : called when ctdb starts
7 # shutdown : called when ctdb shuts down
8 # takeip : called when an IP address is taken over
9 # releaseip : called when an IP address is released
10 # recovered : called when ctdb has finished a recovery event
12 . $CTDB_BASE/functions
15 # ensure we have /bin and /usr/bin in the path
16 PATH=/bin:/usr/bin:$PATH
21 # set default samba cleanup period - in minutes
22 [ -z "$CTDB_VACUUM_PERIOD" ] && {
26 ###########################
27 # periodic vacuum function
29 # this cleans up dead records and repacks the databases
30 ( time ctdb vacuum 200000 -T 30; time ctdb repack -T 30 ) > $CTDB_BASE/state/vacuum.log 2>&1 &
35 # make sure we have a blank state directory for the scripts to work with
36 /bin/rm -rf $CTDB_BASE/state
37 /bin/mkdir -p $CTDB_BASE/state
39 # set any tunables from the config file
40 set | grep ^CTDB_SET_ | cut -d_ -f3- |
42 varname=`echo $v | cut -d= -f1`
43 value=`echo $v | cut -d= -f2`
44 ctdb setvar $varname $value || exit 1
45 echo "Set $varname to $value"
50 # Create a dummy file to track when we need to do periodic cleanup
52 [ -f $CTDB_BASE/state/periodic_vacuum ] || {
53 touch $CTDB_BASE/state/periodic_vacuum
55 [ `/usr/bin/find $CTDB_BASE/state/periodic_vacuum -mmin +$CTDB_VACUUM_PERIOD | wc -l` -eq 1 ] && {
56 # vacuum the databases
57 touch $CTDB_BASE/state/periodic_vacuum