diff --git a/conf/dnsmasq.conf.tpl b/conf/dnsmasq.conf.tpl new file mode 100644 index 0000000..74b638a --- /dev/null +++ b/conf/dnsmasq.conf.tpl @@ -0,0 +1,4 @@ +# Wifi Hotspot app for YunoHost + +# Enable DNS +interface=__WIFI_DEVICE__ diff --git a/scripts/_common.sh b/scripts/_common.sh index 94a730a..485fed0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -79,6 +79,11 @@ function configure_hostapd() ynh_add_config --template="/etc/hostapd/$app/hostapd.conf.tpl" --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" +} + function configure_dhcp() { ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv4.conf" diff --git a/scripts/backup b/scripts/backup index 1362ed7..de71cba 100644 --- a/scripts/backup +++ b/scripts/backup @@ -43,6 +43,9 @@ ynh_print_info --message="Declaring files to be backed up..." 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/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 diff --git a/scripts/config b/scripts/config index b7c9748..b493dbf 100644 --- a/scripts/config +++ b/scripts/config @@ -193,6 +193,7 @@ ynh_app_config_apply() { _ynh_app_config_apply configure_hostapd + configure_dnsmasq configure_dhcp # Start hotspot diff --git a/scripts/install b/scripts/install index 08e09ee..5dd508d 100644 --- a/scripts/install +++ b/scripts/install @@ -162,6 +162,7 @@ mkdir -pm 0755 /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 @@ -200,6 +201,7 @@ systemctl unmask hostapd 2>&1 # On some system e.g. RPi, for some reason hostapd if [[ -n "${wifi_device}" ]]; then configure_hostapd + configure_dnsmasq configure_dhcp fi diff --git a/scripts/remove b/scripts/remove index e7a0a0f..c59fe8e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -64,6 +64,8 @@ do done # Remove confs +ynh_secure_remove --file="/etc/dnsmasq.d/$app.conf" + ynh_secure_remove --file="/etc/dnsmasq.$app/" ynh_secure_remove --file="/etc/hostapd/$app/" diff --git a/scripts/restore b/scripts/restore index 43d912c..afd0c60 100644 --- a/scripts/restore +++ b/scripts/restore @@ -65,6 +65,9 @@ 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/dnsmasq.$app/dnsmasq.conf.tpl" +ynh_restore_file --origin_path="/etc/dnsmasq.d/$app.conf" --not_mandatory + ynh_restore_file --origin_path="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" ynh_restore_file --origin_path="/etc/dnsmasq.$app/dhcpdv6.conf" --not_mandatory diff --git a/scripts/upgrade b/scripts/upgrade index 0810b57..dfa7c6d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -214,11 +214,13 @@ mkdir -pm 0755 /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 configure_hostapd + configure_dnsmasq configure_dhcp fi