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

create functions for configuring hostapd and dhcp

This commit is contained in:
HgO 2023-08-22 14:51:13 +02:00
parent a4a99e70f6
commit 69478cd6e2
4 changed files with 26 additions and 36 deletions

View file

@ -48,6 +48,26 @@ function hot_reload_usb_wifi_cards()
done done
} }
function configure_hostapd()
{
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"
}
function configure_dhcp()
{
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
}
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -191,18 +191,8 @@ ynh_app_config_apply() {
_ynh_app_config_apply _ynh_app_config_apply
if [ "${wifi_secure}" -eq 1 ]; then configure_hostapd
local sec_comment="" configure_dhcp
else
local sec_comment="#"
fi
ynh_add_config --template="/etc/hostapd/$app/hostapd.conf.tpl" --destination="/etc/hostapd/$app/hostapd.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
# Start hotspot # Start hotspot
ynh_print_info --message="Starting hotspot service if needed" ynh_print_info --message="Starting hotspot service if needed"

View file

@ -201,18 +201,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 ... systemctl unmask hostapd 2>&1 # On some system e.g. RPi, for some reason hostapd is masked after install ...
if [[ -n ${wifi_device} ]]; then if [[ -n ${wifi_device} ]]; then
if [ "${wifi_secure}" -eq 1 ]; then configure_hostapd
sec_comment="" configure_dhcp
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/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
fi fi
#================================================= #=================================================

View file

@ -208,18 +208,8 @@ install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq
install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.$app/dhcpdv4.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
if [ "${wifi_secure}" -eq 1 ]; then configure_hostapd
sec_comment="" configure_dhcp
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/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
fi fi
# Copy init script # Copy init script