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:
parent
a4a99e70f6
commit
69478cd6e2
4 changed files with 26 additions and 36 deletions
|
@ -48,6 +48,26 @@ function hot_reload_usb_wifi_cards()
|
|||
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
|
||||
#=================================================
|
||||
|
|
|
@ -191,18 +191,8 @@ ynh_app_config_apply() {
|
|||
|
||||
_ynh_app_config_apply
|
||||
|
||||
if [ "${wifi_secure}" -eq 1 ]; then
|
||||
local sec_comment=""
|
||||
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
|
||||
configure_hostapd
|
||||
configure_dhcp
|
||||
|
||||
# Start hotspot
|
||||
ynh_print_info --message="Starting hotspot service if needed"
|
||||
|
|
|
@ -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 ...
|
||||
|
||||
if [[ -n ${wifi_device} ]]; then
|
||||
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/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
|
||||
configure_hostapd
|
||||
configure_dhcp
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
|
||||
if [[ -n ${wifi_device} ]]; then
|
||||
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/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
|
||||
configure_hostapd
|
||||
configure_dhcp
|
||||
fi
|
||||
|
||||
# Copy init script
|
||||
|
|
Loading…
Reference in a new issue