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 #110 from YunoHost-Apps/testing

Testing
This commit is contained in:
HgO 2023-09-28 20:00:26 +02:00 committed by GitHub
commit 2d97ad5aec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 20 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
**Shipped version:** 2.1~ynh1
**Shipped version:** 2.1.1~ynh1
## 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
**Version incluse :** 2.1~ynh1
**Version incluse :** 2.1.1~ynh1
## Captures décran

View file

@ -148,13 +148,13 @@ start_dhcpd() {
# Run DHCPv4 server
if ! is_dhcpd4_running; then
echo "hotspot ${wifi_device}: Start the DHCPv4 server (dnsmasq)"
dnsmasq -C /etc/dnsmasq.$app/dhcpdv4.conf -p0 -x /run/dnsmasq/dnsmasq-dhcpv4-$app.pid
dnsmasq -C /etc/dnsmasq.$app/dhcpdv4.conf -p0 -x /run/dnsmasq/dnsmasq-dhcpdv4-$app.pid
fi
# Run DHCPv6 server
if has_ip6delegatedprefix && ! is_dhcpd6_running; then
echo "hotspot ${wifi_device}: Start the NDP and DHCPv6 server (dnsmasq)"
dnsmasq -C /etc/dnsmasq.$app/dhcpdv6.conf -p0 -x /run/dnsmasq/dnsmasq-dhcpv6-$app.pid
dnsmasq -C /etc/dnsmasq.$app/dhcpdv6.conf -p0 -x /run/dnsmasq/dnsmasq-dhcpdv6-$app.pid
fi
}

View file

@ -103,7 +103,6 @@ name = "Configuration"
[main.hotspot.dns]
ask = "DNS resolvers"
type = "tags"
bind = "null"
visible = "advanced"
pattern.regexp = '^([0-9.]{7,15}|[0-9a-fA-F:]+)$'
pattern.error = "Not an ip"

View file

@ -6,7 +6,7 @@
"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.1~ynh1",
"version": "2.1.1~ynh1",
"url": "https://github.com/labriqueinternet/hotspot_ynh",
"license": "AGPL-3.0",
"maintainer": {

View file

@ -136,21 +136,24 @@ validate__ip4_nat_prefix() {
}
validate__dns() {
if ! echo "${dns}" | grep -q "\."
if [[ -z "$ip4_dns" ]]
then
echo 'IPv4 DNS required'
fi
if [[ -n "${ip6_net}" ]] && ! echo "${dns}" | grep -q ":"
if [[ -n "${ip6_net}" ]] && [[ -z "$ip6_dns" ]]
then
echo 'IPv6 DNS required'
fi
}
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
ynh_app_config_validate() {
if [[ "${advanced}" -eq 0 ]]; then
# When we aren't in advanced mode, these variables must be manually declared
dns="${old[dns]}"
ip6_net="${old[ip6_net]}"
ip4_nat_prefix="${old[ip4_nat_prefix]}"
fi
set__dns() {
ip6_dns=""
ip4_dns=""
for ip in $(echo "${dns}" | tr ',' ' '); do
@ -171,7 +174,15 @@ set__dns() {
if [[ -n "${ip4_nat_prefix}" ]] && [[ -z "${ip4_dns}" ]]; then
ip4_dns="${ip4_nat_prefix}.1"
fi
_ynh_app_config_validate
}
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__dns() {
ynh_app_setting_set $app ip6_dns "${ip6_dns}"
ynh_app_setting_set $app ip4_dns "${ip4_dns}"
}
@ -188,18 +199,27 @@ ynh_app_config_apply() {
# Stop vpn client
ynh_print_info --message="Stopping hotspot in order to edit files"
/usr/local/bin/${service_name} stop
systemctl stop ${service_name}
_ynh_app_config_apply
configure_hostapd
configure_dnsmasq
configure_dhcp
if [[ "${service_enabled}" -eq 1 ]]; then
configure_hostapd
configure_dnsmasq
configure_dhcp
# Start hotspot
ynh_print_info --message="Starting hotspot service if needed"
/usr/local/bin/${service_name} start
# Start hotspot
ynh_print_info --message="Starting hotspot service if needed"
systemctl start ${service_name}
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
}
ynh_app_config_run $1