From ddb932408407c36342e6fdb01beb4d51a21dd845 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 6 Oct 2023 18:36:24 +0200 Subject: [PATCH 01/15] Yolo packaging v2 --- doc/PRE_INSTALL.md | 1 + doc/PRE_INSTALL_fr.md | 1 + manifest.json | 66 ------------------------ manifest.toml | 73 ++++++++++++++++++++++++++ scripts/_common.sh | 26 ---------- scripts/backup | 27 ---------- scripts/config | 6 --- scripts/install | 83 ++++-------------------------- scripts/remove | 44 +--------------- scripts/restore | 71 +++----------------------- scripts/upgrade | 116 ++++++++---------------------------------- 11 files changed, 111 insertions(+), 403 deletions(-) create mode 100644 doc/PRE_INSTALL.md create mode 100644 doc/PRE_INSTALL_fr.md delete mode 100644 manifest.json create mode 100644 manifest.toml diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..1b77a3b --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1 @@ +After the installation, you will be able to configure the application from YunoHost's webadmin in Applications > Hotspot > Configuration. diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md new file mode 100644 index 0000000..e210e68 --- /dev/null +++ b/doc/PRE_INSTALL_fr.md @@ -0,0 +1 @@ +Après l'application, vous pourrez configurer l'application depuis la webadmin de YunoHost dans Applications > Hotspot > Configuration. diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 369f0f2..0000000 --- a/manifest.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "Wifi Hotspot", - "id": "hotspot", - "packaging_format": 1, - "description": { - "en": "Create and manager wifi networks, share Internet access and use YunoHost apps accross wifi", - "fr": "Créer et configurer des réseaux wifi, partager l'accès a Internet et utiliser les applications YunoHost via wifi" - }, - "version": "2.2.0~ynh1", - "url": "https://github.com/labriqueinternet/hotspot_ynh", - "license": "AGPL-3.0", - "maintainer": { - "name": "Julien Vaubourg", - "email": "julien@vaubourg.com", - "url": "http://julien.vaubourg.com" - }, - "upstream": { - "license": "AGPL-3.0", - "website": "https://internetcu.be/" - }, - "requirements": { - "yunohost": ">= 4.3.2" - }, - "multi_instance": true, - "services": [], - "arguments": { - "install" : [ - { - "name": "disclaimer", - "type": "display_text", - "style": "info", - "ask": { - "en": "After installation, you will be able to configure the application from YunoHost's webadmin in Applications > Hotspot > Configuration.", - "fr": "Après l'application, vous pourrez configurer l'application depuis la webadmin de YunoHost dans Applications > Hotspot > Configuration." - } - }, - { - "name": "wifi_ssid", - "type": "string", - "ask": { - "en": "Choose a wifi name (SSID)", - "fr": "Choisissez un nom pour le wifi (SSID)" - }, - "example": "myNeutralNetwork", - "default": "myNeutralNetwork" - }, - { - "name": "wifi_passphrase", - "type": "password", - "ask": { - "en": "Choose a wifi password (at least 8 characters for WPA2)", - "fr": "Choisissez un mot de passe wifi (au minimum 8 caractères pour le WPA2)" - } - }, - { - "name": "firmware_nonfree", - "type": "boolean", - "ask": { - "en": "Install non-free WiFi firmwares? (Only needed if you're using a proprietary WiFi antenna/dongle)", - "fr": "Installer des firmwares WiFi non-libres ? (Nécessaire seulement si vous utilisez une antenne/clé WiFi propriétaire)" - }, - "default": false - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..95d1d72 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,73 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "hotspot" +name = "Wifi Hotspot" +description.en = "Create and configure a WiFi hotspot" +description.fr = "Créez et gérez un point d'accès WiFi" + +version = "2.3.0~ynh1" + +maintainers = [] + +[upstream] +license = "AGPL-3.0" +website = "https://internetcu.be/" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = true +ldap = "not_relevant" +sso = "not_relevant" +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + [install.wifi_ssid] + ask.en = "Choose a wifi name (SSID)" + ask.fr = "Choisissez un nom pour le wifi (SSID)" + type = "string" + example = "myNeutralNetwork" + default = "myNeutralNetwork" + + [install.wifi_passphrase] + ask.en = "Choose a wifi password (at least 8 characters for WPA2)" + ask.fr = "Choisissez un mot de passe wifi (au minimum 8 caractères pour le WPA2)" + type = "password" + + [install.firmware_nonfree] + ask.en = "Install non-free WiFi firmwares? (Only needed if you're using a proprietary WiFi antenna/dongle)" + ask.fr = "Installer des firmwares WiFi non-libres ? (Nécessaire seulement si vous utilisez une antenne/clé WiFi propriétaire)" + type = "boolean" + default = false + +[resources] + [resources.system_user] + + [resources.apt] + packages = "sipcalc, hostapd, iw, kmod" + +# ========================================= +# FIXME FIXME FIXME FIXME FIXME FIXME FIXME +# Gotta find a way to conditionally install the non-free packages +# So far the "packages_from_raw_bash" thing doesnt allow conditional packages from extra repo (here, the non-free component..) +# FIXME FIXME FIXME FIXME FIXME FIXME FIXME +# ========================================= +# +# # Packaged USB Wireless Device firmwares +# # Based on https://wiki.debian.org/WiFi#USB_Devices +# if [[ $firmware_nonfree -eq 1 ]]; then +# # FIXME : if armbian-firmware is detected, we should remove ra-link.... +# #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//') +# #fi +# echo "firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware firmware-zd1211" +# else +# echo "firmware-ath9k-htc" +# fi diff --git a/scripts/_common.sh b/scripts/_common.sh index 942715a..6d440ed 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,5 @@ #!/bin/bash -#================================================= -# COMMON VARIABLES -#================================================= - -pkg_dependencies="sipcalc hostapd iw kmod" -nonfree_firmware_packages="firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware firmware-zd1211" -free_firmware_packages="firmware-ath9k-htc" - -#================================================= -# PERSONAL HELPERS -#================================================= - function other_hotspot_apps() { local app_shortname="${app%%__*}" @@ -41,20 +29,6 @@ function unused_iw_devices() iw_devices | grep -F -v -f <(used_iw_devices) } -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//') - fi - -} - function hot_reload_usb_wifi_cards() { diff --git a/scripts/backup b/scripts/backup index ce94889..d01e26d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,27 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -firmware_nonfree=$(ynh_app_setting_get --app=$app --key=firmware_nonfree) -service_name=$(ynh_app_setting_get --app=$app --key=service_name) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -49,12 +28,6 @@ ynh_backup --src_path="/usr/local/bin/$service_name" ynh_backup --src_path="/etc/openvpn/scripts/route-up.d/90-$service_name" ynh_backup --src_path="/etc/openvpn/scripts/route-down.d/90-$service_name" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup --src_path="/etc/systemd/system/$service_name.service" ynh_backup --src_path="/etc/systemd/system/hostapd@$app.service" diff --git a/scripts/config b/scripts/config index ad92a84..c353476 100644 --- a/scripts/config +++ b/scripts/config @@ -16,12 +16,6 @@ source /usr/share/yunohost/helpers # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -final_path=$(ynh_app_setting_get $app final_path) - #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= diff --git a/scripts/install b/scripts/install index 13640b1..b3335cf 100644 --- a/scripts/install +++ b/scripts/install @@ -9,32 +9,14 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -wifi_ssid=$YNH_APP_ARG_WIFI_SSID -wifi_passphrase=$YNH_APP_ARG_WIFI_PASSPHRASE -firmware_nonfree=$YNH_APP_ARG_FIRMWARE_NONFREE - -app=$YNH_APP_INSTANCE_NAME - -# the service name must match the service template files service_name=ynh-$app +ynh_app_setting_set --app=$app --key=service_name --value=$service_name #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= + +# FIXME : we could probably implement all these checks in manifest.toml directly ? ynh_script_progression --message="Validating installation parameters..." # Check arguments @@ -45,7 +27,7 @@ fi # Check passphrase length wifi_passphrase_length="$(wc -c <<< "${wifi_passphrase}")" if [[ $wifi_passphrase_length -lt 8 ]] || [[ $wifi_passphrase_length -gt 63 ]]; then - ynh_die --message="Your password must from 8 to 63 characters (WPA2 passphrase)" + ynh_die --message="Your password must have between 8 and 63 characters (WPA2 passphrase)" fi # Check no special characters are present in the passphrase @@ -53,16 +35,6 @@ if [[ $wifi_passphrase =~ [^[:print:]] ]]; then ynh_die --message="Only printable ASCII characters are permitted in your password (WPA2 passphrase)" fi -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." - -ynh_app_setting_set --app=$app --key=wifi_ssid --value="$wifi_ssid" -ynh_app_setting_set --app=$app --key=wifi_passphrase --value="$wifi_passphrase" -ynh_app_setting_set --app=$app --key=firmware_nonfree --value="$firmware_nonfree" -ynh_app_setting_set --app=$app --key=service_name --value=$service_name - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -71,6 +43,7 @@ ynh_app_setting_set --app=$app --key=service_name --value=$service_name ynh_script_progression --message="Configuring firewall..." # Update firewall for DHCP +# FIXME : move to manifest.toml ynh_exec_warn_less yunohost firewall allow --no-upnp --ipv6 UDP 547 ynh_exec_warn_less yunohost firewall allow --no-upnp UDP 67 @@ -81,37 +54,6 @@ then /usr/sbin/rfkill unblock wlan fi -#================================================= -# INSTALL NONFREE FIRWARE IF REQUESTED -#================================================= -ynh_script_progression --message="Installing firmware..." - -export DEBIAN_FRONTEND=noninteractive - -# Packaged USB Wireless Device firmwares -# Based on https://wiki.debian.org/WiFi#USB_Devices -if [[ $firmware_nonfree -eq 1 ]]; then - check_armbian_nonfree_conflict - ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" -else - pkg_dependencies="$pkg_dependencies $free_firmware_packages" -fi - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # SPECIFIC SETTINGS #================================================= @@ -132,9 +74,7 @@ wifi_device=$(unused_iw_devices | head -n 1) wifi_secure=1 wifi_channel=6 -ynh_app_setting_set --app=$app --key=wifi_ssid --value="${wifi_ssid}" ynh_app_setting_set --app=$app --key=wifi_secure --value="${wifi_secure}" -ynh_app_setting_set --app=$app --key=wifi_passphrase --value="${wifi_passphrase}" ynh_app_setting_set --app=$app --key=wifi_device --value="${wifi_device}" ynh_app_setting_set --app=$app --key=wifi_channel --value="${wifi_channel}" ynh_app_setting_set --app=$app --key=advanced --value=0 @@ -144,7 +84,7 @@ ynh_app_setting_set --app=$app --key=ip6_dns --value="${ip6_dns}" ynh_app_setting_set --app=$app --key=ip4_dns --value="${ip4_dns}" ynh_app_setting_set --app=$app --key=ip4_nat_prefix --value="${ip4_nat_prefix}" -if [[ -z $wifi_device ]]; then +if [[ -z "$wifi_device" ]]; then ynh_app_setting_set --app=$app --key=service_enabled --value=0 else ynh_app_setting_set --app=$app --key=service_enabled --value=1 @@ -194,28 +134,23 @@ fi #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring systemd service..." # Create a dedicated systemd config ynh_add_systemd_config --service=$service_name # Create custom systemd config for hostapd to handle multiple wifi devices ynh_add_systemd_config --service="hostapd@$app" --template="../conf/systemd_hostapd.service" -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -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" --need_lock #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting the hotspot..." # Start a systemd service if device is present if [[ $wifi_device == "" ]]; then - echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 + echo "WARNING: Wifi Hotspot is not started because no wifi device was found (check the Hotspot configuration in the webadmin > Applications > Hotspot > the config panel)" >&2 else yunohost service start $service_name fi diff --git a/scripts/remove b/scripts/remove index 7b3d158..edaa762 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,16 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -firmware_nonfree=$(ynh_app_setting_get --app=$app --key=firmware_nonfree) -service_name=$(ynh_app_setting_get --app=$app --key=service_name) - #================================================= # STANDARD REMOVE #================================================= @@ -30,32 +20,16 @@ ynh_script_progression --message="Removing $app service" yunohost service stop $service_name yunohost service remove $service_name -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." - -# Remove the dedicated systemd config ynh_remove_systemd_config --service=$service_name ynh_remove_systemd_config --service="hostapd@$app" -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +ynh_script_progression --message="Removing $app configurations..." ynh_secure_remove --file="/etc/openvpn/scripts/route-up.d/90-${service_name}" 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 @@ -84,19 +58,3 @@ if [[ -z "$(other_hotspot_apps)" ]]; then ynh_exec_warn_less yunohost firewall disallow TCP 67 fi fi - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -ynh_system_user_delete --username=$app - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 8232152..4d93dce 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,32 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -firmware_nonfree=$(ynh_app_setting_get --app=$app --key=firmware_nonfree) -service_name=$(ynh_app_setting_get --app=$app --key=service_name) -wifi_device=$(ynh_app_setting_get --app=$app --key=wifi_device) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." - #================================================= # FIND AND OPEN A PORT #================================================= @@ -55,21 +29,8 @@ fi #================================================= # STANDARD RESTORATION STEPS #================================================= -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - - -if [[ $firmware_nonfree -eq 1 ]]; then - check_armbian_nonfree_conflict - ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" -else - pkg_dependencies="$pkg_dependencies $free_firmware_packages" -fi +ynh_script_progression --message="Restoring configurations ..." ynh_restore_file --origin_path="/etc/hostapd/$app/hostapd.conf" --not_mandatory ynh_restore_file --origin_path="/etc/dnsmasq.$app/dhcpdv6.conf" --not_mandatory @@ -80,50 +41,30 @@ ynh_restore_file --origin_path="/usr/local/bin/$service_name" ynh_restore_file --origin_path="/etc/openvpn/scripts/route-up.d/90-${service_name}" ynh_restore_file --origin_path="/etc/openvpn/scripts/route-down.d/90-${service_name}" -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." - ynh_restore_file --origin_path="/etc/systemd/system/$service_name.service" ynh_restore_file --origin_path="/etc/systemd/system/hostapd@$app.service" -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -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" --need_lock +yunohost service add "$service_name" --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" --need_lock #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting the hotspot service..." hot_reload_usb_wifi_cards -if [[ -z "$wifi_device" ]] || ! grep -q -F "$wifi_device" <(unused_iw_devices); then +if [[ -z "${wifi_device:-}" ]] || ! grep -q -F "$wifi_device" <(unused_iw_devices); then wifi_device=$(unused_iw_devices | head -n 1) ynh_app_setting_set --app=$app --key=wifi_device --value="${wifi_device}" fi -if [[ -z $wifi_device ]]; then +if [[ -z "${wifi_device:-}" ]]; then ynh_app_setting_set --app=$app --key=service_enabled --value=0 else ynh_app_setting_set --app=$app --key=service_enabled --value=1 fi # Start a systemd service if device is present -if [[ $wifi_device == "" ]]; then +if [[ "${wifi_device:-}" == "" ]]; then echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 else yunohost service start $service_name diff --git a/scripts/upgrade b/scripts/upgrade index 3d3ecbd..7b14ae9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,49 +9,8 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -firmware_nonfree=$(ynh_app_setting_get --app=$app --key=firmware_nonfree) -service_name=$(ynh_app_setting_get --app=$app --key=service_name) - -wifi_device=$(ynh_app_setting_get --app=$app --key=wifi_device) -wifi_ssid=$(ynh_app_setting_get --app=$app --key=wifi_ssid) -wifi_secure=$(ynh_app_setting_get --app=$app --key=wifi_secure) -wifi_passphrase=$(ynh_app_setting_get --app=$app --key=wifi_passphrase) -wifi_channel=$(ynh_app_setting_get --app=$app --key=wifi_channel) -advanced=$(ynh_app_setting_get --app=$app --key=advanced) -ip4_nat_prefix=$(ynh_app_setting_get --app=$app --key=ip4_nat_prefix) -ip6_net=$(ynh_app_setting_get --app=$app --key=ip6_net) -ip6_firewall=$(ynh_app_setting_get --app=$app --key=ip6_firewall) -dns=$(ynh_app_setting_get --app=$app --key=dns) -multissid=$(ynh_app_setting_get --app=$app --key=multissid) - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." - upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -73,20 +32,20 @@ if [ -e /etc/dnsmasq.d/$app.conf ]; then ynh_secure_remove /etc/dnsmasq.d/$app.conf fi -if [ $firmware_nonfree = "yes" ]; then +if [ ${firmware_nonfree:-} = "yes" ]; then firmware_nonfree=1 ynh_app_setting_set --app=$app --key=firmware_nonfree --value=$firmware_nonfree -elif [ $firmware_nonfree = "no" ]; then +elif [ ${firmware_nonfree:-} = "no" ]; then firmware_nonfree=0 ynh_app_setting_set --app=$app --key=firmware_nonfree --value=$firmware_nonfree fi -if [ -z $service_name ]; then +if [ -z ${service_name:-} ]; then service_name="ynh-$app" ynh_app_setting_set --app=$app --key=service_name --value=$service_name fi -if [[ -n "${multissid}" ]] && [[ "${multissid}" -gt 1 ]]; then +if [[ -n "${multissid:-}" ]] && [[ "${multissid}" -gt 1 ]]; then wifi_ssid=$(cut -d'|' -f 1 <<< ${wifi_ssid}) wifi_secure=$(cut -d'|' -f 1 <<< ${wifi_secure}) wifi_passphrase=$(cut -d'|' -f 1 <<< ${wifi_passphrase}) @@ -104,7 +63,7 @@ if [[ -n "${multissid}" ]] && [[ "${multissid}" -gt 1 ]]; then ynh_app_setting_set --app=$app --key=ip6_firewall --value="${ip6_firewall}" fi -if [[ -n "${dns}" ]]; then +if [[ -n "${dns:-}" ]]; then ip6_dns="" ip4_dns="" for ip in $(echo "${dns}" | tr ',' ' '); do @@ -118,20 +77,17 @@ if [[ -n "${dns}" ]]; then ip6_dns="${ip6_dns%%,}" ip4_dns="${ip4_dns%%,}" - if [[ -z "$(ynh_app_setting_get --app=$app --key=ip6_dns)" ]]; then + if [[ -z "$(ynh_app_setting_get --app=$app --key=ip6_dns)" ]]; then ynh_app_setting_set --app=$app --key=ip6_dns --value="${ip6_dns}" fi - if [[ -z "$(ynh_app_setting_get --app=$app --key=ip4_dns)" ]]; then + if [[ -z "$(ynh_app_setting_get --app=$app --key=ip4_dns)" ]]; then ynh_app_setting_set --app=$app --key=ip4_dns --value="${ip4_dns}" fi ynh_app_setting_delete $app dns -else - ip6_dns=$(ynh_app_setting_get --app=$app --key=ip6_dns) - ip4_dns=$(ynh_app_setting_get --app=$app --key=ip4_dns) fi -if [[ -n "${multissid}" ]]; then +if [[ -n "${multissid:-}" ]]; then ynh_app_setting_delete --app=$app --key=multissid ynh_secure_remove --file="/etc/hostapd/hostapd.conf" @@ -140,14 +96,13 @@ if [[ -n "${multissid}" ]]; then ynh_secure_remove --file="/etc/dnsmasq.dhcpd/" fi -if [[ -z "${advanced}" ]]; then +if [[ -z "${advanced:-}" ]]; then ynh_app_setting_set --app=$app --key=advanced --value=0 fi # Old stuff prior to 2.x -ip6_net=$(ynh_app_setting_get --app=$app --key=ip6_net) -if [ "$ip6_net" == "none" ] +if [ "${ip6_net:-}" == "none" ] then ip6_net="" ynh_app_setting_set --app=$app --key=ip6_net --value="$ip6_net" @@ -166,36 +121,14 @@ if [ -d /var/www/$app ]; then ynh_secure_remove /var/www/$app fi -[ -z "$(ynh_app_setting_get $app domain)" ] || ynh_app_setting_delete $app domain -[ -z "$(ynh_app_setting_get $app path)" ] || ynh_app_setting_delete $app path -[ -z "$(ynh_app_setting_get $app final_path)" ] || ynh_app_setting_delete $app final_path +[ -z "${domain:-}" ] || ynh_app_setting_delete $app domain +[ -z "${path:-}" ] || ynh_app_setting_delete $app path +[ -z "${install_dir:-}" ] || ynh_app_setting_delete $app install_dir if [ -e "/etc/sudoers.d/${app}_ynh" ]; then ynh_secure_remove "/etc/sudoers.d/${app}_ynh" fi -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." - -if [[ $firmware_nonfree -eq 1 ]]; then - check_armbian_nonfree_conflict - ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" -else - pkg_dependencies="$pkg_dependencies $free_firmware_packages" -fi - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # SPECIFIC UPGRADE #================================================= @@ -204,6 +137,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Copying configuration..." hot_reload_usb_wifi_cards + if [[ -z "$wifi_device" ]] || ! grep -q -F "$wifi_device" <(unused_iw_devices); then wifi_device="$(unused_iw_devices | head -n 1)" ynh_app_setting_set --app=$app --key=wifi_device --value="${wifi_device}" @@ -215,9 +149,13 @@ chown root: /etc/hostapd/$app/ mkdir -pm 0755 /etc/dnsmasq.$app/ chown root: /etc/dnsmasq.$app/ -if [[ -n "${wifi_device}" ]]; then +if [[ -n "${wifi_device:-}" ]]; then configure_hostapd configure_dhcp + ynh_app_setting_set --app=$app --key=service_enabled --value=1 +else + ynh_app_setting_set --app=$app --key=service_enabled --value=0 + wifi_device="" fi # Copy init script @@ -243,13 +181,6 @@ ynh_add_systemd_config --service=$service_name # Create custom systemd config for hostapd to handle multiple wifi devices ynh_add_systemd_config --service="hostapd@$app" --template="../conf/systemd_hostapd.service" -#================================================= -# GENERIC FINALIZATION -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -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" --need_lock #================================================= @@ -257,16 +188,9 @@ yunohost service add $service_name --description "Creates a Wi-Fi access point" #================================================= ynh_script_progression --message="Starting the hotspot service..." -if [[ -z $wifi_device ]]; then - ynh_app_setting_set --app=$app --key=service_enabled --value=0 - wifi_device="" -else - ynh_app_setting_set --app=$app --key=service_enabled --value=1 -fi - # Start a systemd service if device is present if [[ $wifi_device == "" ]]; then - echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 + echo "WARNING: Wifi Hotspot is not started because no wifi device was found (check the Hotspot configuration in the webadmin > Applications > Hotspot > the config panel)" >&2 else yunohost service start $service_name fi From 3849c69b41e3f27ecc28ada498e6e81480fc5a3d Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 6 Oct 2023 16:36:36 +0000 Subject: [PATCH 02/15] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d13490b..98af644 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in * Combine with the [VPN Client app](https://github.com/labriqueinternet/vpnclient_ynh) to obtain a VPN-protected WiFi -**Shipped version:** 2.2.0~ynh1 +**Shipped version:** 2.3.0~ynh1 ## Screenshots diff --git a/README_fr.md b/README_fr.md index af0814d..fbfc54b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -20,7 +20,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po * À combiner avec l'[app VPN Client](https://github.com/labriqueinternet/vpnclient_ynh) pour obtenir un accès internet aumatiquement protégé par votre VPN -**Version incluse :** 2.2.0~ynh1 +**Version incluse :** 2.3.0~ynh1 ## Captures d’écran From f53168da30c6e23669336a4e7ff42475ee660404 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Mon, 27 Nov 2023 14:45:26 +0100 Subject: [PATCH 03/15] manifest: implement conditional inclusion of non-free firmwares --- manifest.toml | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/manifest.toml b/manifest.toml index 95d1d72..27f4a7b 100644 --- a/manifest.toml +++ b/manifest.toml @@ -49,25 +49,22 @@ ram.runtime = "50M" [resources.apt] packages = "sipcalc, hostapd, iw, kmod" + packages_from_raw_bash = """ + # Free firmwares + [[ "$firmware_nonfree" -eq 0 ]] && echo "firmware-ath9k-htc" || true + """ -# ========================================= -# FIXME FIXME FIXME FIXME FIXME FIXME FIXME -# Gotta find a way to conditionally install the non-free packages -# So far the "packages_from_raw_bash" thing doesnt allow conditional packages from extra repo (here, the non-free component..) -# FIXME FIXME FIXME FIXME FIXME FIXME FIXME -# ========================================= -# -# # Packaged USB Wireless Device firmwares -# # Based on https://wiki.debian.org/WiFi#USB_Devices -# if [[ $firmware_nonfree -eq 1 ]]; then -# # FIXME : if armbian-firmware is detected, we should remove ra-link.... -# #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//') -# #fi -# echo "firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware firmware-zd1211" -# else -# echo "firmware-ath9k-htc" -# fi + extras.nonfree.repo = "deb http://deb.debian.org/debian bullseye non-free" + extras.nonfree.key = "https://ftp-master.debian.org/keys/archive-key-11.asc" + extras.nonfree.packages_from_raw_bash = """ + # Proprietary USB Wireless Device firmwares, based on https://wiki.debian.org/WiFi#USB_Devices + if [[ "$firmware_nonfree" -eq 1 ]]; then + # if armbian-firmware is detected, we dont include ra-link which is known to conflict.... + if dpkg --list | grep -q armbian-firmware; then + echo "firmware-atheros firmware-realtek firmware-libertas atmel-firmware firmware-zd1211" + fi + echo "firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware firmware-zd1211" + else + echo "" + fi + """ From d528bdcf6b3f6124e674bf94560cc3ca5b4414e2 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 27 Nov 2023 13:45:35 +0000 Subject: [PATCH 04/15] Auto-update README --- README.md | 1 + README_fr.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 98af644..6df4e15 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Documentation and resources * Official app website: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index fbfc54b..2830785 100644 --- a/README_fr.md +++ b/README_fr.md @@ -29,6 +29,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Documentations et ressources * Site officiel de l’app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs From 24067faa53c53e6f4aca8d7531d890f6423bcd08 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 27 Nov 2023 22:52:24 +0100 Subject: [PATCH 05/15] Fix stupid toml multiline string parsing issue... --- manifest.toml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/manifest.toml b/manifest.toml index 27f4a7b..db31176 100644 --- a/manifest.toml +++ b/manifest.toml @@ -49,10 +49,7 @@ ram.runtime = "50M" [resources.apt] packages = "sipcalc, hostapd, iw, kmod" - packages_from_raw_bash = """ - # Free firmwares - [[ "$firmware_nonfree" -eq 0 ]] && echo "firmware-ath9k-htc" || true - """ + packages_from_raw_bash = '[[ "$firmware_nonfree" -eq 0 ]] && echo "firmware-ath9k-htc" || true' extras.nonfree.repo = "deb http://deb.debian.org/debian bullseye non-free" extras.nonfree.key = "https://ftp-master.debian.org/keys/archive-key-11.asc" @@ -62,9 +59,9 @@ ram.runtime = "50M" # if armbian-firmware is detected, we dont include ra-link which is known to conflict.... if dpkg --list | grep -q armbian-firmware; then echo "firmware-atheros firmware-realtek firmware-libertas atmel-firmware firmware-zd1211" + else + echo "firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware firmware-zd1211" fi - echo "firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware firmware-zd1211" else - echo "" - fi - """ + echo " " + fi""" From 93f99733f520133012b43b558c6e35be0fffbde2 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 27 Nov 2023 23:01:30 +0100 Subject: [PATCH 06/15] =?UTF-8?q?Fix=20stupid=20toml=20multiline=20string?= =?UTF-8?q?=20parsing=20issue...=20=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index db31176..ddbac22 100644 --- a/manifest.toml +++ b/manifest.toml @@ -51,9 +51,10 @@ ram.runtime = "50M" packages = "sipcalc, hostapd, iw, kmod" packages_from_raw_bash = '[[ "$firmware_nonfree" -eq 0 ]] && echo "firmware-ath9k-htc" || true' - extras.nonfree.repo = "deb http://deb.debian.org/debian bullseye non-free" - extras.nonfree.key = "https://ftp-master.debian.org/keys/archive-key-11.asc" - extras.nonfree.packages_from_raw_bash = """ + [resources.apt.extras.nonfree] + repo = "deb http://deb.debian.org/debian bullseye non-free" + key = "https://ftp-master.debian.org/keys/archive-key-11.asc" + packages_from_raw_bash = """ # Proprietary USB Wireless Device firmwares, based on https://wiki.debian.org/WiFi#USB_Devices if [[ "$firmware_nonfree" -eq 1 ]]; then # if armbian-firmware is detected, we dont include ra-link which is known to conflict.... From 366beb69b3b2c6ee4c213743a19aec710e560b20 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 27 Nov 2023 23:10:12 +0100 Subject: [PATCH 07/15] wifi_passphrase must be saved explicitly --- scripts/install | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/install b/scripts/install index b3335cf..9ee1bab 100644 --- a/scripts/install +++ b/scripts/install @@ -90,6 +90,10 @@ else ynh_app_setting_set --app=$app --key=service_enabled --value=1 fi +# We must explicitly save the wifi passphrase despite being in the install question +# because password-type questions are not saved automatically +ynh_app_setting_set --app=$app --key=wifi_passphrase --value="$wifi_passphrase" + #================================================= # COPY CONFIGS #================================================= From 750f3ac66a18868512c58fece1d261fe418722da Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 27 Nov 2023 22:17:15 +0000 Subject: [PATCH 08/15] Auto-update README --- README_fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_fr.md b/README_fr.md index 3354c9a..2830785 100644 --- a/README_fr.md +++ b/README_fr.md @@ -44,4 +44,4 @@ ou sudo yunohost app upgrade hotspot -u https://github.com/YunoHost-Apps/hotspot_ynh/tree/testing --debug ``` -**Plus d’infos sur le packaging d’applications :** +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file From 60f3bced6535c8d88c220118a80e333485037e8e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 27 Nov 2023 23:33:44 +0100 Subject: [PATCH 09/15] Replace check_process with tests.toml --- check_process | 20 -------------------- tests.toml | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 20 deletions(-) delete mode 100644 check_process create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 950622f..0000000 --- a/check_process +++ /dev/null @@ -1,20 +0,0 @@ -;; Test complet - ; Manifest - wifi_ssid="myNeutralNetwork" - wifi_passphrase="VhegT8oev0jZI" - firmware_nonfree="no" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - upgrade=1 from_commit=539a1f26c30ba850455c63746d50ce3d8f33b119 - backup_restore=1 - multi_instance=1 - change_url=0 -;;; Upgrade options - ; commit=539a1f26c30ba850455c63746d50ce3d8f33b119 - name=Pre-2.0 diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..419bdc4 --- /dev/null +++ b/tests.toml @@ -0,0 +1,14 @@ +test_format = 1.0 + +[default] + + args.wifi_passphrase = "!abcDEF01234" + args.firmware_nonfree = "no" + + test_upgrade_from.539a1f26.name = "Pre 2.0" + +[with_nonfree] + + args.wifi_passphrase = "!abcDEF01234" + args.firmware_nonfree = "yes" + only = ["install.nourl"] From 7b4254baa0a0f9ec3630beebb2ca4d3f418f20d6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 27 Nov 2023 23:47:57 +0100 Subject: [PATCH 10/15] For some reason, gotta specify a default domain arg when testing upgrade from old version --- tests.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests.toml b/tests.toml index 419bdc4..98907d8 100644 --- a/tests.toml +++ b/tests.toml @@ -6,6 +6,7 @@ test_format = 1.0 args.firmware_nonfree = "no" test_upgrade_from.539a1f26.name = "Pre 2.0" + test_upgrade_from.539a1f26.args.domain = "domain.tld" [with_nonfree] From 5f7551ed1c727ae98ecac23e8dafe52758ea4c64 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 28 Nov 2023 00:02:23 +0100 Subject: [PATCH 11/15] Moar args to expicitly define for tests --- tests.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests.toml b/tests.toml index 98907d8..f8716c5 100644 --- a/tests.toml +++ b/tests.toml @@ -7,6 +7,7 @@ test_format = 1.0 test_upgrade_from.539a1f26.name = "Pre 2.0" test_upgrade_from.539a1f26.args.domain = "domain.tld" + test_upgrade_from.539a1f26.args.wifi_passphrase = "!abcDEF01234" [with_nonfree] From 53d1708056dc114b74c915c026a9f0e931274692 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Tue, 28 Nov 2023 03:04:14 +0100 Subject: [PATCH 12/15] Update manifest.toml : bump yunohos requirement to 11.2.7 --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index ddbac22..a54c1b6 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,7 +16,7 @@ license = "AGPL-3.0" website = "https://internetcu.be/" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.7" architectures = "all" multi_instance = true ldap = "not_relevant" From 80e29842d97b9e5f1b5bff664720c4f5159323f7 Mon Sep 17 00:00:00 2001 From: HgO Date: Mon, 18 Dec 2023 14:33:53 +0100 Subject: [PATCH 13/15] check if ynh-hotspot is activating --- conf/openvpn_90-hotspot | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/openvpn_90-hotspot b/conf/openvpn_90-hotspot index 1fbc11c..bb1f580 100644 --- a/conf/openvpn_90-hotspot +++ b/conf/openvpn_90-hotspot @@ -15,7 +15,8 @@ set_nat() { iptables -w -t nat -A POSTROUTING -o "${gateway_interface}" -j MASQUERADE } -if systemctl -q is-active __SERVICE_NAME__; then +ynh_hotspot_state=$(systemctl -q is-active __SERVICE_NAME__) +if [[ "${ynh_hotspot_state}" == "active" || "${ynh_hotspot_state}" == "activating" ]]; then old_gateway_interface=$(yunohost app setting __APP__ gateway_interface) new_gateway_interface=$(ip route get 1.2.3.4 | awk '{ print $5; }') From d16e8f5503f2525a54165d5edf7408e20ca30fba Mon Sep 17 00:00:00 2001 From: HgO Date: Tue, 19 Dec 2023 10:42:31 +0100 Subject: [PATCH 14/15] obviously it won't work in quiet mode... --- conf/openvpn_90-hotspot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/openvpn_90-hotspot b/conf/openvpn_90-hotspot index bb1f580..1fc4dd0 100644 --- a/conf/openvpn_90-hotspot +++ b/conf/openvpn_90-hotspot @@ -15,7 +15,7 @@ set_nat() { iptables -w -t nat -A POSTROUTING -o "${gateway_interface}" -j MASQUERADE } -ynh_hotspot_state=$(systemctl -q is-active __SERVICE_NAME__) +ynh_hotspot_state=$(systemctl is-active __SERVICE_NAME__) if [[ "${ynh_hotspot_state}" == "active" || "${ynh_hotspot_state}" == "activating" ]]; then old_gateway_interface=$(yunohost app setting __APP__ gateway_interface) new_gateway_interface=$(ip route get 1.2.3.4 | awk '{ print $5; }') From 2d38e95ea3a05b5a0d5b3d692f43132c72626bc6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 31 Dec 2023 17:32:37 +0100 Subject: [PATCH 15/15] Disable the classic hostapd service because we're using hostapd@$app instead, otherwise it'll flood logs x_x --- scripts/install | 6 ++---- scripts/restore | 8 ++++++++ scripts/upgrade | 8 ++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 9ee1bab..451d9ad 100644 --- a/scripts/install +++ b/scripts/install @@ -123,12 +123,10 @@ chmod 0755 "/etc/openvpn/scripts/route-down.d/90-${service_name}" #================================================= ynh_script_progression --message="Configuring hostapd..." -# Set default inits -# The boot order of these services are important, so they are disabled by default -# and the ynh-hotspot service handles them. +# Disable hostapd, we'll use hostapd@$app instead (for multissid support etc) systemctl disable hostapd --quiet 2>&1 systemctl stop hostapd 2>&1 -systemctl unmask hostapd 2>&1 # On some system e.g. RPi, for some reason hostapd is masked after install ... +systemctl mask hostapd 2>&1 if [[ -n "${wifi_device}" ]]; then configure_hostapd diff --git a/scripts/restore b/scripts/restore index 4d93dce..9cd18cb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,14 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +if systemctl -q is-enabled hostapd +then + # Disable hostapd, we'll use hostapd@$app instead (for multissid support etc) + systemctl disable hostapd --quiet 2>&1 + systemctl stop hostapd 2>&1 + systemctl mask hostapd 2>&1 +fi + #================================================= # FIND AND OPEN A PORT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 7b14ae9..fb92cc1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -129,6 +129,14 @@ if [ -e "/etc/sudoers.d/${app}_ynh" ]; then ynh_secure_remove "/etc/sudoers.d/${app}_ynh" fi +if systemctl -q is-enabled hostapd +then + # Disable hostapd, we'll use hostapd@$app instead (for multissid support etc) + systemctl disable hostapd --quiet 2>&1 + systemctl stop hostapd 2>&1 + systemctl mask hostapd 2>&1 +fi + #================================================= # SPECIFIC UPGRADE #=================================================