1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hotspot_ynh.git synced 2024-09-03 19:25:53 +02:00

Merge pull request #112 from YunoHost-Apps/testing

Testing
This commit is contained in:
Alexandre Aubin 2023-10-06 17:25:39 +02:00 committed by GitHub
commit 19e43b8726
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 64 additions and 103 deletions

View file

@ -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 * Combine with the [VPN Client app](https://github.com/labriqueinternet/vpnclient_ynh) to obtain a VPN-protected WiFi
**Shipped version:** 2.1.1~ynh1 **Shipped version:** 2.2.0~ynh1
## Screenshots ## Screenshots

View file

@ -20,7 +20,7 @@ Si vous navez 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 * À 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.1.1~ynh1 **Version incluse :** 2.2.0~ynh1
## Captures décran ## Captures décran

View file

@ -1,4 +0,0 @@
# Wifi Hotspot app for YunoHost
# Enable DNS resolution on wifi interface
interface=__WIFI_DEVICE__

View file

@ -296,6 +296,9 @@ start)
# Update dynamic settings # Update dynamic settings
ynh_app_setting_set hotspot gateway_interface "${new_gateway_interface}" 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) stop)
echo "[hotspot] Stopping..." echo "[hotspot] Stopping..."
@ -319,6 +322,9 @@ stop)
echo "Stop hostapd" echo "Stop hostapd"
stop_hostapd stop_hostapd
fi fi
# Regen-conf dnsmasq to disable dns resolution on dnsmasq for the previous interface
yunohost tools regen-conf dnsmasq
;; ;;
restart) restart)
$0 stop $0 stop

View file

@ -6,7 +6,7 @@
"en": "Create and manager wifi networks, share Internet access and use YunoHost apps accross wifi", "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" "fr": "Créer et configurer des réseaux wifi, partager l'accès a Internet et utiliser les applications YunoHost via wifi"
}, },
"version": "2.1.1~ynh1", "version": "2.2.0~ynh1",
"url": "https://github.com/labriqueinternet/hotspot_ynh", "url": "https://github.com/labriqueinternet/hotspot_ynh",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"maintainer": { "maintainer": {

View file

@ -80,28 +80,14 @@ function configure_hostapd()
sec_comment="#" sec_comment="#"
fi 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_dnsmasq()
{
ynh_add_config --template="/etc/dnsmasq.$app/dnsmasq.conf.tpl" --destination="/etc/dnsmasq.d/$app.conf"
systemctl restart dnsmasq
} }
function configure_dhcp() function configure_dhcp()
{ {
ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" --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 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/dnsmasq_dhcpdv6.conf" --destination="/etc/dnsmasq.$app/dhcpdv6.conf"
fi fi
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -40,16 +40,8 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # 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/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"
ynh_backup --src_path="/etc/dnsmasq.$app/dhcpdv6.conf" --not_mandatory 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="/etc/dnsmasq.$app/dhcpdv4.conf" --not_mandatory
ynh_backup --src_path="/usr/local/bin/$service_name" ynh_backup --src_path="/usr/local/bin/$service_name"

View file

@ -205,7 +205,6 @@ ynh_app_config_apply() {
if [[ "${service_enabled}" -eq 1 ]]; then if [[ "${service_enabled}" -eq 1 ]]; then
configure_hostapd configure_hostapd
configure_dnsmasq
configure_dhcp configure_dhcp
# Start hotspot # Start hotspot
@ -214,12 +213,13 @@ ynh_app_config_apply() {
else else
ynh_print_info --message="Cleanup hotspot config files" ynh_print_info --message="Cleanup hotspot config files"
ynh_secure_remove --file="/etc/hostapd/$app/hostapd.conf" 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/dhcpdv4.conf"
ynh_secure_remove --file="/etc/dnsmasq.$app/dhcpdv6.conf" ynh_secure_remove --file="/etc/dnsmasq.$app/dhcpdv6.conf"
systemctl restart dnsmasq systemctl restart dnsmasq
fi fi
yunohost tools regen-conf dnsmasq
} }
ynh_app_config_run $1 ynh_app_config_run $1

View file

@ -161,11 +161,6 @@ chown root: /etc/hostapd/$app/
mkdir -pm 0755 /etc/dnsmasq.$app/ mkdir -pm 0755 /etc/dnsmasq.$app/
chown root: /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
# Copy init script # Copy init script
ynh_add_config --template="../conf/ynh-hotspot" --destination="/usr/local/bin/$service_name" ynh_add_config --template="../conf/ynh-hotspot" --destination="/usr/local/bin/$service_name"
chmod 0755 "/usr/local/bin/$service_name" chmod 0755 "/usr/local/bin/$service_name"
@ -193,7 +188,6 @@ systemctl unmask hostapd 2>&1 # On some system e.g. RPi, for some reason hostapd
if [[ -n "${wifi_device}" ]]; then if [[ -n "${wifi_device}" ]]; then
configure_hostapd configure_hostapd
configure_dnsmasq
configure_dhcp configure_dhcp
fi fi
@ -212,7 +206,7 @@ ynh_add_systemd_config --service="hostapd@$app" --template="../conf/systemd_host
#================================================= #=================================================
ynh_script_progression --message="Integrating 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" yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" --need_lock
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -223,7 +217,7 @@ ynh_script_progression --message="Starting a systemd service..."
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 echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2
else 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 fi
#================================================= #=================================================

View file

@ -71,17 +71,8 @@ else
pkg_dependencies="$pkg_dependencies $free_firmware_packages" pkg_dependencies="$pkg_dependencies $free_firmware_packages"
fi 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/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 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="/etc/dnsmasq.$app/dhcpdv4.conf" --not_mandatory
ynh_restore_file --origin_path="/usr/local/bin/$service_name" ynh_restore_file --origin_path="/usr/local/bin/$service_name"
@ -112,7 +103,7 @@ ynh_restore_file --origin_path="/etc/systemd/system/hostapd@$app.service"
#================================================= #=================================================
ynh_script_progression --message="Integrating 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" yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" --need_lock
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -135,7 +126,7 @@ fi
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 echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2
else 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 fi
#================================================= #=================================================

View file

@ -58,8 +58,7 @@ ynh_abort_if_errors
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping the hotspot service ... (this may take some time)" ynh_script_progression --message="Stopping the hotspot service ... (this may take some time)"
yunohost service stop $service_name
ynh_systemd_action --service_name=$service_name --action="stop" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot"
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
@ -70,6 +69,9 @@ if [ -d /var/www/wifiadmin/ ]; then
ynh_secure_remove /var/www/wifiadmin/ ynh_secure_remove /var/www/wifiadmin/
fi fi
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 firmware_nonfree=1
@ -213,14 +215,8 @@ chown root: /etc/hostapd/$app/
mkdir -pm 0755 /etc/dnsmasq.$app/ mkdir -pm 0755 /etc/dnsmasq.$app/
chown root: /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 if [[ -n "${wifi_device}" ]]; then
configure_hostapd configure_hostapd
configure_dnsmasq
configure_dhcp configure_dhcp
fi fi
@ -254,7 +250,7 @@ ynh_add_systemd_config --service="hostapd@$app" --template="../conf/systemd_host
#================================================= #=================================================
ynh_script_progression --message="Integrating 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" yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd@$app" --need_lock
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -272,7 +268,7 @@ fi
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 echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2
else 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 fi
#================================================= #=================================================