packages/net/autossh/files/autossh.init
Leo Soares 9c4d79519c autossh: fix procd env issue
This commit fixes an issue where the `AUTOSSH_GATETIME` is not available in the `procd`  environment which gets overwritten by the second `procd_set_param env` call.
It now calls the `procd_set_param env` once with the two variables, instead of twice.

Signed-off-by: Leo Soares <leo@hyper.ag>
2021-10-06 12:30:45 -07:00

28 lines
751 B
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2007-2011 OpenWrt.org
USE_PROCD=1
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
procd_open_instance
procd_set_param command /usr/sbin/autossh -M ${monitorport:-20000} ${ssh}
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
procd_set_param env AUTOSSH_GATETIME="${gatetime:-30}" AUTOSSH_POLL="${poll:-600}"
procd_close_instance
}
start_service() {
config_load 'autossh'
config_foreach start_instance 'autossh'
}