diff --git a/config/hostapd.conf b/config/hostapd.conf index cdb2a881..b88b5469 100644 --- a/config/hostapd.conf +++ b/config/hostapd.conf @@ -20,5 +20,5 @@ country_code=GB ## RaspAP wireless client AP mode #interface=uap0 -## RaspAP bridge AP mode (disabled by default) +## RaspAP bridge AP mode, disabled by default #bridge=br0 diff --git a/includes/dhcp.php b/includes/dhcp.php index 40570bbb..72601374 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -187,12 +187,14 @@ function updateDnsmasqConfig($iface,$status) } // Static leases $staticLeases = array(); - for ($i=0; $i < count($_POST["static_leases"]["mac"]); $i++) { - $mac = trim($_POST["static_leases"]["mac"][$i]); - $ip = trim($_POST["static_leases"]["ip"][$i]); - $comment = trim($_POST["static_leases"]["comment"][$i]); - if ($mac != "" && $ip != "") { - $staticLeases[] = array('mac' => $mac, 'ip' => $ip, 'comment' => $comment); + if (isset($_POST["static_leases"]["mac"])) { + for ($i=0; $i < count($_POST["static_leases"]["mac"]); $i++) { + $mac = trim($_POST["static_leases"]["mac"][$i]); + $ip = trim($_POST["static_leases"]["ip"][$i]); + $comment = trim($_POST["static_leases"]["comment"][$i]); + if ($mac != "" && $ip != "") { + $staticLeases[] = array('mac' => $mac, 'ip' => $ip, 'comment' => $comment); + } } } // Sort ascending by IPs diff --git a/includes/functions.php b/includes/functions.php index 35d285cf..7618eeb2 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -52,11 +52,15 @@ function mask2cidr($mask) */ function cidr2mask($cidr) { - $ta = substr ($cidr, strpos ($cidr, '/') + 1) * 1; - $netmask = str_split (str_pad (str_pad ('', $ta, '1'), 32, '0'), 8); - foreach ($netmask as &$element) - $element = bindec ($element); - return join ('.', $netmask); + $ipParts = explode('/', $cidr); + $ip = $ipParts[0]; + $prefixLength = $ipParts[1]; + + $ipLong = ip2long($ip); + $netmaskLong = bindec(str_pad(str_repeat('1', $prefixLength), 32, '0')); + $netmask = long2ip($netmaskLong); + + return $netmask; } /** diff --git a/installers/common.sh b/installers/common.sh index d7a046af..ade4e546 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -140,7 +140,13 @@ function _get_linux_distro() { # Sets php package option based on Linux version, abort if unsupported distro function _set_php_package() { case $RELEASE in - 22.04|20.04|18.04|19.10|11*) # Ubuntu Server, Debian 11 & Armbian 22.05 + 23.05|12*) # Debian 12 & Armbian 23.05 + php_package="php8.2-cgi" + phpcgiconf="/etc/php/8.2/cgi/php.ini" ;; + 23.04) # Ubuntu Server 23.04 + php_package="php8.1-cgi" + phpcgiconf="/etc/php/8.1/cgi/php.ini" ;; + 22.04|20.04|18.04|19.10|11*) # Previous Ubuntu Server, Debian & Armbian distros php_package="php7.4-cgi" phpcgiconf="/etc/php/7.4/cgi/php.ini" ;; 10*|11*) @@ -165,6 +171,8 @@ function _set_php_package() { function _manage_systemd_services() { _install_log "Checking for systemd network services" + _check_notify_ubuntu + services=( "systemd-networkd" "systemd-resolved" ) for svc in "${services[@]}"; do # Prompt to disable systemd service @@ -189,10 +197,27 @@ function _manage_systemd_services() { _install_status 0 } +# Notifies Ubuntu users of pre-install requirements +function _check_notify_ubuntu() { + if [ ${OS,,} = "ubuntu" ]; then + _install_status 2 "Ubuntu Server requires manual pre- and post-install steps. See https://docs.raspap.com/manual/" + echo -n "Proceed with installation? [Y/n]: " + read answer < /dev/tty + if [ "$answer" != "${answer#[Nn]}" ]; then + echo "Installation aborted." + exit 0 + else + _install_status 0 + fi + fi +} + # Runs a system software update to make sure we're using all fresh packages function _install_dependencies() { _install_log "Installing required packages" _set_php_package + + # OS-specific packages if [ "$php_package" = "php7.4-cgi" ] && [ ${OS,,} = "ubuntu" ] && [[ ${RELEASE} =~ ^(22.04|20.04|18.04|19.10|11) ]]; then echo "Adding apt-repository ppa:ondrej/php" sudo apt-get install -y software-properties-common || _install_status 1 "Unable to install dependency" @@ -203,10 +228,14 @@ function _install_dependencies() { if [ ${OS,,} = "debian" ] || [ ${OS,,} = "ubuntu" ]; then dhcpcd_package="dhcpcd5" fi + if [ ${OS,,} = "ubuntu" ]; then + iw_package="iw" + fi + # Set dconf-set-selections echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections - sudo apt-get install -y lighttpd git hostapd dnsmasq iptables-persistent $php_package $dhcpcd_package vnstat qrencode || _install_status 1 "Unable to install dependencies" + sudo apt-get install -y lighttpd git hostapd dnsmasq iptables-persistent $php_package $dhcpcd_package $iw_package vnstat qrencode || _install_status 1 "Unable to install dependencies" _install_status 0 }