tcsh: move to github
[packages.git] / net / sshtunnel / files / sshtunnel.sh
1 #!/bin/sh 
2
3 PIDFILE="/tmp/run/sshtunnel"
4
5 args="$1"
6 retrydelay="$2"
7 server="$3"
8
9 while true
10 do
11         logger -p daemon.info -t "sshtunnel[$$][$server]" "connection started"
12         
13         start-stop-daemon -S -p "${PIDFILE}_${$}.pid" -mx ssh -- $args &>/tmp/log/sshtunnel_$$ 
14         
15         logger -p daemon.err -t "sshtunnel[$$][$server]" < /tmp/log/sshtunnel_$$
16         rm /tmp/log/sshtunnel_$$
17         logger -p daemon.info -t "sshtunnel[$$][$server]" "ssh exited with code $?, retrying in $retrydelay seconds"
18         rm "${PIDFILE}_${$}.pid"
19
20         sleep "$retrydelay" & wait
21 done