From 2d8b5867942f224453b012fe518e5684c3d22313 Mon Sep 17 00:00:00 2001 From: HgO Date: Wed, 16 Aug 2023 20:39:02 +0200 Subject: [PATCH] remove openvpn coupling --- conf/openvpn_90-hotspot | 3 +++ conf/ynh-hotspot | 15 --------------- scripts/backup | 3 +++ scripts/install | 8 ++++++++ scripts/remove | 3 +++ scripts/restore | 3 +++ scripts/upgrade | 7 +++++++ 7 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 conf/openvpn_90-hotspot diff --git a/conf/openvpn_90-hotspot b/conf/openvpn_90-hotspot new file mode 100644 index 0000000..5964ef2 --- /dev/null +++ b/conf/openvpn_90-hotspot @@ -0,0 +1,3 @@ +#!/bin/bash + +systemctl restart ynh-hotspot diff --git a/conf/ynh-hotspot b/conf/ynh-hotspot index 546d283..26fa6d9 100644 --- a/conf/ynh-hotspot +++ b/conf/ynh-hotspot @@ -20,10 +20,6 @@ # Functions ## State functions -has_vpnclient_app() { - [ -e /tmp/.ynh-vpnclient-started ] -} - has_ip6delegatedprefix() { local i=${1} @@ -353,12 +349,6 @@ if [ "$1" != restart ]; then old_gateway_interface=$(ynh_setting_get hotspot gateway_interface) new_gateway_interface=$(ip route get 1.2.3.4 | awk '{ print $5; }') - # Switch the NAT interface if there is a VPN - ip link show dev tun0 &>/dev/null - if [ "$?" -eq 0 ]; then - new_gateway_interface=tun0 - fi - echo "OK" fi @@ -459,11 +449,6 @@ stop) echo "Stop hostapd" stop_hostapd fi - - # Fix configuration - if has_vpnclient_app; then - ynh-vpnclient start - fi ;; restart) $0 stop diff --git a/scripts/backup b/scripts/backup index 8284b04..8634184 100644 --- a/scripts/backup +++ b/scripts/backup @@ -50,6 +50,9 @@ ynh_backup --src_path="/etc/dnsmasq.dhcpd/dhcpdv4.conf.tpl" ynh_backup --src_path="/usr/local/bin/$service_name" +ynh_backup --src_path="/etc/openvpn/scripts/route-up.d/90-hotspot" +ynh_backup --src_path="/etc/openvpn/scripts/route-down.d/90-hotspot" + ynh_backup --src_path="/etc/init.d/hostapd" #================================================= diff --git a/scripts/install b/scripts/install index 8032f2a..e82036b 100644 --- a/scripts/install +++ b/scripts/install @@ -165,6 +165,14 @@ install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq # Copy init script install -o root -g root -m 0755 ../conf/$service_name /usr/local/bin/ +# Copy openvpn scripts +mkdir -pm 0755 /etc/openvpn/scripts +mkdir -pm 0755 /etc/openvpn/scripts/route-up.d +mkdir -pm 0755 /etc/openvpn/scripts/route-down.d +install -o root -g root -m 0755 ../conf/openvpn_90-hotspot /etc/openvpn/scripts/route-up.d/90-hotspot +install -o root -g root -m 0755 ../conf/openvpn_90-hotspot /etc/openvpn/scripts/route-down.d/90-hotspot + + #================================================= # CONFIGURE HOSTAPD #================================================= diff --git a/scripts/remove b/scripts/remove index 4ccfd27..ae210dd 100644 --- a/scripts/remove +++ b/scripts/remove @@ -54,6 +54,9 @@ ynh_remove_app_dependencies #================================================= ynh_script_progression --message="Removing app main directory..." +ynh_secure_remove --file="/etc/openvpn/scripts/route-up.d/90-hotspot" +ynh_secure_remove --file="/etc/openvpn/scripts/route-down.d/90-hotspot" + # Remove the app directory securely ynh_secure_remove --file="/usr/local/bin/$service_name" diff --git a/scripts/restore b/scripts/restore index fb047d1..ee9580e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,6 +70,9 @@ ynh_restore_file --origin_path="/etc/dnsmasq.dhcpd/dhcpdv4.conf.tpl" ynh_restore_file --origin_path="/usr/local/bin/$service_name" +ynh_restore_file --origin_path="/etc/openvpn/scripts/route-up.d/90-hotspot" +ynh_restore_file --origin_path="/etc/openvpn/scripts/route-down.d/90-hotspot" + ynh_restore_file --origin_path="/etc/init.d/hostapd" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 519721e..72a98b4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -141,6 +141,13 @@ install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq # Copy init script install -o root -g root -m 0755 ../conf/$service_name /usr/local/bin/ +# Copy openvpn scripts +mkdir -pm 0755 /etc/openvpn/scripts +mkdir -pm 0755 /etc/openvpn/scripts/route-up.d +mkdir -pm 0755 /etc/openvpn/scripts/route-down.d +install -o root -g root -m 0755 ../conf/openvpn_90-hotspot /etc/openvpn/scripts/route-up.d/90-hotspot +install -o root -g root -m 0755 ../conf/openvpn_90-hotspot /etc/openvpn/scripts/route-down.d/90-hotspot + #================================================= # SETUP SYSTEMD #=================================================