Skip to content

Commit

Permalink
Merge pull request #1354 from RaspAP/maint/debian12-distros
Browse files Browse the repository at this point in the history
Extend support to latest Debian distros (non-RPi OS)
  • Loading branch information
billz authored Aug 1, 2023
2 parents 16309a1 + 186af54 commit 41445b1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/hostapd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 8 additions & 6 deletions includes/dhcp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
33 changes: 31 additions & 2 deletions installers/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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*)
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
}

Expand Down

0 comments on commit 41445b1

Please sign in to comment.