diff --git a/scripts/_common.sh b/scripts/_common.sh index a7f046f..13ceb53 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,6 +12,14 @@ free_firmware_packages="firmware-ath9k-htc" # PERSONAL HELPERS #================================================= +function other_hotspot_apps() +{ + local app_shortname="${app%%__*}" + local hotspot_apps=$(yunohost app list --output-as json | jq -r .apps[].id | grep -F $app_shortname) + # Remove this app from hotspot apps list + grep -F -x -v $app <<< ${hotspot_apps} +} + function iw_devices() { /sbin/iw dev | grep Interface | grep -v 'mon\.' | grep -v hotspot | awk '{ print $NF }' @@ -19,11 +27,7 @@ function iw_devices() function used_iw_devices() { - local app_shortname="${app%%__*}" - local hotspot_apps=$(yunohost app list --output-as json | jq -r .apps[].id | grep -F $app_shortname) - # Remove this app from hotspot apps list - local other_hotspot_apps=$(grep -F -x -v $app <<< ${hotspot_apps}) - for hotspot_app in ${other_hotspot_apps}; do + for hotspot_app in $(other_hotspot_apps); do hotspot_wifi_device=$(ynh_app_setting_get --app=$hotspot_app --key=wifi_device) if [[ -n "${hotspot_wifi_device}" ]]; then echo "${hotspot_wifi_device}" diff --git a/scripts/remove b/scripts/remove index e3f3ea5..7b3d158 100644 --- a/scripts/remove +++ b/scripts/remove @@ -58,8 +58,7 @@ ynh_secure_remove --file="/etc/openvpn/scripts/route-down.d/90-${service_name}" # Remove the app directory securely ynh_secure_remove --file="/usr/local/bin/$service_name" -for FILE in $(ls /tmp/.${service_name}-* 2>/dev/null) -do +for FILE in $(ls /tmp/.${service_name}-* 2>/dev/null); do ynh_secure_remove --file="$FILE" done @@ -74,17 +73,16 @@ ynh_secure_remove --file="/etc/hostapd/$app/" # CLOSE A PORT #================================================= -if yunohost firewall list | grep -q "\- 547$" -then - ynh_script_progression --message="Closing port 547" - ynh_exec_warn_less yunohost firewall disallow TCP 547 -fi +if [[ -z "$(other_hotspot_apps)" ]]; then + if yunohost firewall list | grep -q "\- 547$"; then + ynh_script_progression --message="Closing port 547" + ynh_exec_warn_less yunohost firewall disallow TCP 547 + fi - -if yunohost firewall list | grep -q "\- 67$" -then - ynh_script_progression --message="Closing port 67" - ynh_exec_warn_less yunohost firewall disallow TCP 67 + if yunohost firewall list | grep -q "\- 67$"; then + ynh_script_progression --message="Closing port 67" + ynh_exec_warn_less yunohost firewall disallow TCP 67 + fi fi #================================================= diff --git a/scripts/restore b/scripts/restore index af9c431..679bb30 100644 --- a/scripts/restore +++ b/scripts/restore @@ -36,6 +36,15 @@ wifi_device=$(ynh_app_setting_get --app=$app --key=wifi_device) #================================================= ynh_script_progression --message="Validating restoration parameters..." +#================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_script_progression --message="Configuring firewall..." + +# Update firewall for DHCP +ynh_exec_warn_less yunohost firewall allow --no-upnp --ipv6 UDP 547 +ynh_exec_warn_less yunohost firewall allow --no-upnp UDP 67 + # Meh idk where to put this ... On RPi, by default wlan is blocked if test -e /usr/sbin/rfkill && rfkill | grep wlan | grep -q -w 'blocked' then