diff --git a/copy_crashplan_id b/copy_crashplan_id index 88952d5..e110acb 100755 --- a/copy_crashplan_id +++ b/copy_crashplan_id @@ -1,11 +1,11 @@ #!/bin/bash -e # -# copy_crashplan_id shell scripts to copy the connection key from a remote +# copy_crashplan_id - shell scripts to copy the connection key from a remote # (e.g. headless) Crashplan instance and setup the local # machine's Crashplan client to connect to it using port # forwarding over an open SSH connection. See also https://support.code42.com/CrashPlan/4/Configuring/Using_CrashPlan_On_A_Headless_Computer # -# Version 1.0, latest version at: https://gitlab.lindenaar.net/scripts/crashplan +# Version 1.1, latest version at: https://gitlab.lindenaar.net/scripts/crashplan # # Copyright (c) 2016 Frederik Lindenaar # @@ -24,7 +24,7 @@ HOST= # name of machine runnig crashplan USER= # userid to use to login to machine # Leave blank for current user -SRC_SYSTEM=Linux # either Linux, Darwin, osx or detect +SRC_SYSTEM=Linux # either Linux, Darwin, osx or detect # Autodetects if blank (ssh conn, slow!) @@ -56,13 +56,22 @@ file_location() { esac } +myname=`basename "$0" .sh` # determine the connection parameters based on command line and configuration -if [ $# -gt 2 -o $# -eq 0 -a -z "$HOST" ]; then - echo "usage: $0 [user@]hostname [linux|osx|detect]" - if [ -n "$HOST" ]; then - echo " or just $0 to copy from $HOST" - fi +if [ $# -gt 2 -o "$1" == "-h" -o "$1" == "--help" -o $# -eq 0 -a -z "$HOST" ]; then + cat<<EOH + +usage: $myname [user@]hostname [linux|osx|detect]${HOST:+" + or just $myname to copy from $HOST"} + +Copy the connection key from a remote (e.g. headless) Crashplan instance and +setup the Crashplan client on local machine to connect to it using SSH port +forwarding (enable with ssh -L $PORT:$ADDR:4243 <name of Crashplan server>) + +See also https://support.code42.com/CrashPlan/4/Configuring/Using_CrashPlan_On_A_Headless_Computer + +EOH exit 2 elif [ $# -gt 0 ]; then conn=$1 @@ -73,7 +82,7 @@ else fi # ensure the host is reachable -if ping -o $HOST > /dev/null 2>&1; then +if ping -c 1 $HOST > /dev/null 2>&1; then echo "copying Crashplan connect key from $HOST" else die "unable to reach host $HOST" @@ -101,7 +110,6 @@ src=`file_location source "$SRC_SYSTEM"` dst=`file_location destination "$os"` # use script name to generate a temp file name, ensure the temp file is removed -myname=`basename "$0" .sh` tmpfile=`mktemp -t "$myname"` trap 'rm -f "$tmpfile"' 0