Merge pull request #1183 from RaspAP/feature/ubuntu20-armbian22

Extend support to Ubuntu 20.04 / Armbian 22
This commit is contained in:
Bill Zimmerman 2022-06-23 18:12:10 +02:00 committed by GitHub
commit e6b6e8eafc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 100 additions and 10 deletions

View File

@ -75,5 +75,16 @@ class Sysinfo
return $status;
}
public function operatingSystem()
{
$os_desc = shell_exec("lsb_release -sd");
return $os_desc;
}
public function kernelVersion()
{
$kernel = shell_exec("uname -r");
return $kernel;
}
}

View File

@ -11,7 +11,7 @@ wpa_passphrase=ChangeMe
interface=wlan0
wpa=2
wpa_pairwise=CCMP
country_code=
country_code=GB
## Rapberry Pi 3 specific to on board WLAN/WiFi
#ieee80211n=1 # 802.11n support (Raspberry Pi 3)
#wmm_enabled=1 # QoS support (Raspberry Pi 3)

View File

@ -0,0 +1,11 @@
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
bridges:
br0:
dhcp4: yes
interfaces:
- eth0

View File

@ -7,6 +7,9 @@ require_once 'includes/config.php';
getWifiInterface();
$system = new \RaspAP\System\Sysinfo;
$os = $system->operatingSystem();
/**
* Initialize hostapd values, display interface
*
@ -15,6 +18,7 @@ function DisplayHostAPDConfig()
{
$status = new StatusMessages();
$system = new \RaspAP\System\Sysinfo;
$operatingSystem = $system->operatingSystem();
$arrConfig = array();
$arr80211Standard = [
'a' => '802.11a - 5 GHz',
@ -119,7 +123,8 @@ function DisplayHostAPDConfig()
"arrEncType",
"arrTxPower",
"txpower",
"arrHostapdConf"
"arrHostapdConf",
"operatingSystem"
)
);
}

View File

@ -159,6 +159,8 @@ function DisplaySystem()
$hostname = $system->hostname();
$uptime = $system->uptime();
$cores = $system->processorCount();
$os = $system->operatingSystem();
$kernel = $system->kernelVersion();
// mem used
$memused = $system->usedMemory();
@ -215,6 +217,8 @@ function DisplaySystem()
"hostname",
"uptime",
"cores",
"os",
"kernel",
"memused",
"memused_status",
"memused_led",

View File

@ -41,6 +41,7 @@ function _install_raspap() {
_display_welcome
_config_installation
_update_system_packages
_manage_systemd_services
_install_dependencies
_enable_php_lighttpd
_create_raspap_directories
@ -157,6 +158,37 @@ function _set_php_package() {
esac
}
# Prompts the user to stop & disable Debian's systemd-networkd services.
# It isn't possible to mix Debian networking with dhcpcd.
# On Ubuntu 20.04 / Armbian 22, the systemd-resolved service uses port 53
# by default which prevents dnsmasq from starting.
function _manage_systemd_services() {
_install_log "Checking for systemd network services"
services=( "systemd-networkd" "systemd-resolved" )
for svc in "${services[@]}"; do
# Prompt to disable systemd service
if systemctl is-active --quiet "$svc".service; then
echo -n "Stop and disable ${svc} service? [Y/n]: "
if [ "$assume_yes" == 0 ]; then
read answer < /dev/tty
if [ "$answer" != "${answer#[Nn]}" ]; then
echo -e
else
sudo systemctl stop "$svc".service || _install_status 1 "Unable to stop ${svc}.service"
sudo systemctl disable "$svc".service || _install_status 1 "Unable to disable ${svc}.service"
fi
else
sudo systemctl stop "$svc".service || _install_status 1 "Unable to stop ${svc}.service"
sudo systemctl disable "$svc".service || _install_status 1 "Unable to disable ${svc}.service"
fi
else
echo "${svc}.service is not running (ok)"
fi
done
_install_status 0
}
# Runs a system software update to make sure we're using all fresh packages
function _install_dependencies() {
_install_log "Installing required packages"
@ -166,7 +198,7 @@ function _install_dependencies() {
sudo apt-get install $apt_option software-properties-common || _install_status 1 "Unable to install dependency"
sudo add-apt-repository $apt_option ppa:ondrej/php || _install_status 1 "Unable to add-apt-repository ppa:ondrej/php"
else
echo "PHP will be installed from the main deb sources list"
echo "${php_package} will be installed from the main deb sources list"
fi
if [ ${OS,,} = "debian" ] || [ ${OS,,} = "ubuntu" ]; then
dhcpcd_package="dhcpcd5"
@ -521,17 +553,21 @@ function _default_configuration() {
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"
echo "Changing file ownership of ${raspap_network}/defaults.json"
echo "Changing file ownership of ${raspap_network}defaults.json"
sudo chown $raspap_user:$raspap_user "$raspap_network"/defaults.json || _install_status 1 "Unable to change file ownership for defaults.json"
echo "Checking for existence of /etc/dnsmasq.d"
[ -d /etc/dnsmasq.d ] || sudo mkdir /etc/dnsmasq.d
echo "Copying bridged AP config to /etc/systemd/network"
sudo systemctl stop systemd-networkd
sudo systemctl disable systemd-networkd
sudo cp $webroot_dir/config/raspap-bridge-br0.netdev /etc/systemd/network/raspap-bridge-br0.netdev || _install_status 1 "Unable to move br0 netdev file"
sudo cp $webroot_dir/config/raspap-br0-member-eth0.network /etc/systemd/network/raspap-br0-member-eth0.network || _install_status 1 "Unable to move br0 member file"
# Copy OS-specific bridge default config
if [ ${OS,,} = "ubuntu" ] && [[ ${RELEASE} =~ ^(20.04|19.10|18.04) ]]; then
echo "Copying bridged AP config to /etc/netplan"
sudo cp $webroot_dir/config/raspap-bridge-br0.netplan /etc/netplan/raspap-bridge-br0.netplan || _install_status 1 "Unable to move br0 netplan file"
else
echo "Copying bridged AP config to /etc/systemd/network"
sudo cp $webroot_dir/config/raspap-bridge-br0.netdev /etc/systemd/network/raspap-bridge-br0.netdev || _install_status 1 "Unable to move br0 netdev file"
sudo cp $webroot_dir/config/raspap-br0-member-eth0.network /etc/systemd/network/raspap-br0-member-eth0.network || _install_status 1 "Unable to move br0 member file"
fi
echo "Copying primary RaspAP config to includes/config.php"
if [ ! -f "$webroot_dir/includes/config.php" ]; then
@ -613,6 +649,15 @@ function _patch_system_files() {
_install_log "Unmasking and enabling hostapd service"
sudo systemctl unmask hostapd.service
sudo systemctl enable hostapd.service
# Set correct DAEMON_CONF path for hostapd (Ubuntu20 + Armbian22)
if [ ${OS,,} = "ubuntu" ] && [[ ${RELEASE} =~ ^(20.04|19.10|18.04) ]]; then
conf="/etc/default/hostapd"
key="DAEMON_CONF"
value="/etc/hostapd/hostapd.conf"
echo "Setting default ${key} path to ${value}"
sudo sed -i "/^$key/ { s/^#//; s%=.*%=\"$value\"%; }" "$conf" || _install_status 1 "Unable to set value in ${conf}"
fi
_install_status 0
}

View File

@ -62,4 +62,5 @@ www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wireguard/*.conf
www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wireguard/wg-*.key
www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/wireguard/*.conf
www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/wireguard/wg-*.key
www-data ALL=(ALL) NOPASSWD:/usr/sbin/netplan

Binary file not shown.

View File

@ -737,6 +737,12 @@ msgstr "Web server port"
msgid "Web server bind address"
msgstr "Web server bind address"
msgid "OS"
msgstr "OS"
msgid "Kernel"
msgstr "Kernel"
#: includes/themes.php
msgid "Theme settings"
msgstr "Theme settings"

View File

@ -4,7 +4,8 @@
<div class="col-md-6 mb-2">
<div class="custom-control custom-switch">
<?php $checked = $arrHostapdConf['BridgedEnable'] == 1 ? 'checked="checked"' : '' ?>
<input class="custom-control-input" id="chxbridgedenable" name="bridgedEnable" type="checkbox" value="1" <?php echo $checked ?> />
<?php $disabled = strpos(strtolower($operatingSystem),'ubuntu') !== false ? 'disabled="disabled"' : '' ?>
<input class="custom-control-input" id="chxbridgedenable" name="bridgedEnable" type="checkbox" value="1" <?php echo $checked ?> <?php echo $disabled ?> />
<label class="custom-control-label" for="chxbridgedenable"><?php echo _("Bridged AP mode"); ?></label>
</div>
</div>

View File

@ -16,6 +16,12 @@ include('includes/sysstats.php');
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Pi Revision"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars(RPiVersion(), ENT_QUOTES); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("OS"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($os, ENT_QUOTES); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Kernel"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($kernel, ENT_QUOTES); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Uptime"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($uptime, ENT_QUOTES); ?></div>
</div>