diff --git a/web/ssh-tunnelier b/web/ssh-tunnelier index a23cce1..172452a 100755 --- a/web/ssh-tunnelier +++ b/web/ssh-tunnelier @@ -2,8 +2,8 @@ CONFDIR="$HOME/.config/ssh-tunnelier" CONF="$CONFDIR/config" -# Just over a week -MAGIC_TIME=604813 +# Just over a year in minutes +MAGIC_TIME=525601 BASE="base64 -w 0" UNBASE="base64 -d" @@ -62,11 +62,11 @@ function get_id() { function get_command() { switches=$( echo "$1" | $UNBASE ) - echo -n "ssh -f -n $switches \"/bin/sh -O huponexit -c 'sleep $MAGIC_TIME'; echo tunneler $1\"" + echo -n "ssh -f -n $switches \"nice /bin/bash -c 'for ((i=1;i<$MAGIC_TIME;i++)); do cut -f4 -d \\\" \\\" /proc/\\\$PPID/stat | xargs kill -0 || exit ; sleep 60;done'; echo tunnelier $1\"" } function get_pid() { - pgrep -f "$MAGIC_TIME.*echo tunneler $1" | head -n 1 + pgrep -f "$MAGIC_TIME.*echo tunnelier $1" | head -n 1 } function list_all_ssh() { @@ -102,7 +102,8 @@ function run_args() { REMOTE="$3" [[ -z "$REMOTE" ]] && REMOTE="$LOCAL" echo Connect to $HOST - ssh -f -n -L "${LOCAL}:localhost:${REMOTE}" "$HOST" "/bin/sh -O huponexit -c 'sleep $MAGIC_TIME'" + switches=$( echo '-L "${LOCAL}:localhost:${REMOTE}" "$HOST"' | $BASE ) + run_command "$switches" } function run_command() {