You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
530 B

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