mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
add checks before closing dhcp ports
This commit is contained in:
parent
5d7a9ca16e
commit
92876e023e
3 changed files with 28 additions and 17 deletions
|
@ -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}"
|
||||
|
|
|
@ -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
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue