summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-07-11 21:50:54 +1000
committerAndrew Tridgell <tridge@samba.org>2008-07-11 21:50:54 +1000
commiteb280bc189c81276330d3f6d3a2ff522e23ecace (patch)
tree6f119c38143e140f4aefbdddb8a2f0dd1ecdef85
parentdc6506ad9fdde3a2c7084f13d0c274551a2b8cc6 (diff)
added testproxy
attempt to allow running from another directory
-rwxr-xr-xautocluster23
-rw-r--r--config.sample15
-rw-r--r--functions25
-rwxr-xr-xvircmd49
4 files changed, 94 insertions, 18 deletions
diff --git a/autocluster b/autocluster
index 703d8f6..80b612e 100755
--- a/autocluster
+++ b/autocluster
@@ -17,6 +17,13 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
+if [ -f "$0" ]; then
+ installdir="`dirname \"$0\"`"
+else
+ autocluster=`which $0`
+ installdir="`dirname \"$autocluster\"`"
+fi
+
config="config"
set -e
@@ -48,6 +55,9 @@ Usage: autocluster [OPTION] ... <COMMAND>
bootbase
boot the base image
+
+ testproxy
+ test your proxy setup
EOF
exit 1
}
@@ -265,9 +275,17 @@ boot_base() {
virsh create tmp/$NAME.xml
}
+###############################
+# test the proxy setup
+test_proxy() {
+ export http_proxy=$WEBPROXY
+ wget -O /dev/null $INSTALL_SERVER
+ echo "Proxy OK"
+}
######################################################################
+
############################
# parse command line options
temp=$(getopt -n "$prog" -o "c:x" -l help -- "$@")
@@ -286,7 +304,7 @@ while true ; do
done
. "$config"
-. functions
+. "$installdir/functions"
# check for needed programs
check_command nbd-client
@@ -335,6 +353,9 @@ case $command in
bootbase)
boot_base;
;;
+ testproxy)
+ test_proxy;
+ ;;
*)
usage;
;;
diff --git a/config.sample b/config.sample
index 52349e5..c323881 100644
--- a/config.sample
+++ b/config.sample
@@ -31,11 +31,11 @@ ISO="/virtual/ISO/RHEL5.2-Server-20080430.0-x86_64-DVD.iso"
# which template kickstart file to use. There are separate templates
# for each version of SoFS
-KICKSTART="templates/kickstart-1.5.cfg"
+KICKSTART="$installdir/templates/kickstart-1.5.cfg"
# the yum repositories to use. Choose the one appropriate for the
# version of SoFS you are installing
-YUM_TEMPLATE="templates/SoFS-1.5.repo"
+YUM_TEMPLATE="$installdir/templates/SoFS-1.5.repo"
# any extra packages to install. List one on each line. To force a package
@@ -163,13 +163,16 @@ JAVA_MAX_SIZE="400M"
NUMCPUS=2
# libvirt template to use for nodes
-NODE_TEMPLATE="templates/node.xml"
+NODE_TEMPLATE="$installdir/templates/node.xml"
# libvirt template to use for TSM server
-TSM_TEMPLATE="templates/tsmserver.xml"
+TSM_TEMPLATE="$installdir/templates/tsmserver.xml"
# libvirt template to use for initial install
-INSTALL_TEMPLATE="templates/install.xml"
+INSTALL_TEMPLATE="$installdir/templates/install.xml"
# libvirt template to use for boot_base.sh
-BOOT_TEMPLATE="templates/bootbase.xml"
+BOOT_TEMPLATE="$installdir/templates/bootbase.xml"
+
+# where to get the base templates from
+BASE_TEMPLATES="$installdir/base"
diff --git a/functions b/functions
index f1e3177..aee9775 100644
--- a/functions
+++ b/functions
@@ -34,40 +34,45 @@ mount_disk() {
mount_ok=1
break
}
+ umount mnt 2>/dev/null || true
sleep 1
done
[ $mount_ok = 1 ] || {
echo "Failed to mount $1"
exit 1
}
+ [ -d mnt/root ] || {
+ echo "Mounted directory does not look like a root filesystem"
+ ls -latr mnt
+ exit 1
+ }
}
# unmount a qemu image
unmount_disk() {
echo "Unmounting disk"
- sync
+ sync; sync; sync
umount mnt || umount mnt
nbd-client -d /dev/nb0 > /dev/null 2>&1 || true
killall -9 -q nbd-client || true
killall -q qemu-nbd || true
}
-# setup the files from base/, substituting any variables
+# setup the files from $BASE_TEMPLATES/, substituting any variables
# based on the config
setup_base() {
echo "Copy base files"
- chmod 600 base/etc/ssh/*key base/root/.ssh/*
for f in `cd base && find . \! -name '*~'`; do
- perms=`stat -c %a base/$f`
- if [ -d base/$f ]; then
- mkdir -p mnt/$f
- chown 0.0 mnt/$f
- chmod $perms mnt/$f
+ if [ -d "$BASE_TEMPLATES/$f" ]; then
+ mkdir -p mnt/"$f"
else
- substitute_vars base/$f mnt/$f
- chmod $perms mnt/$f
+ substitute_vars "$BASE_TEMPLATES/$f" "mnt/$f"
fi
+ chmod --reference="$BASE_TEMPLATES/$f" "mnt/$f"
done
+ # this is needed as git doesn't store file permissions other
+ # than execute
+ chmod 600 mnt/etc/ssh/*key mnt/root/.ssh/*
}
setup_repos() {
diff --git a/vircmd b/vircmd
index ae43626..5ac5bd8 100755
--- a/vircmd
+++ b/vircmd
@@ -1,7 +1,54 @@
#!/bin/bash
#make running virsh commands on a cluster easier
-. ./config
+config="config"
+
+####################
+# show program usage
+usage ()
+{
+ cat >&2 <<EOF
+Usage: vircmd [OPTION] ... <COMMAND>
+ options:
+ -c <file> specify config file (default is "config")
+ -x enable script debugging
+
+ commands:
+ start CLUSTERNAME
+ start cluster nodes
+
+ destroy CLUSTERNAME
+ power off cluster nodes (may cause data loss)
+
+ shutdown CLUSTERNAME
+ shutdown cluster nodes
+
+ undefine CLUSTERNAME
+ remove cluster
+
+EOF
+ exit 1
+}
+
+############################
+# parse command line options
+temp=$(getopt -n "$prog" -o "c:x" -l help -- "$@")
+
+[ $? != 0 ] && usage
+
+eval set -- "$temp"
+
+while true ; do
+ case "$1" in
+ -c) config="$2" ; shift; shift ;;
+ -x) set -x; shift ;;
+ --) shift ; break ;;
+ -h|--help|*) usage ;; # Shouldn't happen, so this is reasonable.
+ esac
+done
+
+. "$config"
+. functions
if [ $# -lt 2 ]; then
echo "Usage: vircmd COMMAND CLUSTERNAME"