openvpn: Added option to not start the native OpenVPN configurations on boot
authorFlorian Eckert <redacted>
Wed, 20 Dec 2023 13:20:13 +0000 (14:20 +0100)
committerFlorian Eckert <redacted>
Wed, 20 Dec 2023 14:01:46 +0000 (15:01 +0100)
OpenVPN configurations that have a uci entry, the enable/enabled option can
be used to control whether the OpenVPN connection should be started at
system startup or not.

OpenVPN configurations that are located under '/etc/openvpn/' are always
started at system boot. To ensure that these connections can also be
started later, they must 'not' be started automatically during system boot.
This can be prevented with the following entry in the OpenVPN configuration.

config globals 'globals'
option autostart '0'

These OpenVPN configurations can then be started later with the command.
'/etc/init.d/openvpn start <name>'

Signed-off-by: Florian Eckert <redacted>
net/openvpn/files/openvpn.init

index 806afe2753ff85ee19f01ac92cde1971a136f9b4..6f4dc4206f26c88f2169b074e10b7b3bdf5bdc8d 100644 (file)
@@ -271,7 +271,12 @@ start_service() {
        else
                config_foreach start_uci_instance 'openvpn'
 
-               start_path_instances
+               auto="$(uci_get openvpn globals autostart 1)"
+               if [ "$auto" = "1" ]; then
+                       start_path_instances
+               else
+                       logger -t openvpn "Autostart for configs in '$PATH_INSTANCE_DIR/*.conf' disabled"
+               fi
        fi
 }
 
git clone https://git.99rst.org/PROJECT