[packages] add sshtunnel, Manages Local and Remote openssh ssh(1) tunnels
[openwrt/svn-archive/archive.git] / net / sshtunnel / files / usr / bin / sshtunnel.sh
1 #!/bin/sh
2
3 PIDFILE="/tmp/run/sshtunnel"
4
5 args=$1
6 retrydelay=$2
7
8 while true
9 do
10 logger -p daemon.info -t "sshtunnel[$$]" "connecting: ssh $args"
11
12 start-stop-daemon -S -p "$PIDFILE"_"$$".pid -mx ssh -- $args &>/tmp/log/sshtunnel_$$
13 logger -p daemon.err -t "sshtunnel[$$]" < /tmp/log/sshtunnel_$$
14 rm /tmp/log/sshtunnel_$$
15
16 logger -p daemon.info -t "sshtunnel[$$]" "ssh exited with code $?, retrying in $retrydelay seconds"
17
18 sleep "$retrydelay" & wait
19 done