[CUWiN-Dev] cuw_pushupgrade patch

Bill Comisky bcomisky at pobox.com
Wed Mar 30 17:40:41 CST 2005


Fixed so -C and -f upgrade options work when batch upgrading.
Also added a -h (help) and -d (dry-run).

bill

--
Bill Comisky
bcomisky at pobox.com
-------------- next part --------------
=== localsrc/batch-upgrades/cuw_pushupgrade
==================================================================
--- localsrc/batch-upgrades/cuw_pushupgrade  (revision 2547)
+++ localsrc/batch-upgrades/cuw_pushupgrade  (local)
@@ -2,32 +2,76 @@
 # $Id$
 
 usage() {
-    cat 1>&2 <<EOF
+	cat 1>&2 <<EOF
 
-Usage: $0 cuwin-upgrade.tar.gz nodeIP [nodeIP]...
+Usage: $0 [-Cfh] cuwin-upgrade.tar.gz nodeIP [nodeIP]...
 
 Pushes a gzip'd CUWiN upgrade tarball to the nodes
 given on the command line, running '/sbin/upgrade -'
 over ssh on each node as the root user.
 
+  -h	show this helpful message
+  -d	dry run, just display what would happen
+  -f	force upgrade, even if node appears to be a CD
+  -C	do not copy existing config file
+
 EOF
-    exit 1
+	exit 1
 }
 
-if [ "$#" -lt 2 ]; then
-    usage
-fi
+parse_flags ()
+{
+	upgrade_opts=''
+	dryrun=0
+	opts=$(getopt Cdfh $*)
+	set -- $opts
+	while [ "$#" -gt 0 ] ; do
+		case "$1" in
+		--)	shift
+			break
+			;;
+		-C)
+			upgrade_opts="$upgrade_opts -C"
+			shift
+			;;
+		-d)
+			dryrun=1
+			shift
+			;;
+		-f)
+			upgrade_opts="$upgrade_opts -f"
+			shift
+			;;
+		-h)
+			usage
+			;;
+		*)
+			;;
+		esac
+	done
+	upgrade_path=$1
+	shift
+	nodes=$*
+}
 
-TARBALL=$1
-if [ ! -f $TARBALL ]; then
-   echo "$TARBALL not found."
-   usage
+parse_flags ${*:-}
+
+[ -z "$upgrade_path" -o -z "$nodes" ] && usage
+
+if [ ! -f $upgrade_path ]; then
+	echo "$upgrade_path not found."
+	usage
 fi
-shift
 
-while [ $# -ne 0 ]; do
-  echo 
-  echo "Pushing $TARBALL to $1:"
-  cat $TARBALL | ssh root@$1 'export PATH="/sbin:/usr/sbin:$PATH"; upgrade -'
-  shift
+for node in $(echo $nodes)
+do
+	echo 
+	echo "Pushing $upgrade_path to $node:"
+	command="cat $upgrade_path | ssh root@$node 'export PATH=\"/sbin:/usr/sbin:\$PATH\"; upgrade $upgrade_opts -'"
+	if [ $dryrun -eq 1 ]; then
+		echo $command
+	else
+		eval $command
+	fi 
+	shift
 done


More information about the CU-Wireless-Dev mailing list