In a tool like this one, you really want an option to establish if the service should start or not by default on boot time, especially when its configuration file has to be customized by the user. In the configuration file, the new 'enabled' option is setted to '0' by default since the configuration provided by default will not be the one finally used. In the init script, the new 'enabled' option is setted to '1' by default in order to support the previous configuration file behaviour. Signed-off-by: Adrià Llaudet <adria.llaudet@gmail.com>
33 lines
646 B
Bash
33 lines
646 B
Bash
#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2007-2011 OpenWrt.org
|
|
|
|
START=80
|
|
|
|
start_instance() {
|
|
local section="$1"
|
|
|
|
config_get ssh "$section" 'ssh'
|
|
config_get gatetime "$section" 'gatetime'
|
|
config_get monitorport "$section" 'monitorport'
|
|
config_get poll "$section" 'poll'
|
|
config_get_bool enabled "$section" 'enabled' '1'
|
|
|
|
[ "$enabled" = 1 ] || exit 0
|
|
|
|
export AUTOSSH_GATETIME="${gatetime:-30}"
|
|
export AUTOSSH_POLL="${poll:-600}"
|
|
service_start /usr/sbin/autossh -M ${monitorport:-20000} -f ${ssh}
|
|
}
|
|
|
|
boot() {
|
|
return
|
|
}
|
|
|
|
start() {
|
|
config_load 'autossh'
|
|
config_foreach start_instance 'autossh'
|
|
}
|
|
|
|
stop() {
|
|
service_stop /usr/sbin/autossh
|
|
}
|