b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/bin/sh /etc/rc.common |
| 2 | # Copyright (C) 2007-2011 OpenWrt.org |
| 3 | |
| 4 | USE_PROCD=1 |
| 5 | START=80 |
| 6 | |
| 7 | start_instance() { |
| 8 | local section="$1" |
| 9 | |
| 10 | config_get ssh "$section" 'ssh' |
| 11 | config_get gatetime "$section" 'gatetime' |
| 12 | config_get monitorport "$section" 'monitorport' |
| 13 | config_get poll "$section" 'poll' |
| 14 | config_get_bool enabled "$section" 'enabled' '1' |
| 15 | |
| 16 | [ "$enabled" = 1 ] || exit 0 |
| 17 | |
| 18 | procd_open_instance |
| 19 | procd_set_param command /usr/sbin/autossh -M ${monitorport:-20000} ${ssh} |
| 20 | procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5} |
| 21 | procd_set_param env AUTOSSH_GATETIME="${gatetime:-30}" AUTOSSH_POLL="${poll:-600}" |
| 22 | procd_close_instance |
| 23 | } |
| 24 | |
| 25 | start_service() { |
| 26 | config_load 'autossh' |
| 27 | config_foreach start_instance 'autossh' |
| 28 | } |