From f55f11762529a81093853ad46d98bc3e4f88bef8 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 5 Oct 2023 18:26:41 +0200 Subject: [PATCH 1/9] Fix indent in _common.sh --- scripts/_common.sh | 90 +++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 13ceb53..6ca2179 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -14,31 +14,31 @@ free_firmware_packages="firmware-ath9k-htc" 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} + 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 }' + /sbin/iw dev | grep Interface | grep -v 'mon\.' | grep -v hotspot | awk '{ print $NF }' } function used_iw_devices() { - 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}" - fi - done + 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}" + fi + done } function unused_iw_devices() { - # Only prints devices that are not in the list of used devices - iw_devices | grep -F -v -f <(used_iw_devices) + # Only prints devices that are not in the list of used devices + iw_devices | grep -F -v -f <(used_iw_devices) } function check_armbian_nonfree_conflict() @@ -47,10 +47,10 @@ function check_armbian_nonfree_conflict() # If we're on armbian, force $firmware_nonfree # because armbian-firmware conflicts with firmware-misc-nonfree package if dpkg --list | grep -q armbian-firmware; then - echo "You are running Armbian and firmware-misc-nonfree are known to conflict with armbian-firwmare. " >&2 - echo "The package firmware-misc-nonfree is a dependency of firmware-ralink, so firmware-ralink will NOT be installed" >&2 - echo "You can manually install firmware-ralink with 'apt -o Dpkg::Options::=\"--force-overwrite\" firmware-ralink'" >&2 - nonfree_firmware_packages=$(echo $nonfree_firmware_packages | sed 's/ firmware-ralink//') + echo "You are running Armbian and firmware-misc-nonfree are known to conflict with armbian-firwmare. " >&2 + echo "The package firmware-misc-nonfree is a dependency of firmware-ralink, so firmware-ralink will NOT be installed" >&2 + echo "You can manually install firmware-ralink with 'apt -o Dpkg::Options::=\"--force-overwrite\" firmware-ralink'" >&2 + nonfree_firmware_packages=$(echo $nonfree_firmware_packages | sed 's/ firmware-ralink//') fi } @@ -58,50 +58,42 @@ function check_armbian_nonfree_conflict() function hot_reload_usb_wifi_cards() { - modulesList="acx-mac80211 ar5523 ar9170usb at76c50x-usb at76_usb ath9k_htc carl9170 orinoco_usb p54usb prism2_usb r8712u r8192s_usb r8192u_usb rndis_wlan rt2500usb rt2800usb rt2870sta rt73usb rtl8187 rtl8192cu usb8xxx vt6656_stage zd1201 zd1211rw" - modprobe --quiet --remove $modulesList || true - possibleUsbDevicesNeedingReload=$(dmesg | grep -Pio '(?<=usb )[0-9-]+(?=:.*firmware)' | sort | uniq) - for usbPath in $possibleUsbDevicesNeedingReload; do - if [[ -f "/sys/bus/usb/devices/$usbPath/authorized" ]]; then - echo "Try to reload driver for usb $usbPath" >&2 - echo 0 > /sys/bus/usb/devices/$usbPath/authorized - echo 1 > /sys/bus/usb/devices/$usbPath/authorized - # Wait for driver reloading - sleep 2 - fi - done + modulesList="acx-mac80211 ar5523 ar9170usb at76c50x-usb at76_usb ath9k_htc carl9170 orinoco_usb p54usb prism2_usb r8712u r8192s_usb r8192u_usb rndis_wlan rt2500usb rt2800usb rt2870sta rt73usb rtl8187 rtl8192cu usb8xxx vt6656_stage zd1201 zd1211rw" + modprobe --quiet --remove $modulesList || true + possibleUsbDevicesNeedingReload=$(dmesg | grep -Pio '(?<=usb )[0-9-]+(?=:.*firmware)' | sort | uniq) + for usbPath in $possibleUsbDevicesNeedingReload; do + if [[ -f "/sys/bus/usb/devices/$usbPath/authorized" ]]; then + echo "Try to reload driver for usb $usbPath" >&2 + echo 0 > /sys/bus/usb/devices/$usbPath/authorized + echo 1 > /sys/bus/usb/devices/$usbPath/authorized + # Wait for driver reloading + sleep 2 + fi + done } function configure_hostapd() { - if [[ "${wifi_secure}" -eq 1 ]]; then - sec_comment="" - else - sec_comment="#" - fi + if [[ "${wifi_secure}" -eq 1 ]]; then + sec_comment="" + else + sec_comment="#" + fi - ynh_add_config --template="/etc/hostapd/$app/hostapd.conf.tpl" --destination="/etc/hostapd/$app/hostapd.conf" + ynh_add_config --template="/etc/hostapd/$app/hostapd.conf.tpl" --destination="/etc/hostapd/$app/hostapd.conf" } function configure_dnsmasq() { - ynh_add_config --template="/etc/dnsmasq.$app/dnsmasq.conf.tpl" --destination="/etc/dnsmasq.d/$app.conf" - systemctl restart dnsmasq + ynh_add_config --template="/etc/dnsmasq.$app/dnsmasq.conf.tpl" --destination="/etc/dnsmasq.d/$app.conf" + systemctl restart dnsmasq } function configure_dhcp() { - ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv4.conf" + ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv4.conf" - if [[ -n "${ip6_net}" ]] && [[ "${ip6_net}" != "none" ]]; then - ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv6.conf" - fi + if [[ -n "${ip6_net}" ]] && [[ "${ip6_net}" != "none" ]]; then + ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv6.conf" + fi } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= From f40082a94c707f8ca1ddb08ee6c969d96b7885a3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 5 Oct 2023 18:44:05 +0200 Subject: [PATCH 2/9] yolo: we shouldn't need to add an app-specific conf for dnsmasq only to add 'interface=wlanX', it's already handled by the core, we just need to regen-conf dnsmasq when we start/stop the hotspot ? --- conf/dnsmasq.conf.tpl | 4 ---- conf/ynh-hotspot | 6 ++++++ scripts/_common.sh | 6 ------ scripts/backup | 1 - scripts/config | 1 - scripts/install | 6 ++---- scripts/restore | 4 ---- scripts/upgrade | 6 ++---- 8 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 conf/dnsmasq.conf.tpl diff --git a/conf/dnsmasq.conf.tpl b/conf/dnsmasq.conf.tpl deleted file mode 100644 index 7af2560..0000000 --- a/conf/dnsmasq.conf.tpl +++ /dev/null @@ -1,4 +0,0 @@ -# Wifi Hotspot app for YunoHost - -# Enable DNS resolution on wifi interface -interface=__WIFI_DEVICE__ diff --git a/conf/ynh-hotspot b/conf/ynh-hotspot index 0133dee..f190a78 100644 --- a/conf/ynh-hotspot +++ b/conf/ynh-hotspot @@ -296,6 +296,9 @@ start) # Update dynamic settings ynh_app_setting_set hotspot gateway_interface "${new_gateway_interface}" + + # Regen-conf dnsmasq to enable dns resolution on dnsmasq for the new interface + yunohost tools regen-conf dnsmasq ;; stop) echo "[hotspot] Stopping..." @@ -319,6 +322,9 @@ stop) echo "Stop hostapd" stop_hostapd fi + + # Regen-conf dnsmasq to disable dns resolution on dnsmasq for the previous interface + yunohost tools regen-conf dnsmasq ;; restart) $0 stop diff --git a/scripts/_common.sh b/scripts/_common.sh index 6ca2179..8d1c20d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -83,12 +83,6 @@ function configure_hostapd() ynh_add_config --template="/etc/hostapd/$app/hostapd.conf.tpl" --destination="/etc/hostapd/$app/hostapd.conf" } -function configure_dnsmasq() -{ - ynh_add_config --template="/etc/dnsmasq.$app/dnsmasq.conf.tpl" --destination="/etc/dnsmasq.d/$app.conf" - systemctl restart dnsmasq -} - function configure_dhcp() { ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv4.conf" diff --git a/scripts/backup b/scripts/backup index de71cba..a3dbd5e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -43,7 +43,6 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="/etc/hostapd/$app/hostapd.conf.tpl" ynh_backup --src_path="/etc/hostapd/$app/hostapd.conf" --not_mandatory -ynh_backup --src_path="/etc/dnsmasq.$app/dnsmasq.conf.tpl" ynh_backup --src_path="/etc/dnsmasq.d/$app.conf" --not_mandatory ynh_backup --src_path="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" diff --git a/scripts/config b/scripts/config index ff02211..1283d6b 100644 --- a/scripts/config +++ b/scripts/config @@ -205,7 +205,6 @@ ynh_app_config_apply() { if [[ "${service_enabled}" -eq 1 ]]; then configure_hostapd - configure_dnsmasq configure_dhcp # Start hotspot diff --git a/scripts/install b/scripts/install index 5f746d4..98588b2 100644 --- a/scripts/install +++ b/scripts/install @@ -162,7 +162,6 @@ mkdir -pm 0755 /etc/dnsmasq.$app/ chown root: /etc/dnsmasq.$app/ install -b -o root -g root -m 0644 ../conf/hostapd.conf.tpl /etc/hostapd/$app/hostapd.conf.tpl -install -b -o root -g root -m 0644 ../conf/dnsmasq.conf.tpl /etc/dnsmasq.$app/dnsmasq.conf.tpl install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.$app/dhcpdv6.conf.tpl install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.$app/dhcpdv4.conf.tpl @@ -192,9 +191,8 @@ systemctl stop hostapd 2>&1 systemctl unmask hostapd 2>&1 # On some system e.g. RPi, for some reason hostapd is masked after install ... if [[ -n "${wifi_device}" ]]; then - configure_hostapd - configure_dnsmasq - configure_dhcp + configure_hostapd + configure_dhcp fi #================================================= diff --git a/scripts/restore b/scripts/restore index 679bb30..7bfd49f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -74,10 +74,6 @@ fi ynh_restore_file --origin_path="/etc/hostapd/$app/hostapd.conf.tpl" ynh_restore_file --origin_path="/etc/hostapd/$app/hostapd.conf" --not_mandatory -ynh_restore_file --origin_path="/etc/dnsmasq.$app/dnsmasq.conf.tpl" -ynh_restore_file --origin_path="/etc/dnsmasq.d/$app.conf" --not_mandatory -systemctl restart dnsmasq - ynh_restore_file --origin_path="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" ynh_restore_file --origin_path="/etc/dnsmasq.$app/dhcpdv6.conf" --not_mandatory diff --git a/scripts/upgrade b/scripts/upgrade index 1d56a39..e3fdd59 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -214,14 +214,12 @@ mkdir -pm 0755 /etc/dnsmasq.$app/ chown root: /etc/dnsmasq.$app/ install -b -o root -g root -m 0644 ../conf/hostapd.conf.tpl /etc/hostapd/$app/hostapd.conf.tpl -install -b -o root -g root -m 0644 ../conf/dnsmasq.conf.tpl /etc/dnsmasq.$app/dnsmasq.conf.tpl install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.$app/dhcpdv6.conf.tpl install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.$app/dhcpdv4.conf.tpl if [[ -n "${wifi_device}" ]]; then - configure_hostapd - configure_dnsmasq - configure_dhcp + configure_hostapd + configure_dhcp fi # Copy init script From bdd92243419bc45116a1d9d4eb995c129fb391e2 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 5 Oct 2023 16:45:40 +0000 Subject: [PATCH 3/9] Auto-update README --- README.md | 1 - README_fr.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 7cd872e..7ce4f72 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Documentation and resources * Official app website: -* YunoHost documentation for this app: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index 8706e5d..d60ae7e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -29,7 +29,6 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Documentations et ressources * Site officiel de l’app : -* Documentation YunoHost pour cette app : * Signaler un bug : ## Informations pour les développeurs From 3a72871641a734870511629057f30cf1174574bd Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 5 Oct 2023 18:49:17 +0200 Subject: [PATCH 4/9] follow-up of previous commit : we probably need yunohost's lock to be able to trigger the regenconf from inside the service script --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 98588b2..8dfe28a 100644 --- a/scripts/install +++ b/scripts/install @@ -210,7 +210,7 @@ ynh_add_systemd_config --service="hostapd@$app" --template="../conf/systemd_host #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" +yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" --need_lock #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index 7bfd49f..807a336 100644 --- a/scripts/restore +++ b/scripts/restore @@ -108,7 +108,7 @@ ynh_restore_file --origin_path="/etc/systemd/system/hostapd@$app.service" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" +yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" --need_lock #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index e3fdd59..8826961 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -252,7 +252,7 @@ ynh_add_systemd_config --service="hostapd@$app" --template="../conf/systemd_host #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" +yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" --need_lock #================================================= # START SYSTEMD SERVICE From b80ee8b347bd0f723e7aa63574e4d30618cb605f Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 5 Oct 2023 19:00:56 +0200 Subject: [PATCH 5/9] Cleanup the whole stuff with .tpl file ... we don't need to copy them to intermediate locations, nor to backup/restore them... --- conf/{dnsmasq_dhcpdv4.conf.tpl => dnsmasq_dhcpdv4.conf} | 0 conf/{dnsmasq_dhcpdv6.conf.tpl => dnsmasq_dhcpdv6.conf} | 0 conf/{hostapd.conf.tpl => hostapd.conf} | 0 scripts/_common.sh | 6 +++--- scripts/backup | 7 ------- scripts/install | 4 ---- scripts/restore | 5 ----- scripts/upgrade | 4 ---- 8 files changed, 3 insertions(+), 23 deletions(-) rename conf/{dnsmasq_dhcpdv4.conf.tpl => dnsmasq_dhcpdv4.conf} (100%) rename conf/{dnsmasq_dhcpdv6.conf.tpl => dnsmasq_dhcpdv6.conf} (100%) rename conf/{hostapd.conf.tpl => hostapd.conf} (100%) diff --git a/conf/dnsmasq_dhcpdv4.conf.tpl b/conf/dnsmasq_dhcpdv4.conf similarity index 100% rename from conf/dnsmasq_dhcpdv4.conf.tpl rename to conf/dnsmasq_dhcpdv4.conf diff --git a/conf/dnsmasq_dhcpdv6.conf.tpl b/conf/dnsmasq_dhcpdv6.conf similarity index 100% rename from conf/dnsmasq_dhcpdv6.conf.tpl rename to conf/dnsmasq_dhcpdv6.conf diff --git a/conf/hostapd.conf.tpl b/conf/hostapd.conf similarity index 100% rename from conf/hostapd.conf.tpl rename to conf/hostapd.conf diff --git a/scripts/_common.sh b/scripts/_common.sh index 8d1c20d..c67cc0e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -80,14 +80,14 @@ function configure_hostapd() sec_comment="#" fi - ynh_add_config --template="/etc/hostapd/$app/hostapd.conf.tpl" --destination="/etc/hostapd/$app/hostapd.conf" + ynh_add_config --template="../conf/hostapd.conf" --destination="/etc/hostapd/$app/hostapd.conf" } function configure_dhcp() { - ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv4.conf" + ynh_add_config --template="../conf/dhcpdv4.conf" --destination="/etc/dnsmasq.$app/dhcpdv4.conf" if [[ -n "${ip6_net}" ]] && [[ "${ip6_net}" != "none" ]]; then - ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv6.conf" + ynh_add_config --template="../conf/dhcpdv6.conf" --destination="/etc/dnsmasq.$app/dhcpdv6.conf" fi } diff --git a/scripts/backup b/scripts/backup index a3dbd5e..ce94889 100644 --- a/scripts/backup +++ b/scripts/backup @@ -40,15 +40,8 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="/etc/hostapd/$app/hostapd.conf.tpl" ynh_backup --src_path="/etc/hostapd/$app/hostapd.conf" --not_mandatory - -ynh_backup --src_path="/etc/dnsmasq.d/$app.conf" --not_mandatory - -ynh_backup --src_path="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" ynh_backup --src_path="/etc/dnsmasq.$app/dhcpdv6.conf" --not_mandatory - -ynh_backup --src_path="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" ynh_backup --src_path="/etc/dnsmasq.$app/dhcpdv4.conf" --not_mandatory ynh_backup --src_path="/usr/local/bin/$service_name" diff --git a/scripts/install b/scripts/install index 8dfe28a..ff45235 100644 --- a/scripts/install +++ b/scripts/install @@ -161,10 +161,6 @@ chown root: /etc/hostapd/$app/ mkdir -pm 0755 /etc/dnsmasq.$app/ chown root: /etc/dnsmasq.$app/ -install -b -o root -g root -m 0644 ../conf/hostapd.conf.tpl /etc/hostapd/$app/hostapd.conf.tpl -install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.$app/dhcpdv6.conf.tpl -install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.$app/dhcpdv4.conf.tpl - # Copy init script ynh_add_config --template="../conf/ynh-hotspot" --destination="/usr/local/bin/$service_name" chmod 0755 "/usr/local/bin/$service_name" diff --git a/scripts/restore b/scripts/restore index 807a336..8510bc7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,13 +71,8 @@ else pkg_dependencies="$pkg_dependencies $free_firmware_packages" fi -ynh_restore_file --origin_path="/etc/hostapd/$app/hostapd.conf.tpl" ynh_restore_file --origin_path="/etc/hostapd/$app/hostapd.conf" --not_mandatory - -ynh_restore_file --origin_path="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" ynh_restore_file --origin_path="/etc/dnsmasq.$app/dhcpdv6.conf" --not_mandatory - -ynh_restore_file --origin_path="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" ynh_restore_file --origin_path="/etc/dnsmasq.$app/dhcpdv4.conf" --not_mandatory ynh_restore_file --origin_path="/usr/local/bin/$service_name" diff --git a/scripts/upgrade b/scripts/upgrade index 8826961..a64ab4d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -213,10 +213,6 @@ chown root: /etc/hostapd/$app/ mkdir -pm 0755 /etc/dnsmasq.$app/ chown root: /etc/dnsmasq.$app/ -install -b -o root -g root -m 0644 ../conf/hostapd.conf.tpl /etc/hostapd/$app/hostapd.conf.tpl -install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.$app/dhcpdv6.conf.tpl -install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.$app/dhcpdv4.conf.tpl - if [[ -n "${wifi_device}" ]]; then configure_hostapd configure_dhcp From 3e2bd872ce3b16e0c71c6d31c36eef0468da30eb Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 5 Oct 2023 19:05:13 +0200 Subject: [PATCH 6/9] Cleanup/propagate stuff to config panel controller as well --- scripts/config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/config b/scripts/config index 1283d6b..ad92a84 100644 --- a/scripts/config +++ b/scripts/config @@ -213,12 +213,13 @@ ynh_app_config_apply() { else ynh_print_info --message="Cleanup hotspot config files" ynh_secure_remove --file="/etc/hostapd/$app/hostapd.conf" - ynh_secure_remove --file="/etc/dnsmasq.d/$app.conf" ynh_secure_remove --file="/etc/dnsmasq.$app/dhcpdv4.conf" ynh_secure_remove --file="/etc/dnsmasq.$app/dhcpdv6.conf" systemctl restart dnsmasq fi + + yunohost tools regen-conf dnsmasq } ynh_app_config_run $1 From 8449fc5ac8d0d7b998626e1b5d24b85b04532088 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 5 Oct 2023 19:08:51 +0200 Subject: [PATCH 7/9] Delete boring legacy /etc/dnsmasq.d/$app.conf if it exists --- scripts/upgrade | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index a64ab4d..42929db 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -70,6 +70,9 @@ if [ -d /var/www/wifiadmin/ ]; then ynh_secure_remove /var/www/wifiadmin/ fi +if [ -e /etc/dnsmasq.d/$app.conf ]; then + ynh_secure_remove /etc/dnsmasq.d/$app.conf +fi if [ $firmware_nonfree = "yes" ]; then firmware_nonfree=1 From cf03447866ec0c575ee1e2e305d43d3a5bdcf900 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 5 Oct 2023 19:27:55 +0200 Subject: [PATCH 8/9] Oopsies --- scripts/_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c67cc0e..942715a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -85,9 +85,9 @@ function configure_hostapd() function configure_dhcp() { - ynh_add_config --template="../conf/dhcpdv4.conf" --destination="/etc/dnsmasq.$app/dhcpdv4.conf" + ynh_add_config --template="../conf/dnsmasq_dhcpdv4.conf" --destination="/etc/dnsmasq.$app/dhcpdv4.conf" if [[ -n "${ip6_net}" ]] && [[ "${ip6_net}" != "none" ]]; then - ynh_add_config --template="../conf/dhcpdv6.conf" --destination="/etc/dnsmasq.$app/dhcpdv6.conf" + ynh_add_config --template="../conf/dnsmasq_dhcpdv6.conf" --destination="/etc/dnsmasq.$app/dhcpdv6.conf" fi } From 1d9844f997d30a4b05c7e8916e3bb0c829c01dd3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 5 Oct 2023 20:34:32 +0200 Subject: [PATCH 9/9] Use 'yunohost service start' instead of 'ynh_systemd_action' such that yunohost properly gives the lock to the 'yunohost tools regen-conf' inside the service --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index ff45235..13640b1 100644 --- a/scripts/install +++ b/scripts/install @@ -217,7 +217,7 @@ ynh_script_progression --message="Starting a systemd service..." if [[ $wifi_device == "" ]]; then echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 else - ynh_systemd_action --service_name=$service_name --action="start" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" + yunohost service start $service_name fi #================================================= diff --git a/scripts/restore b/scripts/restore index 8510bc7..8232152 100644 --- a/scripts/restore +++ b/scripts/restore @@ -126,7 +126,7 @@ fi if [[ $wifi_device == "" ]]; then echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 else - ynh_systemd_action --service_name=$service_name --action="start" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" + yunohost service start $service_name fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 42929db..3d3ecbd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,8 +58,7 @@ ynh_abort_if_errors # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping the hotspot service ... (this may take some time)" - -ynh_systemd_action --service_name=$service_name --action="stop" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" +yunohost service stop $service_name #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -269,7 +268,7 @@ fi if [[ $wifi_device == "" ]]; then echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 else - ynh_systemd_action --service_name=$service_name --action="start" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" + yunohost service start $service_name fi #=================================================