mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Merge pull request #106 from YunoHost-Apps/remove_openvpn_coupling
Remove/rework openvpn coupling
This commit is contained in:
commit
2c188a5789
7 changed files with 27 additions and 27 deletions
3
conf/openvpn_90-hotspot
Normal file
3
conf/openvpn_90-hotspot
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
systemctl restart ynh-hotspot
|
|
@ -20,10 +20,6 @@
|
||||||
# Functions
|
# Functions
|
||||||
## State functions
|
## State functions
|
||||||
|
|
||||||
has_vpnclient_app() {
|
|
||||||
[ -e /tmp/.ynh-vpnclient-started ]
|
|
||||||
}
|
|
||||||
|
|
||||||
has_ip6delegatedprefix() {
|
has_ip6delegatedprefix() {
|
||||||
local i=${1}
|
local i=${1}
|
||||||
|
|
||||||
|
@ -353,12 +349,6 @@ if [ "$1" != restart ]; then
|
||||||
old_gateway_interface=$(ynh_setting_get hotspot gateway_interface)
|
old_gateway_interface=$(ynh_setting_get hotspot gateway_interface)
|
||||||
new_gateway_interface=$(ip route get 1.2.3.4 | awk '{ print $5; }')
|
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"
|
echo "OK"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -459,11 +449,6 @@ stop)
|
||||||
echo "Stop hostapd"
|
echo "Stop hostapd"
|
||||||
stop_hostapd
|
stop_hostapd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fix configuration
|
|
||||||
if has_vpnclient_app; then
|
|
||||||
ynh-vpnclient start
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
$0 stop
|
$0 stop
|
||||||
|
|
|
@ -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="/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"
|
ynh_backup --src_path="/etc/init.d/hostapd"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -117,18 +117,6 @@ ynh_system_user_create --username=$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring hotspot..."
|
ynh_script_progression --message="Configuring hotspot..."
|
||||||
|
|
||||||
if [[ ! -v ip6_net ]]; then # if ip6_net not set
|
|
||||||
ip6_net=""
|
|
||||||
|
|
||||||
if [[ -e /tmp/.ynh-vpnclient-started ]]; then
|
|
||||||
vpnclient_ip6_net=$(ynh_app_setting_get vpnclient ip6_net 2>&1)
|
|
||||||
|
|
||||||
if [[ $vpnclient_ip6_net =~ :: ]]; then
|
|
||||||
ip6_net=${vpnclient_ip6_net}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
hot_reload_usb_wifi_cards
|
hot_reload_usb_wifi_cards
|
||||||
wifi_device=$(iw_devices | awk -F\| '{ print $1 }')
|
wifi_device=$(iw_devices | awk -F\| '{ print $1 }')
|
||||||
|
|
||||||
|
@ -165,6 +153,14 @@ install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq
|
||||||
# Copy init script
|
# Copy init script
|
||||||
install -o root -g root -m 0755 ../conf/$service_name /usr/local/bin/
|
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
|
# CONFIGURE HOSTAPD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -54,6 +54,9 @@ ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app main directory..."
|
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
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="/usr/local/bin/$service_name"
|
ynh_secure_remove --file="/usr/local/bin/$service_name"
|
||||||
|
|
||||||
|
|
|
@ -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="/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"
|
ynh_restore_file --origin_path="/etc/init.d/hostapd"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -141,6 +141,13 @@ install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq
|
||||||
# Copy init script
|
# Copy init script
|
||||||
install -o root -g root -m 0755 ../conf/$service_name /usr/local/bin/
|
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
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue