done
}
+append_list() {
+ local p; local v; local s="$1"; shift
+
+ list_cb_append() {
+ v="$1:${v}"
+ }
+
+ for p in $*; do
+ config_list_foreach "$s" "$p" list_cb_append
+ done
+ [ -n "$v" ] && append_param "$s" "$p" && echo " ${v%*:}" >> "/var/etc/openvpn-$s.conf"
+}
+
section_enabled() {
config_get_bool enable "$1" 'enable' 0
config_get_bool enabled "$1" 'enabled' 0
local dir="$2"
local conf="$3"
- procd_open_instance
+ procd_open_instance "$name"
procd_set_param command "$PROG" \
--syslog "openvpn($name)" \
--status "/var/run/openvpn.$name.status" \
--cd "$dir" \
--config "$conf"
procd_set_param file "$dir/$conf"
+ procd_set_param term_timeout 15
procd_set_param respawn
+ procd_append_param respawn 3600
+ procd_append_param respawn 5
+ procd_append_param respawn -1
procd_close_instance
}
append_bools "$s" $OPENVPN_BOOLS
append_params "$s" $OPENVPN_PARAMS
+ append_list "$s" $OPENVPN_LIST
openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf"
}
start_service() {
+ local instance="$1"
+ local instance_found=0
+
+ config_cb() {
+ local type="$1"
+ local name="$2"
+ if [ "$type" = "openvpn" ]; then
+ if [ -n "$instance" -a "$instance" = "$name" ]; then
+ instance_found=1
+ fi
+ fi
+ }
+
. /usr/share/openvpn/openvpn.options
config_load 'openvpn'
- config_foreach start_instance 'openvpn'
- local path name
- for path in /etc/openvpn/*.conf; do
- if [ -f "$path" ]; then
- name="${path##*/}"; name="${name%.conf}"
+ if [ -n "$instance" ]; then
+ [ "$instance_found" -gt 0 ] || return
+ start_instance "$instance"
+ else
+ config_foreach start_instance 'openvpn'
- # don't start configs again that are already started by uci
- if echo "$UCI_STARTED" | grep -qxF "$path"; then
- continue
+ local path name
+ for path in /etc/openvpn/*.conf; do
+ if [ -f "$path" ]; then
+ name="${path##*/}"; name="${name%.conf}"
- # don't start configs which are set to disabled in uci
- elif echo "$UCI_DISABLED" | grep -qxF "$path"; then
- logger -t openvpn "$name.conf is disabled in /etc/config/openvpn"
- continue
- fi
+ # don't start configs again that are already started by uci
+ if echo "$UCI_STARTED" | grep -qxF "$path"; then
+ continue
- openvpn_add_instance "$name" "${path%/*}" "$path"
- fi
- done
+ # don't start configs which are set to disabled in uci
+ elif echo "$UCI_DISABLED" | grep -qxF "$path"; then
+ logger -t openvpn "$name.conf is disabled in /etc/config/openvpn"
+ continue
+ fi
+
+ openvpn_add_instance "$name" "${path%/*}" "$path"
+ fi
+ done
+ fi
}
service_triggers() {