diff --git a/app/lib/system.php b/app/lib/system.php index ee21ad84..22f7255a 100644 --- a/app/lib/system.php +++ b/app/lib/system.php @@ -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; + } } diff --git a/config/hostapd.conf b/config/hostapd.conf index 856e4a1b..cdb2a881 100644 --- a/config/hostapd.conf +++ b/config/hostapd.conf @@ -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) diff --git a/config/raspap-bridge-br0.netplan b/config/raspap-bridge-br0.netplan new file mode 100644 index 00000000..e00b2833 --- /dev/null +++ b/config/raspap-bridge-br0.netplan @@ -0,0 +1,11 @@ +network: + version: 2 + renderer: networkd + ethernets: + eth0: + dhcp4: no + bridges: + br0: + dhcp4: yes + interfaces: + - eth0 diff --git a/includes/hostapd.php b/includes/hostapd.php index 812d81ee..d1160d6d 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -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" ) ); } diff --git a/includes/system.php b/includes/system.php index db7f3c48..56f5e111 100755 --- a/includes/system.php +++ b/includes/system.php @@ -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", diff --git a/installers/common.sh b/installers/common.sh index f63a5baa..6e89f307 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -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 } diff --git a/installers/raspap.sudoers b/installers/raspap.sudoers index 945aa0c8..000f8057 100644 --- a/installers/raspap.sudoers +++ b/installers/raspap.sudoers @@ -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 diff --git a/locale/en_US/LC_MESSAGES/messages.mo b/locale/en_US/LC_MESSAGES/messages.mo index 3433cbf6..703307ef 100644 Binary files a/locale/en_US/LC_MESSAGES/messages.mo and b/locale/en_US/LC_MESSAGES/messages.mo differ diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index e179dc17..445a3b31 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -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" diff --git a/templates/hostapd/advanced.php b/templates/hostapd/advanced.php index f331734b..89d90c72 100644 --- a/templates/hostapd/advanced.php +++ b/templates/hostapd/advanced.php @@ -4,7 +4,8 @@