25
# Note the quotes around `$TEMP': they are essential!
26
#TEMP=`getopt -o t:ac:sSvpe:lwf:d --long run,clean -n 'cts' -- "$@"`
35
-c|-g) cluster_name=$2; shift; shift;;
36
-S) summary=1; saved=1; shift;;
37
-s) summary=1; shift;;
38
-v) verbose=`expr $verbose + 1`; shift;;
39
-p) pengine=1; shift;;
40
-e) patterns="$patterns -e `echo $2 | sed 's/ /\\\W/g'`"; shift; shift;;
41
-l) logfile=1; shift;;
43
-f) summary=1; custom_log=$2; shift; shift;;
44
-t) tests="$tests $2"; shift; shift;;
45
[0-9]*) tests="$tests $1"; shift;;
46
--build|build) build=1; shift;;
47
--kill|kill) kill=1; shift; break;;
48
--run|run) run=1; shift; break;;
49
--clean|clean) clean=1; shift;;
50
--inst|--install|install) install=1; clean=1; shift;;
54
/*) local_root=`dirname $cts_root`;;
55
*) local_root=`dirname $PWD/$cts_root`;;
58
cat << EOF > $cts_root/CTSvars.py
60
CTS_home="$local_root/cts"
61
Fencing_home="$local_root/fencing"
62
CRM_CONFIG_DIR="/var/lib/pacemaker/cib"
63
CRM_DAEMON_USER="hacluster"
64
CRM_DAEMON_DIR="/usr/libexec/pacemaker"
65
OCF_ROOT_DIR="/usr/lib/ocf"
68
files="extra/cluster-init extra/cluster-helper extra/cluster-clean tools/crm_report.in"
70
cp $local_root/$f $cts_root/
73
cp $local_root/report_common.in $local_root/report_common
74
sed -i.sed s:@localstatedir@:/var: $local_root/report_common
76
cp $cts_root/crm_report.in $cts_root/crm_report
77
sed -i.sed s:@datadir@/@PACKAGE@:$local_root/tools: $cts_root/crm_report
78
chmod +x $cts_root/crm_report
80
cp $cts_root/LSBDummy.in $cts_root/LSBDummy
81
chmod +x $local_root/fencing/fence_*
82
sed -i.sed s:@OCF_ROOT_DIR@:/usr/lib/ocf: $cts_root/LSBDummy
87
files="cluster-helper cluster-clean"
90
echo "Downloading helper script $f from GitHub"
91
wget -O $cts_root/$f https://raw.github.com/ClusterLabs/pacemaker/master/extra/$f
96
--) shift; tests="$tests $*"; break;;
98
*) echo "Unknown argument: $1"; exit 1;;
102
# Add the location of this script
103
export PATH="$PATH:$cts_root"
104
which cluster-helper &>/dev/null
106
echo $0 needs the cluster-helper script to be in your path
107
echo You can obtain it from: https://raw.github.com/ClusterLabs/pacemaker/master/extra/cluster-helper
111
which cluster-clean &>/dev/null
113
echo $0 needs the cluster-clean script to be in your path
114
echo You can obtain it from: https://raw.github.com/ClusterLabs/pacemaker/master/extra/cluster-clean
118
if [ "x$cluster_name" = x -o "x$cluster_name" = xpick ]; then
119
clusters=`ls -1 ~/.dsh/group/[a-z]+[0-9] | sed s/.*group.// | tr '\n' ' ' `
121
echo "custom) interactively define a cluster"
122
for i in $clusters; do
123
echo "$i) `cluster-helper --list short -g $i`"
126
read -p "Choose a cluster [custom]: " cluster_name
130
if [ -z $cluster_name ]; then
135
case $cluster_name in
137
cluster_hosts=`cluster-helper --list short -g $cluster_name`
138
cluster_log=~/cluster-$cluster_name.log;
141
read -p "Cluster name: " cluster_name
142
read -p "Cluster hosts: " cluster_hosts
143
read -p "Cluster log file: " cluster_log
147
if [ $build = 1 -a $run = 1 ]; then
152
if [ $build = 1 ]; then
155
echo "You'll need to write/obtain build-pcmk in order to build pacemaker from here. Skipping"
159
if [ $rc != 0 ]; then
160
echo "Build failed: $rc"
166
if [ $clean = 1 ]; then
167
rm -f $cluster_log; cluster-clean -g $cluster_name --kill
168
elif [ $kill = 1 ]; then
169
cluster-clean -g $cluster_name --kill-only
172
if [ $install = 1 ]; then
173
cluster-helper -g $cluster_name -- yum install -y pacemaker pacemaker-debuginfo pacemaker-cts libqb libqb-debuginfo
176
if [ $run = 1 ]; then
177
$cts_root/CTSlab.py -g $cluster_name -r --stonith $stonith -c --schema pacemaker-$schema --stack $stack 500 $*
180
elif [ $clean = 1 ]; then
184
screen -ls | grep cts-$cluster_name &>/dev/null
187
if [ ! -z $custom_log ]; then
188
cluster_log=$custom_log
191
if [ "x$tests" != x -a "x$tests" != "x " ]; then
193
echo "crm_report --cts-log $cluster_log -d -T $t"
194
crm_report --cts-log $cluster_log -d -T $t
197
elif [ $logfile = 1 ]; then
200
elif [ $summary = 1 ]; then
202
if [ $saved = 1 ]; then
203
files=`ls -1tr ~/CTS-*/cluster-log.txt`
208
0) cat -n $f | grep $patterns | grep -v "CTS: debug:"
210
1) cat -n $f | grep $patterns | grep -v "CTS:.* cmd:"
212
*) cat -n $f | grep $patterns
218
elif [ $watch = 1 ]; then
220
0) tail -F $cluster_log | grep $patterns | grep -v "CTS: debug:"
222
1) tail -F $cluster_log | grep $patterns | grep -v "CTS:.* cmd:"
224
*) tail -F $cluster_log | grep $patterns
228
elif [ $active = 0 ]; then
229
screen -x cts-$cluster_name
235
# . $BASH_FILES/.heartbeat
236
export cluster_name cluster_hosts cluster_log
237
screen -S cts-$cluster_name bash