From a7fc6e60095965a7171a6f115ad276bb57ec3758 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 7 Aug 2017 15:53:55 +0800 Subject: [PATCH] dispatch.sh: Make dispatching actually work for rrsync and diff Make it work. Basic BSD shell doesn't seem to have array support (read failed and ${!VAR[@]} as well). Also I don't know integer arithmetic so I do a runtime length for the loop. As we don't put $MACHINE/$RELASE into an `` block we should be okay and not run into remote execution. --- scripts/dispatch.sh | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) mode change 100644 => 100755 scripts/dispatch.sh diff --git a/scripts/dispatch.sh b/scripts/dispatch.sh old mode 100644 new mode 100755 index 6fde0ec..5670a63 --- a/scripts/dispatch.sh +++ b/scripts/dispatch.sh @@ -4,14 +4,37 @@ # TODO: Make this interactive and show the diff before and then # do the merge? -case "$SSH_ORIGINAL_COMMAND" in + +set -e + +# Extract first part... +item=1 +for i in $SSH_ORIGINAL_COMMAND; +do + if [ $item = "1" ]; then + CMD=$i + elif [ $item = "11" ]; then + MACHINE=$i + elif [ $item = "111" ]; then + RELEASE=$i + else + echo "Unknown.. $i" + fi + item="1$item" +done + +case "$CMD" in "rsync") - exec /usr/local/bin/rrsync web-files + exec /usr/local/bin/rrsync $1 ;; "diff-testing") - exec `dirname $0`/make-stable.sh $1 $2 dry-run + cd $1 + cd ../ + exec `dirname $0`/make-stable.sh $MACHINE $RELEASE dry-run ;; "merge-testing") - exec `dirname $0`/make-stable.sh $1 $2 + cd $1 + cd ../ + exec `dirname $0`/make-stable.sh $MACHINE $RELEASE ;; esac