Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 38 lines (33 sloc) 622 Bytes
#!/bin/bash
#port=
#user=
#host=
source .hostinfo &> /dev/null || { echo "Please set the hostinfo."; exit 1; }
name=$(basename "$0")
lock=$(ps -A -F | grep CfgNnqT | grep ${user}@${host} | grep -v grep \
| awk '{print $2}')
if [[ "$#" = "1" && "$1" = "on" ]]
then
if [ -n "$lock" ]
then
echo Tunnel is already on.
exit 1
else
ssh -CfgNnqT -D $port ${user}@${host}
echo Tunnel is turned on.
fi
elif [[ "$#" = "1" && "$1" = "off" ]]
then
if [ -n "$lock" ]
then
kill $lock
echo Tunnel is turned off.
else
echo Tunnel is already off.
exit 1
fi
else
echo "Usage: $name on | off"
exit 1
fi
exit 0
Something went wrong with that request. Please try again.