-
-
Save opexxx/b0b1cd99acb8d6c09f75 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
| # Simple init script to dig a ssh tunnel | |
| # Author: Christoph Heer <christoph.heer@googlemail.com> | |
| SSH_ARGS="user@remote.host -p 22 -N -n -L 4950:localhost:4949" | |
| PID_FILE="/var/run/remote_host_tunnel.pid" | |
| case "$1" in | |
| start) | |
| if [ -f $PID_FILE ]; then | |
| echo "ssh tunnel already exists" | |
| else | |
| echo "dig ssh tunnel..." | |
| start-stop-daemon --start --exec /usr/bin/ssh --background --pidfile=$PID_FILE --make-pidfile -- $SSH_ARGS | |
| fi | |
| ;; | |
| stop) | |
| echo "break down ssh tunnel..." | |
| start-stop-daemon --stop --pidfile=$PID_FILE | |
| rm $PID_FILE | |
| ;; | |
| restart) | |
| $0 stop | |
| $0 start | |
| ;; | |
| *) | |
| echo "Usage: $0 {start|stop|restart}" | |
| exit 1 | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment