scp.sh 615 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bash
  2. here=$(dirname "$0")
  3. # shellcheck source=net/common.sh
  4. source "$here"/common.sh
  5. usage() {
  6. exitcode=0
  7. if [[ -n "$1" ]]; then
  8. exitcode=1
  9. echo "Error: $*"
  10. fi
  11. cat <<EOF
  12. usage: $0 source ... target
  13. node scp - behaves like regular scp with the necessary options to
  14. access network nodes added automatically
  15. EOF
  16. exit $exitcode
  17. }
  18. while getopts "h?" opt; do
  19. case $opt in
  20. h | \?)
  21. usage
  22. ;;
  23. *)
  24. usage "Error: unhandled option: $opt"
  25. ;;
  26. esac
  27. done
  28. loadConfigFile
  29. if [[ -n "$1" ]]; then
  30. set -x
  31. exec scp "${sshOptions[@]}" "$@"
  32. fi
  33. exec "$here"/ssh.sh
  34. exit 0