diff options
Diffstat (limited to 'rapid-tunneling')
-rwxr-xr-x | rapid-tunneling | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/rapid-tunneling b/rapid-tunneling index a7ff91f..996c9df 100755 --- a/rapid-tunneling +++ b/rapid-tunneling @@ -11,6 +11,7 @@ usage() { echo >&2 " $me [options] remote-access-NAME.tar.gz" echo >&2 "" echo >&2 "Options:" + echo >&2 " -c Copy tarball" echo >&2 " -D Don't daemonize" echo >&2 " -h HOST Connect to HOST rather the host from the tarball" echo >&2 " -p PORT Connect to PORT rather the host from the tarball" @@ -25,13 +26,15 @@ fi if [ -r /etc/rapid-tunneling/client ]; then . /etc/rapid-tunneling/client; fi +opt_copy='no' opt_host='' opt_port='' opt_user='' opt_daemonize='yes' -while getopts dDh:p:u: opt; do +while getopts cdDh:p:u: opt; do case "$opt" in + c) opt_copy='yes';; D) opt_daemonize='no';; d) opt_daemonize='yes';; h) opt_host="$OPTARG";; @@ -43,9 +46,11 @@ done shift $((OPTIND - 1)) +tarball="$1" + tmpdir=`mktemp -d rapid-tunneling.XXXXXX` mkdir $tmpdir/recv $tmpdir/send -tar xzf "$1" -C $tmpdir/recv +tar xzf "$tarball" -C $tmpdir/recv [ "$opt_host" ] && host="$opt_host" || host=`cat $tmpdir/recv/host` [ "$opt_port" ] && port="$opt_port" || port=`cat $tmpdir/recv/port` [ "$opt_user" ] && user="$opt_user" || user=`cat $tmpdir/recv/user` @@ -77,4 +82,8 @@ else SSD_CMD="/bin/sh -c" fi +if [ "$opt_copy" = 'yes' ]; then + cp "$tarball" "$base_dir/remote-access.tar.gz" +fi + $SSD_CMD "exec env SSH_AUTH_SOCK= ssh -o 'StrictHostKeyChecking no' -o 'BatchMode yes' -o 'ServerAliveInterval 60' -T -p $port -i $base_dir/key -R $tunnelport:127.0.0.1:22 -l $user $host < $base_dir/ra-params.tar.gz" |