1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Merge branch 'feature/dhcp-eth0' of https://github.com/billz/raspap-webgui into feature/dhcp-eth0

This commit is contained in:
Bill Zimmerman 2020-12-15 17:25:27 +01:00
commit bcd90f80d0
7 changed files with 26 additions and 25 deletions

4
config/090_raspap.conf Normal file
View File

@ -0,0 +1,4 @@
# RaspAP default config
log-facility=/tmp/dnsmasq.log
conf-dir=/etc/dnsmasq.d

View File

@ -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_LEASES', '/var/lib/misc/dnsmasq.leases');
define('RASPI_DNSMASQ_PREFIX', '/etc/dnsmasq.d/090_'); define('RASPI_DNSMASQ_PREFIX', '/etc/dnsmasq.d/090_');
define('RASPI_ADBLOCK_LISTPATH', '/etc/raspap/adblock/'); 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_HOSTAPD_CONFIG', '/etc/hostapd/hostapd.conf');
define('RASPI_DHCPCD_CONFIG', '/etc/dhcpcd.conf'); define('RASPI_DHCPCD_CONFIG', '/etc/dhcpcd.conf');
define('RASPI_WPA_SUPPLICANT_CONFIG', '/etc/wpa_supplicant/wpa_supplicant.conf'); define('RASPI_WPA_SUPPLICANT_CONFIG', '/etc/wpa_supplicant/wpa_supplicant.conf');

View File

@ -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

View File

@ -17,7 +17,7 @@ $defaults = [
'RASPI_DNSMASQ_LEASES' => '/var/lib/misc/dnsmasq.leases', 'RASPI_DNSMASQ_LEASES' => '/var/lib/misc/dnsmasq.leases',
'RASPI_DNSMASQ_PREFIX' => '/etc/dnsmasq.d/090_', 'RASPI_DNSMASQ_PREFIX' => '/etc/dnsmasq.d/090_',
'RASPI_ADBLOCK_LISTPATH' => '/etc/raspap/adblock/', '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_HOSTAPD_CONFIG' => '/etc/hostapd/hostapd.conf',
'RASPI_DHCPCD_CONFIG' => '/etc/dhcpcd.conf', 'RASPI_DHCPCD_CONFIG' => '/etc/dhcpcd.conf',
'RASPI_WPA_SUPPLICANT_CONFIG' => '/etc/wpa_supplicant/wpa_supplicant.conf', 'RASPI_WPA_SUPPLICANT_CONFIG' => '/etc/wpa_supplicant/wpa_supplicant.conf',

View File

@ -191,8 +191,6 @@ function updateDnsmasqConfig($iface,$status)
} }
$config .= PHP_EOL; $config .= PHP_EOL;
} }
$config .= "log-facility=/tmp/dnsmasq.log".PHP_EOL;
file_put_contents("/tmp/dnsmasqdata", $config); file_put_contents("/tmp/dnsmasqdata", $config);
$msg = file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf') ? 'updated' : 'added'; $msg = file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf') ? 'updated' : 'added';
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$iface.'.conf', $result); system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$iface.'.conf', $result);

View File

@ -18,7 +18,8 @@ set -o errtrace
readonly raspap_dir="/etc/raspap" readonly raspap_dir="/etc/raspap"
readonly raspap_user="www-data" readonly raspap_user="www-data"
readonly raspap_sudoers="/etc/sudoers.d/090_raspap" 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_adblock="/etc/dnsmasq.d/090_adblock.conf"
readonly raspap_sysctl="/etc/sysctl.d/90_raspap.conf" readonly raspap_sysctl="/etc/sysctl.d/90_raspap.conf"
readonly raspap_network="$raspap_dir/networking/" 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 # 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" 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" 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" 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" sudo ln -sf "$raspap_dir/backups/hostapd.conf.`date +%F-%R`" "$raspap_dir/backups/hostapd.conf"
fi fi
if [ -f $raspap_dnsmasq ]; then if [ -f $raspap_default ]; then
sudo cp $raspap_dnsmasq "$raspap_dir/backups/090_wlan0.conf.`date +%F-%R`" 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" sudo ln -sf "$raspap_dir/backups/090_wlan0.conf.`date +%F-%R`" "$raspap_dir/backups/090_wlan0.conf"
fi fi
@ -370,7 +376,8 @@ function _default_configuration() {
_install_log "Applying default configuration to installed services" _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/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/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" sudo cp $webroot_dir/config/defaults.json $raspap_network || _install_status 1 "Unable to move defaults.json settings"

View File

@ -18,7 +18,8 @@ set -o errtrace
readonly raspap_dir="/etc/raspap" readonly raspap_dir="/etc/raspap"
readonly raspap_user="www-data" readonly raspap_user="www-data"
readonly raspap_sudoers="/etc/sudoers.d/090_raspap" 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_sysctl="/etc/sysctl.d/90_raspap.conf" readonly raspap_sysctl="/etc/sysctl.d/90_raspap.conf"
readonly raspap_adblock="/etc/dnsmasq.d/090_adblock.conf" readonly raspap_adblock="/etc/dnsmasq.d/090_adblock.conf"
readonly raspap_network="/etc/systemd/network/" readonly raspap_network="/etc/systemd/network/"
@ -174,9 +175,13 @@ function _restore_networking() {
fi fi
echo "Done." echo "Done."
# Remove dnsmasq and bridge configs # Remove dnsmasq and bridge configs
echo "Removing 090_raspap.conf from dnsmasq"
if [ -f $raspap_default ]; then
sudo rm "$raspap_default" || _install_error "Unable to remove $raspap_default"
fi
echo "Removing 090_wlan0.conf from dnsmasq" echo "Removing 090_wlan0.conf from dnsmasq"
if [ -f $raspap_dnsmasq ]; then if [ -f $raspap_wlan0 ]; then
sudo rm "$raspap_dnsmasq" || _install_error "Unable to remove $raspap_dnsmasq" sudo rm "$raspap_wlan0" || _install_error "Unable to remove $raspap_wlan0"
fi fi
echo "Removing raspap bridge configurations" echo "Removing raspap bridge configurations"
sudo rm "$raspap_network"/raspap* || _install_error "Unable to remove bridge config" sudo rm "$raspap_network"/raspap* || _install_error "Unable to remove bridge config"