[pisa-src] r1100 - trunk/tools

  • From: René Hummen <rene.hummen@xxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Mon, 12 Oct 2009 20:34:14 +0200

Author: hummen
Date: Mon Oct 12 20:34:14 2009
New Revision: 1100

Log:
autoupdate now functional with passwords as well

Modified:
   trunk/tools/autoupdater.sh

Modified: trunk/tools/autoupdater.sh
==============================================================================
--- trunk/tools/autoupdater.sh  Mon Oct 12 18:15:58 2009        (r1099)
+++ trunk/tools/autoupdater.sh  Mon Oct 12 20:34:14 2009        (r1100)
@@ -10,27 +10,24 @@
 USER="root"
 SERVER="morpheus.informatik.rwth-aachen.de"
 PK=""
-# these need trailing /
-REMOTE_DIR=""
+# we need the fully qualified path
+REMOTE_DIR="/root/"
 REMOTE_HIPL_DIR=$REMOTE_DIR"hipl--midauth2--2.6/"
 REMOTE_PISA_DIR=$REMOTE_DIR"pisa/trunk/"
 REMOTE_CUSTOM_DIR=$REMOTE_DIR"pisa_custom/"
 LOCAL_DIR=$HOME"/pisa_testbed/"
 
-HIPL_FILES="hipd/hipd tools/hipconf"
-#TODO add required conf-files
+HIPL_FILES="hipd/hipd tools/hipconf firewall/hipfw"
 PISA_FILES="pisacd/pisacd pisasd/pisasd pisabeacon/pisabeacon tools/msleep"
 PISA_FILES=$PISA_FILES" tools/autoupdater.sh"
 # These files might need modifications for your scenario
-#PISA_FILES=$PISA_FILES"tools/switch-ip files/etc/pisa/pisacd.conf"
 CUSTOM_FILES="trigger-hipupdate.sh trigger-demo-update.sh switch-ip 
pisacd.conf"
 
 
 #### DON'T CHANGE BELOW ####
 
-REMOTE_PATH=""
-REMOTE_FILES=""
 PK_OPTION=""
+TMP_DIR=""
 
 echo
 echo "--- autoupdater for hipl and pisa binaries/configs ---"
@@ -45,51 +42,53 @@
     echo "NOTE: You can statically set the user name in this script."
 fi
 
-REMOTE_PATH=$USER"@"$SERVER":"
-
 # Create required directory structure
 if [ ! -d "$LOCAL_DIR" ]; then
      echo "Directory $LOCAL_DIR does not exist. Creating directory.";
      mkdir $LOCAL_DIR
 fi
 
+#Change to target dir
+TMP_DIR=$PWD
+cd $LOCAL_DIR
+
 for FILE in $HIPL_FILES
 do
-       REMOTE_FILES=$REMOTE_PATH$REMOTE_HIPL_DIR$FILE" "$REMOTE_FILES
+       echo "get "$REMOTE_HIPL_DIR$FILE" "$LOCAL_DIR >> files_to_copy
 done
 
 for FILE in $PISA_FILES
 do
-       REMOTE_FILES=$REMOTE_PATH$REMOTE_PISA_DIR$FILE" "$REMOTE_FILES
+       echo "get "$REMOTE_PISA_DIR$FILE" "$LOCAL_DIR >> files_to_copy
 done
 
 for FILE in $CUSTOM_FILES
 do
-       REMOTE_FILES=$REMOTE_PATH$REMOTE_CUSTOM_DIR$FILE" "$REMOTE_FILES
+       echo "get "$REMOTE_CUSTOM_DIR$FILE" "$LOCAL_DIR >> files_to_copy
 done
 
+# We want to exit the sftp client, right!?
+echo "exit" >> files_to_copy
+
 # check for ssh public key
 if [ "$PK" = "" ] || [ ! -e "$HOME/.ssh/$PK" ]; then
-    echo "No public key found. Hopefully you have ssh agent-forwarding \
-enabled. Otherwise, you will be asked for your login password for each \
-file to be copied."
-    echo
-    echo "As a workaround enable ssh multiplexing in your local \
-~/.ssh/config:"
-    echo "  Host "$SERVER
-    echo "    ControlMaster auto"
-    echo "    ControlPath ~/.ssh/master-%r@%h:%p"
-    echo
-    echo "Then open a separate SSH connection before starting this script:"
-    echo "  ssh "$USER@$SERVER
+    echo "No public key found. You will be asked for your login password."
     echo
 else
-       echo "public key found: "$PK;
-       PK_OPTION="-i "$PK
+    echo "public key found: "$PK;
+    echo
+    PK_OPTION="-o IdentityFile "$PK
 fi
 
+
 # Get files
-scp $PK_OPTION $REMOTE_FILES $LOCAL_DIR
+# NOTE: "BatchMode yes" does not allow for interactive login
+sftp -o "BatchMode no" $PK_OPTION -b files_to_copy $USER@$SERVER
+
+
+# Clean up
+rm files_to_copy
+cd $TMP_DIR
 
 # Further instructions
 echo "done."

Other related posts:

  • » [pisa-src] r1100 - trunk/tools - René Hummen