X-Git-Url: https://git.archive.openwrt.org/?p=openwrt.git;a=blobdiff_plain;f=package%2Fnetwork%2Fservices%2Fopenvpn%2Ffiles%2Fopenvpn.init;h=294e3ed71031dc8a4185278dc31dda4a71ce7a96;hp=1e0f384f97806da84eafe24f3a4db1aef411d802;hb=848b0f05972047ba20015dc83c62c2c1da8d8d84;hpb=be79b667ee54b0d62ac079f68e3bcedc6e6d9133 diff --git a/package/network/services/openvpn/files/openvpn.init b/package/network/services/openvpn/files/openvpn.init index 1e0f384f97..294e3ed710 100644 --- a/package/network/services/openvpn/files/openvpn.init +++ b/package/network/services/openvpn/files/openvpn.init @@ -13,6 +13,9 @@ PROG=/usr/sbin/openvpn LIST_SEP=" " +UCI_STARTED= +UCI_DISABLED= + append_param() { local s="$1" local v="$2" @@ -59,6 +62,7 @@ openvpn_add_instance() { procd_open_instance procd_set_param command "$PROG" \ --syslog "openvpn($name)" \ + --status "/var/run/openvpn.$name.status" \ --cd "$dir" \ --config "$conf" procd_set_param file "$dir/$conf" @@ -69,14 +73,19 @@ openvpn_add_instance() { start_instance() { local s="$1" - section_enabled "$s" || return 1 - config_get config "$s" config + config="${config:+$(readlink -f "$config")}" + + section_enabled "$s" || { + append UCI_DISABLED "$config" "$LIST_SEP" + return 1 + } [ ! -d "/var/run" ] && mkdir -p "/var/run" if [ ! -z "$config" ]; then - openvpn_add_instance "$s" "$(dirname "$config")" "$(basename "$config")" + append UCI_STARTED "$config" "$LIST_SEP" + openvpn_add_instance "$s" "${config%/*}" "$config" return fi @@ -123,4 +132,23 @@ start_instance() { start_service() { 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}" + + # don't start configs again that are already started by uci + if echo "$UCI_STARTED" | grep -qxF "$path"; then + continue + + # 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 }