Use a single entry-point script for post-boot setup
authorMartin Schwenke <martin@meltin.net>
Wed, 2 Jul 2014 07:39:06 +0000 (17:39 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 2 Jul 2014 10:26:52 +0000 (20:26 +1000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
autocluster
base/all/root/scripts/cluster_setup.sh [new file with mode: 0755]
base/all/root/scripts/install_extra_packages.sh [new file with mode: 0755]
base/all/root/scripts/install_packages.sh [deleted file]
base/all/root/scripts/setup_cluster.sh [deleted file]
base/all/root/scripts/setup_clusterfs.sh [deleted file]

index 69edc31..147670e 100755 (executable)
@@ -641,7 +641,7 @@ cluster_setup ()
                    ;;
            esac
 
-           $ssh "$name" "./scripts/${stage}.sh" $tasks
+           $ssh "$name" ./scripts/cluster_setup.sh "$stage" $tasks
        fi
 
     }
diff --git a/base/all/root/scripts/cluster_setup.sh b/base/all/root/scripts/cluster_setup.sh
new file mode 100755 (executable)
index 0000000..28f42f7
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+stage="$1" ; shift
+
+prefix="$stage"
+case "$stage" in
+    install_packages)
+       prefix="install"
+       # Always do the extra packages task
+       set -- "extra_packages" "$@"
+       ;;
+esac
+
+
+dn=$(dirname $0)
+
+for task ; do
+    case "$task" in
+       clusterfs)
+           type="@@CLUSTERFS_TYPE@@"
+           file="${prefix%_clusterfs}_clusterfs_${type}.sh"
+           ;;
+       *)
+           file="${prefix}_${task}.sh"
+    esac
+
+    path="${dn}/${file}"
+
+    if [ ! -x "$path" ] ; then
+       echo "Unable to find script \"${file}\" for stage \"${stage}\" task \"${task}\""
+       exit 1
+    fi
+
+    echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+    printf "%% %-66s %%\n" "Stage \"${stage}\", task \"${task}\" on host ${HOSTNAME%%.*}"
+    echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+    "$path"
+done
diff --git a/base/all/root/scripts/install_extra_packages.sh b/base/all/root/scripts/install_extra_packages.sh
new file mode 100755 (executable)
index 0000000..20b0094
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+echo "Updating from YUM repositories"
+yum -y update
+
+extra_packages="@@CONFIG_EXTRA_PACKAGES@@"
+if [ -n "$extra_packages" ] ; then
+    echo "Installing extra packages"
+    yum -y install $extra_packages
+fi
diff --git a/base/all/root/scripts/install_packages.sh b/base/all/root/scripts/install_packages.sh
deleted file mode 100755 (executable)
index 2b6a04c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-
-echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-printf "%% %-66s %%\n" "Install packages doing \"yum update\" on host ${HOSTNAME%%.*}"
-echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-echo "Updating from YUM repositories"
-yum -y update
-
-extra_packages="@@CONFIG_EXTRA_PACKAGES@@"
-if [ -n "$extra_packages" ] ; then
-    yum -y install $extra_packages
-fi
-
-dn=$(dirname $0)
-
-for task ; do
-    case "$task" in
-       clusterfs)
-           type="@@CLUSTERFS_TYPE@@"
-           file="install_clusterfs_${type}.sh"
-           ;;
-       *)
-           file="install_${task}.sh"
-    esac
-
-    path="${dn}/${file}"
-
-    if [ ! -x "$path" ] ; then
-       echo "Unable to find script \"${file}\" to install task \"${task}\""
-       exit 1
-    fi
-
-    echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-    printf "%% %-66s %%\n" "Install packages task \"${task}\" on host ${HOSTNAME%%.*}"
-    echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-    "$path"
-done
diff --git a/base/all/root/scripts/setup_cluster.sh b/base/all/root/scripts/setup_cluster.sh
deleted file mode 100755 (executable)
index 93aca59..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-dn=$(dirname $0)
-
-for task ; do
-    file="setup_cluster_${task}.sh"
-    path="${dn}/${file}"
-
-    if [ ! -x "$path" ] ; then
-       echo "Unable to find script \"${file}\" to setup task \"${task}\""
-       exit 1
-    fi
-
-    echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-    printf "%% %-66s %%\n" "Setup cluster task \"${task}\""
-    echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-    "$path" || exit $?
-done
diff --git a/base/all/root/scripts/setup_clusterfs.sh b/base/all/root/scripts/setup_clusterfs.sh
deleted file mode 100755 (executable)
index ec7c3e9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-dn=$(dirname $0)
-
-for task ; do
-    type="@@CLUSTERFS_TYPE@@"
-    file="setup_clusterfs_${type}.sh"
-    path="${dn}/${file}"
-
-    if [ ! -x "$path" ] ; then
-       echo "Unable to find script \"${file}\" to setup task \"${task}\""
-       exit 1
-    fi
-
-    echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-    printf "%% %-66s %%\n" "Setup clusterfs task \"${task}\""
-    echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-    "$path" || exit $?
-done