summaryrefslogtreecommitdiffstats
path: root/base/root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'base/root/scripts')
-rw-r--r--base/root/scripts/functions33
-rwxr-xr-xbase/root/scripts/setup_samba.sh27
2 files changed, 45 insertions, 15 deletions
diff --git a/base/root/scripts/functions b/base/root/scripts/functions
new file mode 100644
index 0000000..be320fe
--- /dev/null
+++ b/base/root/scripts/functions
@@ -0,0 +1,33 @@
+# Hey Emacs, this is a -*- shell-script -*- In fact, it is bash! :-)
+
+cluster_is_healthy ()
+{(
+ set -o pipefail
+ { ctdb -Y status || return 1 ; } |
+ {
+ read x
+ count=0
+ while read line ; do
+ count=$(($count + 1))
+ [ "${line#:*:*:}" != "0:0:0:0:" ] && cat >/dev/null && return 1
+ done
+ [ $count -gt 0 ] && return $?
+ }
+)}
+
+wait_until_healthy ()
+{
+ local timeout="${1:-120}"
+
+ while [ $timeout -gt 0 ] ; do
+ if cluster_is_healthy ; then
+ echo .
+ return 0
+ fi
+ echo -n .
+ timeout=$(($timeout - 1))
+ sleep 1
+ done
+
+ return 1
+}
diff --git a/base/root/scripts/setup_samba.sh b/base/root/scripts/setup_samba.sh
index f8f533d..bc57fc8 100755
--- a/base/root/scripts/setup_samba.sh
+++ b/base/root/scripts/setup_samba.sh
@@ -12,6 +12,8 @@ trap 'es=$?;
domain_auth="administrator"
conf_file="/root/scripts/conf.base"
+. /root/scripts/functions
+
######################################
# run an onnode - using -p if possible
run_onnode() {
@@ -75,9 +77,8 @@ echo "Enabling and restarting ctdb"
run_onnode all chkconfig ctdb on
run_onnode all "service ctdb restart > /dev/null"
-echo "Waiting for ctdb to enter normal mode"
-while ! ctdb status | grep NORMAL > /dev/null; do echo -n "."; sleep 1; done
-echo
+echo "Waiting for cluster to become healthy"
+wait_until_healthy
echo "Starting smbd to initialise registry"
/usr/sbin/smbd -D
@@ -90,28 +91,24 @@ sofs conf restore "$conf_file"
echo "Forcing config reload"
sofs conf reload
-echo "Fixing scp and ftp jails"
-onnode -p all /opt/IBM/sofs/scripts/cnjailgen /var/opt/IBM/sofs/scproot
-onnode -p all /opt/IBM/sofs/scripts/cnjailgen /var/opt/IBM/sofs/ftproot
-ln -f /lib64/libnss_winbind* /var/opt/IBM/sofs/scproot/lib64/
-ln -f /lib64/libnss_winbind* /var/opt/IBM/sofs/ftproot/lib64/
-
echo "Joining domain"
net ads join -U"$domain_auth"
echo "Restarting ctdb"
run_onnode all "service ctdb restart > /dev/null"
-echo "Waiting for ctdb to enter normal mode"
-while ! ctdb status | grep NORMAL > /dev/null; do echo -n "."; sleep 1; done
-echo
+echo "Waiting for cluster to become healthy"
+wait_until_healthy
# why is this needed? Samba doesn't come up the first time??
echo "Restarting ctdb again"
run_onnode all "service ctdb restart > /dev/null"
-echo "Waiting for ctdb to enter normal mode"
-while ! ctdb status | grep NORMAL > /dev/null; do echo -n "."; sleep 1; done
-echo
+echo "Waiting for cluster to become healthy"
+wait_until_healthy
+
+echo "Ensuring scp and ftp jails are setup"
+onnode -p all /opt/IBM/sofs/scripts/cnjailgen /var/opt/IBM/sofs/scproot
+onnode -p all /opt/IBM/sofs/scripts/cnjailgen /var/opt/IBM/sofs/ftproot
echo "Setup done"