Selaa lähdekoodia

Add net/scp.sh for easier file transfer to/from network nodes

Michael Vines 7 vuotta sitten
vanhempi
sitoutus
c07d09c011
2 muutettua tiedostoa jossa 46 lisäystä ja 0 poistoa
  1. 43 0
      net/scp.sh
  2. 3 0
      net/ssh.sh

+ 43 - 0
net/scp.sh

@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+
+here=$(dirname "$0")
+# shellcheck source=net/common.sh
+source "$here"/common.sh
+
+usage() {
+  exitcode=0
+  if [[ -n "$1" ]]; then
+    exitcode=1
+    echo "Error: $*"
+  fi
+  cat <<EOF
+usage: $0 source ... target
+
+node scp - behaves like regular scp with the necessary options to
+access network nodes added automatically
+
+EOF
+  exit $exitcode
+}
+
+while getopts "h?" opt; do
+  case $opt in
+  h | \?)
+    usage
+    ;;
+  *)
+    usage "Error: unhandled option: $opt"
+    ;;
+  esac
+done
+
+loadConfigFile
+
+if [[ -n "$1" ]]; then
+  set -x
+  exec scp "${sshOptions[@]}" "$@"
+fi
+
+exec "$here"/ssh.sh
+
+exit 0

+ 3 - 0
net/ssh.sh

@@ -65,5 +65,8 @@ else
     printNode client "$ipAddress"
   done
 fi
+echo
+echo "Use |scp.sh| to transfer files to and from nodes"
+echo
 
 exit 0