diff --git a/config/090_raspap.conf b/config/090_raspap.conf new file mode 100644 index 00000000..da01c751 --- /dev/null +++ b/config/090_raspap.conf @@ -0,0 +1,4 @@ +# RaspAP default config +log-facility=/tmp/dnsmasq.log +conf-dir=/etc/dnsmasq.d + diff --git a/config/config.php b/config/config.php index 31bb9376..2c476b57 100755 --- a/config/config.php +++ b/config/config.php @@ -12,7 +12,7 @@ define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap'); define('RASPI_DNSMASQ_LEASES', '/var/lib/misc/dnsmasq.leases'); define('RASPI_DNSMASQ_PREFIX', '/etc/dnsmasq.d/090_'); define('RASPI_ADBLOCK_LISTPATH', '/etc/raspap/adblock/'); -define('RASPI_ADBLOCK_CONFIG', '/etc/dnsmasq.d/090_adblock.conf'); +define('RASPI_ADBLOCK_CONFIG', RASPI_DNSMASQ_PREFIX.'adblock.conf'); define('RASPI_HOSTAPD_CONFIG', '/etc/hostapd/hostapd.conf'); define('RASPI_DHCPCD_CONFIG', '/etc/dhcpcd.conf'); define('RASPI_WPA_SUPPLICANT_CONFIG', '/etc/wpa_supplicant/wpa_supplicant.conf'); diff --git a/config/dnsmasq.conf b/config/dnsmasq.conf deleted file mode 100644 index acbf4765..00000000 --- a/config/dnsmasq.conf +++ /dev/null @@ -1,13 +0,0 @@ -# RaspAP wlan0 configuration for wired (ethernet) AP mode -interface=wlan0 -dhcp-range=10.3.141.50,10.3.141.255,255.255.255.0,12h -dhcp-option=6,1.1.1.1,8.8.8.8 - -# RaspAP uap0 configuration for wireless client AP mode -#interface=lo,uap0 # Use interfaces lo and uap0 -#bind-interfaces # Bind to the interfaces -#server=8.8.8.8 # Forward DNS requests to Google DNS -#domain-needed # Don't forward short names -#bogus-priv # Never forward addresses in the non-routed address spaces -#dhcp-range=192.168.50.50,192.168.50.150,12h - diff --git a/includes/defaults.php b/includes/defaults.php index 69377de8..f0c27ab7 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -17,7 +17,7 @@ $defaults = [ 'RASPI_DNSMASQ_LEASES' => '/var/lib/misc/dnsmasq.leases', 'RASPI_DNSMASQ_PREFIX' => '/etc/dnsmasq.d/090_', 'RASPI_ADBLOCK_LISTPATH' => '/etc/raspap/adblock/', - 'RASPI_ADBLOCK_CONFIG' => '/etc/dnsmasq.d/090_adblock.conf', + 'RASPI_ADBLOCK_CONFIG' => RASPI_DNSMASQ_PREFIX.'adblock.conf', 'RASPI_HOSTAPD_CONFIG' => '/etc/hostapd/hostapd.conf', 'RASPI_DHCPCD_CONFIG' => '/etc/dhcpcd.conf', 'RASPI_WPA_SUPPLICANT_CONFIG' => '/etc/wpa_supplicant/wpa_supplicant.conf', diff --git a/includes/dhcp.php b/includes/dhcp.php index 02755af7..7795b113 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -191,8 +191,6 @@ function updateDnsmasqConfig($iface,$status) } $config .= PHP_EOL; } - $config .= "log-facility=/tmp/dnsmasq.log".PHP_EOL; - file_put_contents("/tmp/dnsmasqdata", $config); $msg = file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf') ? 'updated' : 'added'; system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$iface.'.conf', $result); diff --git a/installers/common.sh b/installers/common.sh index cf6d2081..27d2bf79 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -18,7 +18,8 @@ set -o errtrace readonly raspap_dir="/etc/raspap" readonly raspap_user="www-data" readonly raspap_sudoers="/etc/sudoers.d/090_raspap" -readonly raspap_dnsmasq="/etc/dnsmasq.d/090_wlan0.conf" +readonly raspap_default="/etc/dnsmasq.d/090_raspap.conf" +readonly raspap_wlan0="/etc/dnsmasq.d/090_wlan0.conf" readonly raspap_adblock="/etc/dnsmasq.d/090_adblock.conf" readonly raspap_sysctl="/etc/sysctl.d/90_raspap.conf" readonly raspap_network="$raspap_dir/networking/" @@ -234,7 +235,7 @@ function _install_adblock() { # Remove dhcp-option=6 in dnsmasq.d/090_wlan0.conf to force local DNS resolution for DHCP clients echo "Enabling local DNS name resolution for DHCP clients" - sudo sed -i '/dhcp-option=6/d' $raspap_dnsmasq || _install_status 1 "Unable to modify $raspap_dnsmasq" + sudo sed -i '/dhcp-option=6/d' $raspap_wlan0 || _install_status 1 "Unable to modify $raspap_dnsmasq" echo "Enabling ad blocking management option" sudo sed -i "s/\('RASPI_ADBLOCK_ENABLED', \)false/\1true/g" "$webroot_dir/includes/config.php" || _install_status 1 "Unable to modify config.php" @@ -332,8 +333,13 @@ function _check_for_old_configs() { sudo ln -sf "$raspap_dir/backups/hostapd.conf.`date +%F-%R`" "$raspap_dir/backups/hostapd.conf" fi - if [ -f $raspap_dnsmasq ]; then - sudo cp $raspap_dnsmasq "$raspap_dir/backups/090_wlan0.conf.`date +%F-%R`" + if [ -f $raspap_default ]; then + sudo cp $raspap_default "$raspap_dir/backups/090_raspap.conf.`date +%F-%R`" + sudo ln -sf "$raspap_dir/backups/090_raspap.conf.`date +%F-%R`" "$raspap_dir/backups/090_raspap.conf" + fi + + if [ -f $raspap_wlan0 ]; then + sudo cp $raspap_wlan0 "$raspap_dir/backups/090_wlan0.conf.`date +%F-%R`" sudo ln -sf "$raspap_dir/backups/090_wlan0.conf.`date +%F-%R`" "$raspap_dir/backups/090_wlan0.conf" fi @@ -370,7 +376,8 @@ function _default_configuration() { _install_log "Applying default configuration to installed services" sudo cp $webroot_dir/config/hostapd.conf /etc/hostapd/hostapd.conf || _install_status 1 "Unable to move hostapd configuration file" - sudo cp $webroot_dir/config/090_wlan0.conf $raspap_dnsmasq || _install_status 1 "Unable to move dnsmasq configuration file" + sudo cp $webroot_dir/config/090_raspap.conf $raspap_default || _install_status 1 "Unable to move dnsmasq default configuration file" + sudo cp $webroot_dir/config/090_wlan0.conf $raspap_wlan0 || _install_status 1 "Unable to move dnsmasq wlan0 configuration file" sudo cp $webroot_dir/config/dhcpcd.conf /etc/dhcpcd.conf || _install_status 1 "Unable to move dhcpcd configuration file" sudo cp $webroot_dir/config/defaults.json $raspap_network || _install_status 1 "Unable to move defaults.json settings"