diff --git a/web/ssh-tunnelier b/web/ssh-tunnelier index f145530..c710b84 100755 --- a/web/ssh-tunnelier +++ b/web/ssh-tunnelier @@ -4,6 +4,13 @@ CONFDIR="$HOME/.config/ssh-tunnelier" CONF="$CONFDIR/config" MAGIC_TIME=873749328 +BASE="base64 -w 0" +UNBASE="base64 -d" +if [[ "$OSTYPE" = "darwin"* ]]; then + BASE="base64" + UNBASE="base64 -D" +fi + function _helpexit() { echo "SSH tunnel manager Runs and monitors preconfigured background ssh tunnels, with the ability @@ -48,12 +55,12 @@ function fpgrep() { } function get_id() { - id=$( printf "%s" "$line" | base64 -w 0 ) + id=$( printf "%s" "$line" | $BASE ) echo -n $id } function get_command() { - switches=$( echo "$1" | base64 -d ) + switches=$( echo "$1" | $UNBASE ) echo -n "ssh -f -n $switches \"sleep $MAGIC_TIME; echo tunneler $1\"" } @@ -138,7 +145,7 @@ while true; do continue } - printf "\n${colTitle}Tunnel command: %s${colZ}\n" "$( echo "${ids[$j]}" | base64 -d )" + printf "\n${colTitle}Tunnel command: %s${colZ}\n" "$( echo "${ids[$j]}" | $UNBASE )" this_pid="$( get_pid "${ids[$j]}" )" [[ -n "$this_pid" ]] && { # PID exists, ask to kill