blob: d97011896f18c2dcf5e7945876bf034bd2321205 (
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
|
#!/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"
net ads join -U"$domain_auth"
;;
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
|