mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge pull request #1354 from RaspAP/maint/debian12-distros
Extend support to latest Debian distros (non-RPi OS)
This commit is contained in:
commit
41445b191d
@ -20,5 +20,5 @@ country_code=GB
|
|||||||
## RaspAP wireless client AP mode
|
## RaspAP wireless client AP mode
|
||||||
#interface=uap0
|
#interface=uap0
|
||||||
|
|
||||||
## RaspAP bridge AP mode (disabled by default)
|
## RaspAP bridge AP mode, disabled by default
|
||||||
#bridge=br0
|
#bridge=br0
|
||||||
|
@ -187,12 +187,14 @@ function updateDnsmasqConfig($iface,$status)
|
|||||||
}
|
}
|
||||||
// Static leases
|
// Static leases
|
||||||
$staticLeases = array();
|
$staticLeases = array();
|
||||||
for ($i=0; $i < count($_POST["static_leases"]["mac"]); $i++) {
|
if (isset($_POST["static_leases"]["mac"])) {
|
||||||
$mac = trim($_POST["static_leases"]["mac"][$i]);
|
for ($i=0; $i < count($_POST["static_leases"]["mac"]); $i++) {
|
||||||
$ip = trim($_POST["static_leases"]["ip"][$i]);
|
$mac = trim($_POST["static_leases"]["mac"][$i]);
|
||||||
$comment = trim($_POST["static_leases"]["comment"][$i]);
|
$ip = trim($_POST["static_leases"]["ip"][$i]);
|
||||||
if ($mac != "" && $ip != "") {
|
$comment = trim($_POST["static_leases"]["comment"][$i]);
|
||||||
$staticLeases[] = array('mac' => $mac, 'ip' => $ip, 'comment' => $comment);
|
if ($mac != "" && $ip != "") {
|
||||||
|
$staticLeases[] = array('mac' => $mac, 'ip' => $ip, 'comment' => $comment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort ascending by IPs
|
// Sort ascending by IPs
|
||||||
|
@ -52,11 +52,15 @@ function mask2cidr($mask)
|
|||||||
*/
|
*/
|
||||||
function cidr2mask($cidr)
|
function cidr2mask($cidr)
|
||||||
{
|
{
|
||||||
$ta = substr ($cidr, strpos ($cidr, '/') + 1) * 1;
|
$ipParts = explode('/', $cidr);
|
||||||
$netmask = str_split (str_pad (str_pad ('', $ta, '1'), 32, '0'), 8);
|
$ip = $ipParts[0];
|
||||||
foreach ($netmask as &$element)
|
$prefixLength = $ipParts[1];
|
||||||
$element = bindec ($element);
|
|
||||||
return join ('.', $netmask);
|
$ipLong = ip2long($ip);
|
||||||
|
$netmaskLong = bindec(str_pad(str_repeat('1', $prefixLength), 32, '0'));
|
||||||
|
$netmask = long2ip($netmaskLong);
|
||||||
|
|
||||||
|
return $netmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +140,13 @@ function _get_linux_distro() {
|
|||||||
# Sets php package option based on Linux version, abort if unsupported distro
|
# Sets php package option based on Linux version, abort if unsupported distro
|
||||||
function _set_php_package() {
|
function _set_php_package() {
|
||||||
case $RELEASE in
|
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"
|
php_package="php7.4-cgi"
|
||||||
phpcgiconf="/etc/php/7.4/cgi/php.ini" ;;
|
phpcgiconf="/etc/php/7.4/cgi/php.ini" ;;
|
||||||
10*|11*)
|
10*|11*)
|
||||||
@ -165,6 +171,8 @@ function _set_php_package() {
|
|||||||
function _manage_systemd_services() {
|
function _manage_systemd_services() {
|
||||||
_install_log "Checking for systemd network services"
|
_install_log "Checking for systemd network services"
|
||||||
|
|
||||||
|
_check_notify_ubuntu
|
||||||
|
|
||||||
services=( "systemd-networkd" "systemd-resolved" )
|
services=( "systemd-networkd" "systemd-resolved" )
|
||||||
for svc in "${services[@]}"; do
|
for svc in "${services[@]}"; do
|
||||||
# Prompt to disable systemd service
|
# Prompt to disable systemd service
|
||||||
@ -189,10 +197,27 @@ function _manage_systemd_services() {
|
|||||||
_install_status 0
|
_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
|
# Runs a system software update to make sure we're using all fresh packages
|
||||||
function _install_dependencies() {
|
function _install_dependencies() {
|
||||||
_install_log "Installing required packages"
|
_install_log "Installing required packages"
|
||||||
_set_php_package
|
_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
|
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"
|
echo "Adding apt-repository ppa:ondrej/php"
|
||||||
sudo apt-get install -y software-properties-common || _install_status 1 "Unable to install dependency"
|
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
|
if [ ${OS,,} = "debian" ] || [ ${OS,,} = "ubuntu" ]; then
|
||||||
dhcpcd_package="dhcpcd5"
|
dhcpcd_package="dhcpcd5"
|
||||||
fi
|
fi
|
||||||
|
if [ ${OS,,} = "ubuntu" ]; then
|
||||||
|
iw_package="iw"
|
||||||
|
fi
|
||||||
|
|
||||||
# Set dconf-set-selections
|
# Set dconf-set-selections
|
||||||
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-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
|
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
|
_install_status 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user