Created
July 6, 2009 03:23
-
-
Save doitian/141247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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