mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-27 22:59:53 +00:00
openvpn: clean up and fix the init script
- clean up duplication of procd instance handling code - using --cd *after* --config is rather pointless - to be able to log errors properly, --syslog needs to be passed before --config - tell procd about the generated or referenced config file instead of the uci file. this avoids having to restart all instances if only one of them changes. Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 38632
This commit is contained in:
parent
e00bc81a56
commit
2c84ff42f7
@ -51,6 +51,20 @@ section_enabled() {
|
|||||||
[ $enable -gt 0 ] || [ $enabled -gt 0 ]
|
[ $enable -gt 0 ] || [ $enabled -gt 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openvpn_add_instance() {
|
||||||
|
local name="$1"
|
||||||
|
local dir="$2"
|
||||||
|
local conf="$3"
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command "$PROG" \
|
||||||
|
--syslog "openvpn($name)" \
|
||||||
|
--cd "$dir" \
|
||||||
|
--config "$conf"
|
||||||
|
procd_set_param file "$dir/$conf"
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
start_instance() {
|
start_instance() {
|
||||||
local s="$1"
|
local s="$1"
|
||||||
|
|
||||||
@ -61,14 +75,7 @@ start_instance() {
|
|||||||
[ ! -d "/var/run" ] && mkdir -p "/var/run"
|
[ ! -d "/var/run" ] && mkdir -p "/var/run"
|
||||||
|
|
||||||
if [ ! -z "$config" ]; then
|
if [ ! -z "$config" ]; then
|
||||||
procd_open_instance
|
openvpn_add_instance "$s" "$(dirname "$config")" "$(basename "$config")"
|
||||||
procd_set_param command "$PROG" \
|
|
||||||
--config "$config" \
|
|
||||||
--cd "$(dirname $config)" \
|
|
||||||
--syslog "openvpn($s)" \
|
|
||||||
--writepid "/var/run/openvpn-$s.pid"
|
|
||||||
procd_set_param file "/etc/config/openvpn"
|
|
||||||
procd_close_instance
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -108,15 +115,7 @@ start_instance() {
|
|||||||
tls_cipher tls_remote tls_timeout tls_verify tmp_dir topology tran_window \
|
tls_cipher tls_remote tls_timeout tls_verify tmp_dir topology tran_window \
|
||||||
tun_mtu tun_mtu_extra txqueuelen user verb down push up
|
tun_mtu tun_mtu_extra txqueuelen user verb down push up
|
||||||
|
|
||||||
|
openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf"
|
||||||
procd_open_instance
|
|
||||||
procd_set_param command "$PROG" \
|
|
||||||
--config "/var/etc/openvpn-$s.conf" \
|
|
||||||
--cd "/var/etc" \
|
|
||||||
--syslog "openvpn($s)" \
|
|
||||||
--writepid "/var/run/openvpn-$s.pid"
|
|
||||||
procd_set_param file "/etc/config/openvpn"
|
|
||||||
procd_close_instance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user