Skip to content

Instantly share code, notes, and snippets.

@doitian
Created July 6, 2009 03:23
Show Gist options
  • Save doitian/141247 to your computer and use it in GitHub Desktop.
Save doitian/141247 to your computer and use it in GitHub Desktop.
#!/bin/bash
# account and host name of the remote server
VAR_HOST=account@host
# session name used in screen
VAR_SESSION_NAME=tunnel
# forwarding port
VAR_PORT=9999
stop () {
screen -S "$VAR_SESSION_NAME" -X quit 2> /dev/null
}
start () {
screen -S "$VAR_SESSION_NAME" -d -m ssh -D "$VAR_PORT" "$VAR_HOST" 'while true; do date; sleep 60; done'
}
main () {
local action=start
if [ -n "$1" ]; then
action="$1"
fi
case "$action" in
start)
stop
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo 'unknow action'
;;
esac
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment