#!/bin/bash
-# Copyright (C) 2006, 2007 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# This is a test script to ease development and testing on test clusters.
# It should not be used to update production environments.
-# Usage: upload.sh node-{1,2,3}
+# Usage: upload node-{1,2,3}
# it will upload the python libraries to
# $prefix/lib/python2.4/site-packages/ganeti and the command line utils to
# $prefix/sbin. It needs passwordless root login to the nodes.
set -e
+
+PREFIX='@PREFIX@'
+SYSCONFDIR='@SYSCONFDIR@'
+PKGLIBDIR='@PKGLIBDIR@'
+
+NO_RESTART=
+NO_CRON=
+NO_DEBUG=
+hosts=
+while [ "$#" -gt 0 ]; do
+ opt="$1"
+ case "$opt" in
+ --no-restart)
+ NO_RESTART=1
+ ;;
+ --no-cron)
+ NO_CRON=1
+ ;;
+ --no-debug)
+ NO_DEBUG=1
+ ;;
+ -h|--help)
+ echo "Usage: $0 [--no-restart] hosts..."
+ exit 0
+ ;;
+ -*)
+ echo "Unknown option: $opt" >&2
+ exit 1
+ ;;
+ *)
+ hosts="$hosts $opt"
+ ;;
+ esac
+ shift
+done
+
+set ${hosts}
+
+make regen-vcs-version
+
TXD=`mktemp -d`
trap 'rm -rf $TXD' EXIT
+if [[ -f /proc/cpuinfo ]]; then
+ cpu_count=$(grep -E -c '^processor[[:space:]]*:' /proc/cpuinfo)
+ make_args=-j$(( cpu_count + 1 ))
+else
+ make_args=
+fi
+
+# Make sure that directories will get correct permissions
+umask 0022
+
# install ganeti as a real tree
-make install DESTDIR="$TXD"
+make $make_args install DESTDIR="$TXD"
+
+# copy additional needed files
+[ -f doc/examples/ganeti.initd ] && \
+install -D --mode=0755 doc/examples/ganeti.initd \
+ "$TXD/$SYSCONFDIR/init.d/ganeti"
+
+[ -f doc/examples/ganeti.default-debug -a -z "$NO_DEBUG" ] && \
+install -D --mode=0644 doc/examples/ganeti.default-debug \
+ "$TXD/$SYSCONFDIR/default/ganeti"
+
+[ -f doc/examples/bash_completion ] && \
+install -D --mode=0644 doc/examples/bash_completion \
+ "$TXD/$SYSCONFDIR/bash_completion.d/ganeti"
+
+if [ -f doc/examples/ganeti.cron -a -z "$NO_CRON" ]; then
+ install -D --mode=0644 doc/examples/ganeti.cron \
+ "$TXD/$SYSCONFDIR/cron.d/ganeti"
+fi
+
+[ -f doc/examples/dumb-allocator ] && \
+install -D --mode=0755 doc/examples/dumb-allocator \
+ "$TXD/$PKGLIBDIR/iallocators/dumb"
echo ---
echo ---
-PREFIX='@PREFIX@'
-
# and now put it under $prefix on the target node(s)
for host; do
echo Uploading code to ${host}...
- rsync -v -rlDc --exclude="*.py[oc]" --exclude="*.pdf" --exclude="*.html" \
- "$TXD/$PREFIX/" \
- root@${host}:$PREFIX/ &
+ rsync -v -rlDc \
+ -e "ssh -oBatchMode=yes" \
+ --exclude="*.py[oc]" --exclude="*.pdf" --exclude="*.html" \
+ "$TXD/" \
+ root@${host}:/ &
done
wait
-for host; do
- echo Uploading init script to ${host}...
- scp doc/examples/ganeti.initd root@${host}:/etc/init.d/ganeti &
-done
-wait
-
-if [ -f ganeti-master-cron ]; then
+if test -z "${NO_RESTART}"; then
for host; do
- echo Uploading cron files to ${host}...
- scp ganeti-master-cron root@${host}:/etc/ganeti/master-cron &
+ echo Restarting ganeti-noded on ${host}...
+ ssh -oBatchMode=yes root@${host} /etc/init.d/ganeti restart &
done
+ wait
fi
-wait
-
-for host; do
- echo Restarting ganeti-noded on ${host}...
- ssh root@${host} /etc/init.d/ganeti restart &
-done
-wait