2010-04-23 14:48:26 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
PIDFILE="/tmp/run/sshtunnel"
|
|
|
|
|
2010-10-05 21:51:46 +00:00
|
|
|
args="$1"
|
|
|
|
retrydelay="$2"
|
|
|
|
server="$3"
|
2010-04-23 14:48:26 +00:00
|
|
|
|
|
|
|
while true
|
|
|
|
do
|
2010-10-05 21:51:46 +00:00
|
|
|
logger -p daemon.info -t "sshtunnel[$$][$server]" "connection started"
|
2010-04-23 14:48:26 +00:00
|
|
|
|
|
|
|
start-stop-daemon -S -p "$PIDFILE"_"$$".pid -mx ssh -- $args &>/tmp/log/sshtunnel_$$
|
|
|
|
|
2010-10-05 21:51:46 +00:00
|
|
|
logger -p daemon.err -t "sshtunnel[$$][$server]" < /tmp/log/sshtunnel_$$
|
|
|
|
rm /tmp/log/sshtunnel_$$
|
|
|
|
logger -p daemon.info -t "sshtunnel[$$][$server]" "ssh exited with code $?, retrying in $retrydelay seconds"
|
2010-04-23 14:48:26 +00:00
|
|
|
|
|
|
|
sleep "$retrydelay" & wait
|
|
|
|
done
|