local security="$4"
local up="$5"
local down="$6"
+ local route_up="$7"
+ local route_pre_down="$8"
+ local ipchange="$9"
local client=$(grep -qEx "client|tls-client" "$dir/$conf" && echo 1)
procd_open_instance "$name"
${client:+--ipchange "/usr/libexec/openvpn-hotplug ipchange $name"} \
${up:+--setenv user_up "$up"} \
${down:+--setenv user_down "$down"} \
+ ${route_up:+--setenv user_route_up "$route_up"} \
+ ${route_pre_down:+--setenv user_route_pre_down "$route_pre_down"} \
+ ${client:+${ipchange:+--setenv user_ipchange "$ipchange"}} \
--script-security "${security:-2}" \
$(openvpn_get_dev "$name" "$conf") \
$(openvpn_get_credentials "$name" "$conf")
return 1
}
- local up down script_security
+ local up down route_up route_pre_down ipchange script_security
config_get up "$s" up
config_get down "$s" down
+ config_get route_up "$s" route_up
+ config_get route_pre_down "$s" route_pre_down
+ config_get ipchange "$s" ipchange
config_get script_security "$s" script_security
[ ! -d "/var/run" ] && mkdir -p "/var/run"
append UCI_STARTED "$config" "$LIST_SEP"
[ -n "$up" ] || get_openvpn_option "$config" up up
[ -n "$down" ] || get_openvpn_option "$config" down down
- openvpn_add_instance "$s" "${config%/*}" "$config" "$script_security" "$up" "$down"
+ [ -n "$route_up" ] || get_openvpn_option "$config" route_up route-up
+ [ -n "$route_pre_down" ] || get_openvpn_option "$config" route_pre_down route-pre-down
+ [ -n "$ipchange" ] || get_openvpn_option "$config" ipchange ipchange
+ openvpn_add_instance "$s" "${config%/*}" "$config" "$script_security" "$up" "$down" "$route_up" "$route_pre_down" "$ipchange"
return
fi
append_params "$s" $OPENVPN_PARAMS
append_list "$s" $OPENVPN_LIST
- openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf" "$script_security" "$up" "$down"
+ openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf" "$script_security" "$up" "$down" "$route_up" "$route_pre_down" "$ipchange"
}
start_service() {
else
config_foreach start_instance 'openvpn'
- local path name up down
+ local path name up down route_up route_pre_down ipchange
for path in /etc/openvpn/*.conf; do
if [ -f "$path" ]; then
name="${path##*/}"; name="${name%.conf}"
get_openvpn_option "$path" up up || up=""
get_openvpn_option "$path" down down || down=""
- openvpn_add_instance "$name" "${path%/*}" "$path" "" "$up" "$down"
+ get_openvpn_option "$path" route_up route-up || route_up=""
+ get_openvpn_option "$path" route_pre_down route-pre-down || route_pre_down=""
+ get_openvpn_option "$path" ipchange ipchange || ipchange=""
+ openvpn_add_instance "$name" "${path%/*}" "$path" "" "$up" "$down" "$route_up" "$route_pre_down" "$ipchange"
+
fi
done
fi
service_triggers() {
procd_add_reload_trigger openvpn
}
+