blob: d584e5a9892ac1858789685e4419642d997b33a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/bash
#config: AD_ADMIN_PASS
# Configure a simple NAS cluster as generated by autocluster..
set -e
conf_file="/root/scripts/nas.conf"
ad_admin_pass="$AD_ADMIN_PASS"
domain_auth="administrator${ad_admin_pass:+%}${ad_admin_pass}"
wait_until_healthy ()
{
local timeout="${1:-120}"
echo -n "Wait until healthy [<${timeout}] "
local count=0
while [ $count -lt $timeout ] ; do
if ctdb nodestatus all >/dev/null ; then
echo "[${count}]"
return 0
fi
echo -n "."
count=$(($count + 1))
sleep 1
done
echo "[TIMEOUT]"
return 1
}
auth_type=$(sed -r -n -e 's@^auth_method[[:space:]]*=[[:space:]]*(files|winbind)[[:space:]]*$@\1@p' "$conf_file")
case "$auth_type" in
winbind)
echo "Joining domain"
for i in $(seq 1 5) ; do
status=0
timeout 10 net ads join -U"$domain_auth" || status=$?
echo " status = $status"
if [ $status -eq 0 ] ; then
break
fi
sleep 1
done
;;
esac
echo "Restarting ctdb (up to 5 times)"
# Just in case the cluster doesn't become healthy the first time,
# repeat a few times...
for i in $(seq 1 5) ; do
onnode -p all "service ctdb restart"
if wait_until_healthy ; then
echo "NAS cluster setup complete"
exit 0
fi
done
exit 1
|