|
|
@ -60,7 +60,7 @@ openvpn_add_instance() { |
|
|
|
local dir="$2" |
|
|
|
local dir="$2" |
|
|
|
local conf="$3" |
|
|
|
local conf="$3" |
|
|
|
|
|
|
|
|
|
|
|
procd_open_instance |
|
|
|
procd_open_instance "$name" |
|
|
|
procd_set_param command "$PROG" \ |
|
|
|
procd_set_param command "$PROG" \ |
|
|
|
--syslog "openvpn($name)" \ |
|
|
|
--syslog "openvpn($name)" \ |
|
|
|
--status "/var/run/openvpn.$name.status" \ |
|
|
|
--status "/var/run/openvpn.$name.status" \ |
|
|
@ -103,28 +103,47 @@ start_instance() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
start_service() { |
|
|
|
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 |
|
|
|
. /usr/share/openvpn/openvpn.options |
|
|
|
config_load 'openvpn' |
|
|
|
config_load 'openvpn' |
|
|
|
config_foreach start_instance 'openvpn' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local path name |
|
|
|
if [ -n "$instance" ]; then |
|
|
|
for path in /etc/openvpn/*.conf; do |
|
|
|
[ "$instance_found" -gt 0 ] || return |
|
|
|
if [ -f "$path" ]; then |
|
|
|
start_instance "$instance" |
|
|
|
name="${path##*/}"; name="${name%.conf}" |
|
|
|
else |
|
|
|
|
|
|
|
config_foreach start_instance 'openvpn' |
|
|
|
|
|
|
|
|
|
|
|
# don't start configs again that are already started by uci |
|
|
|
local path name |
|
|
|
if echo "$UCI_STARTED" | grep -qxF "$path"; then |
|
|
|
for path in /etc/openvpn/*.conf; do |
|
|
|
continue |
|
|
|
if [ -f "$path" ]; then |
|
|
|
|
|
|
|
name="${path##*/}"; name="${name%.conf}" |
|
|
|
|
|
|
|
|
|
|
|
# don't start configs which are set to disabled in uci |
|
|
|
# don't start configs again that are already started by uci |
|
|
|
elif echo "$UCI_DISABLED" | grep -qxF "$path"; then |
|
|
|
if echo "$UCI_STARTED" | grep -qxF "$path"; then |
|
|
|
logger -t openvpn "$name.conf is disabled in /etc/config/openvpn" |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openvpn_add_instance "$name" "${path%/*}" "$path" |
|
|
|
# don't start configs which are set to disabled in uci |
|
|
|
fi |
|
|
|
elif echo "$UCI_DISABLED" | grep -qxF "$path"; then |
|
|
|
done |
|
|
|
logger -t openvpn "$name.conf is disabled in /etc/config/openvpn" |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openvpn_add_instance "$name" "${path%/*}" "$path" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
service_triggers() { |
|
|
|
service_triggers() { |
|
|
|