From 1fe7a3db61ad91a686a118d7568029b0d0ba9ed5 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Mon, 19 Dec 2011 17:25:36 +0000 Subject: rapid-tunneling: gui saves tarball * rapid-tunneling -c copies tarball. * Web interface uses this to keep a copy of the log. * Don't log to /tmp/ra.log . git-svn-id: svn+ssh://xorcom/home/svn/debs/components/rapid-tunneling@10210 283159da-0705-0410-b60c-f2062b4bb6ad --- gui/index.php | 6 +++--- rapid-tunneling | 13 +++++++++++-- rapid-tunneling.8 | 5 +++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gui/index.php b/gui/index.php index 7f3eecf..88c7915 100644 --- a/gui/index.php +++ b/gui/index.php @@ -33,6 +33,7 @@ /tmp/ra.log 2>&1", $ret); + system("sudo -H rapid-tunneling -c ". + $_FILES["filename"]["tmp_name"], $ret); if ($ret != 0) $error = "Invalid or corrupt file. Please try again."; break; 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" diff --git a/rapid-tunneling.8 b/rapid-tunneling.8 index ce93082..88b784f 100644 --- a/rapid-tunneling.8 +++ b/rapid-tunneling.8 @@ -31,6 +31,11 @@ allow the operator of the remote server to connect locally. The following options allow you to override settings from the tarball with your own. +.B \-c +.RS +Save a copy of the tarball as $HOME/rapid-tunneling/remote-access.tar.gz . +.RE + .B \-D .RS Stay in the background and don't daemonize. Useful when running under a monitor -- cgit v1.2.3