cope with non-standard install dirs in event scripts
[sahlberg/ctdb.git] / config / events.d / 00.ctdb
1 #!/bin/sh
2 ############################
3 # main event script for ctdb
4 #
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
11
12 . $CTDB_BASE/functions
13 loadconfig ctdb
14
15 # ensure we have /bin and /usr/bin in the path
16 PATH=/bin:/usr/bin:$PATH
17
18 cmd="$1"
19 shift
20
21 case $cmd in 
22      startup)
23         # make sure we have a blank state directory for the scripts to work with
24         /bin/rm -rf $CTDB_BASE/state
25         /bin/mkdir -p $CTDB_BASE/state
26
27         # set any tunables from the config file
28         set | grep ^CTDB_SET_ | cut -d_ -f3- | 
29         while read v; do
30             varname=`echo $v | cut -d= -f1`
31             value=`echo $v | cut -d= -f2`
32             ctdb setvar $varname $value || exit 1
33             echo "`date` Set $varname to $value"
34         done
35         ;;
36 esac
37
38 # all OK
39 exit 0