From a87772860aeb9319d73da55a5a4fc1ab9c848e08 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 26 Jan 2024 20:28:22 +0100 Subject: [PATCH 01/50] chore: bump base OS to 'bookworm' Signed-off-by: Stephan Wendel --- config/armbian/bananapim2zero | 4 ++-- config/armbian/orangepi3lts | 4 ++-- config/armbian/orangepi4lts | 4 ++-- config/orangepi/orangepi_zero2 | 4 ++-- config/raspberry/rpi32 | 9 ++------- config/raspberry/rpi64 | 10 ++-------- src/modules/piconfig/start_chroot_script | 5 ++++- 7 files changed, 16 insertions(+), 24 deletions(-) diff --git a/config/armbian/bananapim2zero b/config/armbian/bananapim2zero index 9c19be38d..d3bfac98b 100644 --- a/config/armbian/bananapim2zero +++ b/config/armbian/bananapim2zero @@ -3,8 +3,8 @@ # shellcheck enable=require-variable-braces # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-bananapi_m2_zero_bullseye.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-bananapi_m2_zero_bullseye.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-bananapi_m2_zero_bookworm.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-bananapi_m2_zero_bookworm.img.xz" # export Variables export BASE_ARCH diff --git a/config/armbian/orangepi3lts b/config/armbian/orangepi3lts index fad40eb06..a81dbaa06 100644 --- a/config/armbian/orangepi3lts +++ b/config/armbian/orangepi3lts @@ -5,8 +5,8 @@ BASE_ARCH="arm64" # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts_bullseye.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts_bullseye.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts_bookworm.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts_bookworm.img.xz" # export Variables export BASE_ARCH diff --git a/config/armbian/orangepi4lts b/config/armbian/orangepi4lts index 6fbcf889a..0bc5cb703 100644 --- a/config/armbian/orangepi4lts +++ b/config/armbian/orangepi4lts @@ -5,8 +5,8 @@ BASE_ARCH="arm64" # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bookworm.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bookworm.img.xz" # export Variables export BASE_ARCH diff --git a/config/orangepi/orangepi_zero2 b/config/orangepi/orangepi_zero2 index f494e4874..243d11bb2 100644 --- a/config/orangepi/orangepi_zero2 +++ b/config/orangepi/orangepi_zero2 @@ -5,8 +5,8 @@ BASE_ARCH="arm64" # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2_bullseye.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2_bullseye.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2_bookworm.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2_bookworm.img.xz" # export Variables export BASE_ARCH diff --git a/config/raspberry/rpi32 b/config/raspberry/rpi32 index 8239ff3c7..8458c5a83 100644 --- a/config/raspberry/rpi32 +++ b/config/raspberry/rpi32 @@ -4,13 +4,8 @@ # Declare Variables before exporting. # See https://www.shellcheck.net/wiki/SC2155 -# Keep for Bookworm template -# DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha256" -# DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent" - -# New locations after Bullseye turned into 'oldstable' -DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-10-10/2023-05-03-raspios-bullseye-armhf-lite.img.xz.sha256" -DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-10-10/2023-05-03-raspios-bullseye-armhf-lite.img.xz.torrent" +DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha256" +DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent" export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE diff --git a/config/raspberry/rpi64 b/config/raspberry/rpi64 index 01c486d33..3a25464b8 100644 --- a/config/raspberry/rpi64 +++ b/config/raspberry/rpi64 @@ -6,14 +6,8 @@ BASE_ARCH="arm64" -# Keep for Bookworm template -# DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" -# DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" - -# New locations after Bullseye turned into 'oldstable' -DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-10-10/2023-05-03-raspios-bullseye-arm64-lite.img.xz.sha256" -DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-10-10/2023-05-03-raspios-bullseye-arm64-lite.img.xz.torrent" - +DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" +DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" # export variables export BASE_ARCH diff --git a/src/modules/piconfig/start_chroot_script b/src/modules/piconfig/start_chroot_script index 483f8adf8..2ac22c378 100644 --- a/src/modules/piconfig/start_chroot_script +++ b/src/modules/piconfig/start_chroot_script @@ -64,7 +64,10 @@ check_install_pkgs i2c-tools echo_green "Disabling Bluetooth related services..." systemctl_if_exists disable hciuart.service systemctl_if_exists disable bluetooth.service -systemctl_if_exists disable bluealsa.service +# bookworm patch +if ! grep "bookworm" /etc/os-release; then + systemctl_if_exists disable bluealsa.service +fi # Step 11: Increase swapfile size if [[ -f "${PICONFIG_SWAP_CONF_FILE}" ]]; then From e8f4533956a52965be3fe5b6c52a878abf6b9954 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 26 Jan 2024 21:01:13 +0100 Subject: [PATCH 02/50] fix: fix no space left error Bump rootfs size with additional 1GB space Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- config/orangepi/default | 2 +- config/raspberry/default | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/armbian/default b/config/armbian/default index 151b69826..9abb4420c 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -18,7 +18,7 @@ BASE_IMAGE_RASPBIAN="no" # partition resizing BASE_ROOT_PARTITION="2" -BASE_IMAGE_ENLARGEROOT=2500 +BASE_IMAGE_ENLARGEROOT=3500 BASE_IMAGE_RESIZEROOT=600 # Compress not needed due compression done in workflow BASE_RELEASE_COMPRESS=no diff --git a/config/orangepi/default b/config/orangepi/default index 6fbaafaac..941575260 100644 --- a/config/orangepi/default +++ b/config/orangepi/default @@ -18,7 +18,7 @@ BASE_IMAGE_RASPBIAN="no" # partition resizing BASE_ROOT_PARTITION="2" -BASE_IMAGE_ENLARGEROOT=2500 +BASE_IMAGE_ENLARGEROOT=3500 BASE_IMAGE_RESIZEROOT=600 # Compress not needed due compression done in workflow BASE_RELEASE_COMPRESS=no diff --git a/config/raspberry/default b/config/raspberry/default index 0fd604202..acf66e3b4 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -4,7 +4,7 @@ # Declare Variables before exporting. # See https://www.shellcheck.net/wiki/SC2155 -BASE_IMAGE_ENLARGEROOT=4500 +BASE_IMAGE_ENLARGEROOT=5500 BASE_IMAGE_RESIZEROOT=600 # Compress not needed due compression done in workflow BASE_RELEASE_COMPRESS=no From ec559a7d3d996f3f5fca6044509f1815d3677360 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 8 Jun 2024 10:23:30 +0200 Subject: [PATCH 03/50] fix: fix orangepi zero2 url Signed-off-by: Stephan Wendel --- config/armbian/orangepi_zero2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/armbian/orangepi_zero2 b/config/armbian/orangepi_zero2 index 243d11bb2..83ea234c8 100644 --- a/config/armbian/orangepi_zero2 +++ b/config/armbian/orangepi_zero2 @@ -5,8 +5,8 @@ BASE_ARCH="arm64" # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2_bookworm.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2_bookworm.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi_zero2_bookworm.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi_zero2_bookworm.img.xz" # export Variables export BASE_ARCH From 4072981b46c3fa29c38cd5d82facd48914c8f4a3 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 12 Jun 2024 21:17:41 +0200 Subject: [PATCH 04/50] fix(build): disable pkgupgrade Due failing kernel upgrade build errors out Signed-off-by: Stephan Wendel --- config/raspberry/default | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/raspberry/default b/config/raspberry/default index 586e4f57e..f0a876d97 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -9,7 +9,9 @@ BASE_IMAGE_RESIZEROOT=600 # Compress not needed due compression done in workflow BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images -MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" +# MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" +# Disable pkgupgrade for now +MODULES="base(udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" # export Variables export DOWNLOAD_BASE_URL From 431c6bb4a58f56207df778d45f9d3878a18591d1 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 12 Jun 2024 21:24:01 +0200 Subject: [PATCH 05/50] chore(build): add bullseye control group Signed-off-by: Stephan Wendel --- .github/workflow_config.yml | 3 +++ config/armbian/orangepi4lts-bullseye | 21 +++++++++++++++++++++ config/raspberry/rpi64-bullseye | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 config/armbian/orangepi4lts-bullseye create mode 100644 config/raspberry/rpi64-bullseye diff --git a/.github/workflow_config.yml b/.github/workflow_config.yml index 1e6b40b30..14fbd989b 100644 --- a/.github/workflow_config.yml +++ b/.github/workflow_config.yml @@ -26,6 +26,9 @@ buildtest: - raspberry/rpi64 # rpi 64 with KS - raspberry/rpi64-ks + # Control group + - raspberry/rpi64-bullseye + - armbian/orangepi4lts-bullseye # This is used to setup release build chain. # Each entry will be used in setup matrix for releases diff --git a/config/armbian/orangepi4lts-bullseye b/config/armbian/orangepi4lts-bullseye new file mode 100644 index 000000000..6fbcf889a --- /dev/null +++ b/config/armbian/orangepi4lts-bullseye @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Shebang for better file detection +# shellcheck enable=require-variable-braces + +BASE_ARCH="arm64" + +# Image source +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz" + +# export Variables +export BASE_ARCH +export DOWNLOAD_URL_CHECKSUM +export DOWNLOAD_URL_IMAGE + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_PRETTY_SBC_NAME="Orange Pi 4 LTS" +# shellcheck disable=SC2034 +JSON_SUPPORTED_SBC="orangepi4lts-64bit" diff --git a/config/raspberry/rpi64-bullseye b/config/raspberry/rpi64-bullseye new file mode 100644 index 000000000..b300c976b --- /dev/null +++ b/config/raspberry/rpi64-bullseye @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Shebang for better file detection + +# Declare Variables before exporting. +# See https://www.shellcheck.net/wiki/SC2155 + +BASE_ARCH="arm64" + +DOWNLOAD_BASE_URL="https://downloads.raspberrypi.org/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-12-06/2023-12-05-raspios-bullseye-arm64-lite.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}.torrent" + +BASE_BOOT_MOUNT_PATH=boot + +# export variables +export BASE_ARCH +export DOWNLOAD_URL_CHECKSUM +export DOWNLOAD_URL_IMAGE +export BASE_BOOT_MOUNT_PATH + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_SUPPORTED_SBC="pi3-64bit pi4-64bit" From 32c597746629cb6c2ed9a7b8bc3f5ee7b7f4fd9d Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 12 Jun 2024 21:28:28 +0200 Subject: [PATCH 06/50] fix(build): fix shellcheck errors Signed-off-by: Stephan Wendel --- config/raspberry/rpi64 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/raspberry/rpi64 b/config/raspberry/rpi64 index 31e55a02b..3a25464b8 100644 --- a/config/raspberry/rpi64 +++ b/config/raspberry/rpi64 @@ -11,6 +11,8 @@ DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest. # export variables export BASE_ARCH +export DOWNLOAD_URL_CHECKSUM +export DOWNLOAD_URL_IMAGE ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! From 0603d38278bbc92ca08a1f2f4890c2c82e473ba2 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 12 Jun 2024 21:35:56 +0200 Subject: [PATCH 07/50] fix: fix klipperscreen build Moved DOWNLOAD_URL_* to default Signed-off-by: Stephan Wendel --- config/raspberry/default | 3 +++ config/raspberry/rpi64 | 5 ----- config/raspberry/rpi64-ks | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config/raspberry/default b/config/raspberry/default index f0a876d97..0f19241c8 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -13,6 +13,9 @@ BASE_RELEASE_COMPRESS=no # Disable pkgupgrade for now MODULES="base(udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" +DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" +DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" + # export Variables export DOWNLOAD_BASE_URL export DOWNLOAD_URL_CHECKSUM diff --git a/config/raspberry/rpi64 b/config/raspberry/rpi64 index 3a25464b8..3a29f75e2 100644 --- a/config/raspberry/rpi64 +++ b/config/raspberry/rpi64 @@ -6,13 +6,8 @@ BASE_ARCH="arm64" -DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" -DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" - # export variables export BASE_ARCH -export DOWNLOAD_URL_CHECKSUM -export DOWNLOAD_URL_IMAGE ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! diff --git a/config/raspberry/rpi64-ks b/config/raspberry/rpi64-ks index 103f4f8e6..87daa6975 100644 --- a/config/raspberry/rpi64-ks +++ b/config/raspberry/rpi64-ks @@ -7,7 +7,7 @@ BASE_ARCH="arm64" # Changed modules -MODULES="base,pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,klipperscreen,crowsnest,sonar,password-for-sudo),postrename" +MODULES="base(udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,klipperscreen,crowsnest,sonar,password-for-sudo),postrename)" # export variables export BASE_ARCH From 3687a0eeb550444db4d33d1787d872f905de8eda Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 12 Jun 2024 21:40:29 +0200 Subject: [PATCH 08/50] fix: drop armbian_net module for bookworm images Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- config/armbian/orangepi4lts-bullseye | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/armbian/default b/config/armbian/default index f0fd842c0..283900e05 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -23,7 +23,7 @@ BASE_IMAGE_RESIZEROOT=600 # Compress not needed due compression done in workflow BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images -MODULES="base(pkgupgrade,udev_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar))" +MODULES="base(pkgupgrade,udev_fix,armbian(mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar))" # export Variables export DOWNLOAD_BASE_URL diff --git a/config/armbian/orangepi4lts-bullseye b/config/armbian/orangepi4lts-bullseye index 6fbcf889a..09a8bc6fb 100644 --- a/config/armbian/orangepi4lts-bullseye +++ b/config/armbian/orangepi4lts-bullseye @@ -8,10 +8,14 @@ BASE_ARCH="arm64" DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz.sha256" DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz" +MODULES="base(pkgupgrade,udev_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar))" + + # export Variables export BASE_ARCH export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE +export MODULES ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! From 24219bc2654df816c3001fb74c260f44f6fec450 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 12 Jun 2024 22:18:25 +0200 Subject: [PATCH 09/50] fix: fix rpi64-ks Build fails due to lack of diskspace Signed-off-by: Stephan Wendel --- config/raspberry/rpi64-ks | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/raspberry/rpi64-ks b/config/raspberry/rpi64-ks index 87daa6975..f50bf6a1f 100644 --- a/config/raspberry/rpi64-ks +++ b/config/raspberry/rpi64-ks @@ -6,12 +6,15 @@ BASE_ARCH="arm64" +BASE_IMAGE_ENLARGEROOT=6500 + # Changed modules MODULES="base(udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,klipperscreen,crowsnest,sonar,password-for-sudo),postrename)" # export variables export BASE_ARCH export MODULES +export BASE_IMAGE_ENLARGEROOT ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! From 51d4abc51ec14ac833d25bbdf7bafc5d50927d60 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 12 Jun 2024 22:29:13 +0200 Subject: [PATCH 10/50] fix: fix config paths for bookworm Signed-off-by: Stephan Wendel --- src/modules/piconfig/config | 5 ---- src/modules/piconfig/start_chroot_script | 35 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/modules/piconfig/config b/src/modules/piconfig/config index 53d69e678..86965e9f0 100644 --- a/src/modules/piconfig/config +++ b/src/modules/piconfig/config @@ -1,11 +1,6 @@ #!/usr/bin/env bash # Shebang for better file detection -[ -n "$PICONFIG_CONFIG_TXT_FILE" ] || PICONFIG_CONFIG_TXT_FILE="/boot/config.txt" -[ -n "$PICONFIG_CMDLINE_TXT_FILE" ] || PICONFIG_CMDLINE_TXT_FILE="/boot/cmdline.txt" -[ -n "$PICONFIG_CONFIG_BAK_FILE" ] || PICONFIG_CONFIG_BAK_FILE="/boot/config.txt.backup" -[ -n "$PICONFIG_CMDLINE_BAK_FILE" ] || PICONFIG_CMDLINE_BAK_FILE="/boot/cmdline.txt.backup" - [ -n "$PICONFIG_SWAP_CONF_FILE" ] || PICONFIG_SWAP_CONF_FILE="/etc/dphys-swapfile" [ -n "$PICONFIG_SWAP_SIZE" ] || PICONFIG_SWAP_SIZE="256" [ -n "$PICONFIG_SWAP_MAX" ] || PICONFIG_SWAP_MAX="1024" diff --git a/src/modules/piconfig/start_chroot_script b/src/modules/piconfig/start_chroot_script index 2ac22c378..a4c365b98 100644 --- a/src/modules/piconfig/start_chroot_script +++ b/src/modules/piconfig/start_chroot_script @@ -20,6 +20,41 @@ fi source /common.sh install_cleanup_trap +## Configuration helper + +DISTS="bookworm bullseye" + +for dist in ${DISTS}; do + if [[ "$(grep -c "${dist}" ./os-release)" -gt 1 ]]; then + printf "%s\n" "${dist}" + PICONFIG_BASE_DIST="${dist}" + fi +done + +case "${PICONFIG_BASE_DIST}" in + "bullseye") + echo "Set to Dist: bullseye" + [ -n "$PICONFIG_CONFIG_TXT_FILE" ] || PICONFIG_CONFIG_TXT_FILE="/boot/config.txt" + [ -n "$PICONFIG_CMDLINE_TXT_FILE" ] || PICONFIG_CMDLINE_TXT_FILE="/boot/cmdline.txt" + [ -n "$PICONFIG_CONFIG_BAK_FILE" ] || PICONFIG_CONFIG_BAK_FILE="/boot/config.txt.backup" + [ -n "$PICONFIG_CMDLINE_BAK_FILE" ] || PICONFIG_CMDLINE_BAK_FILE="/boot/cmdline.txt.backup" + ;; + + "bookworm") + echo "Set to Dist: bookworm" + [ -n "$PICONFIG_CONFIG_TXT_FILE" ] || PICONFIG_CONFIG_TXT_FILE="/boot/firmware/config.txt" + [ -n "$PICONFIG_CMDLINE_TXT_FILE" ] || PICONFIG_CMDLINE_TXT_FILE="/boot/firmware/cmdline.txt" + [ -n "$PICONFIG_CONFIG_BAK_FILE" ] || PICONFIG_CONFIG_BAK_FILE="/boot/firmware/config.txt.backup" + [ -n "$PICONFIG_CMDLINE_BAK_FILE" ] || PICONFIG_CMDLINE_BAK_FILE="/boot/firmware/cmdline.txt.backup" + ;; + + *) + echo "Unkown dist type... Exiting!" + exit 1 + ;; +esac + + # Step 1: Copy msos_config.txt echo_green "Copying temporary file ..." unpack /filesystem/tmp /tmp root From 77a0190176f5641880aa00cfbb83bb25ad06c0a9 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 12 Jun 2024 22:35:13 +0200 Subject: [PATCH 11/50] fix: fix path in piconfig module Signed-off-by: Stephan Wendel --- src/modules/piconfig/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/piconfig/start_chroot_script b/src/modules/piconfig/start_chroot_script index a4c365b98..7c608d4ec 100644 --- a/src/modules/piconfig/start_chroot_script +++ b/src/modules/piconfig/start_chroot_script @@ -25,7 +25,7 @@ install_cleanup_trap DISTS="bookworm bullseye" for dist in ${DISTS}; do - if [[ "$(grep -c "${dist}" ./os-release)" -gt 1 ]]; then + if [[ "$(grep -c "${dist}" /etc/os-release)" -gt 1 ]]; then printf "%s\n" "${dist}" PICONFIG_BASE_DIST="${dist}" fi From b3d0b1c6cc88d8c5855f6be53e90e7da26aee0ec Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 16 Jun 2024 14:31:34 +0200 Subject: [PATCH 12/50] chore: reenable pkgupgrade for debug purpose Signed-off-by: Stephan Wendel --- config/raspberry/default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/raspberry/default b/config/raspberry/default index 0f19241c8..64a581579 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -11,7 +11,7 @@ BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images # MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" # Disable pkgupgrade for now -MODULES="base(udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" +MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" From 9cd70757c0851dc490804a43c153eda252a50987 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 16 Jun 2024 14:50:49 +0200 Subject: [PATCH 13/50] test: set boot partition Signed-off-by: Stephan Wendel --- config/raspberry/default | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/raspberry/default b/config/raspberry/default index 64a581579..8279f8252 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -16,6 +16,8 @@ MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinst DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" +BASE_BOOT_MOUNT_PATH=boot + # export Variables export DOWNLOAD_BASE_URL export DOWNLOAD_URL_CHECKSUM From 40020e37b3a3eeb83a906824a78a4fc2898e7981 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 16 Jun 2024 15:02:48 +0200 Subject: [PATCH 14/50] Revert "test: set boot partition" This reverts commit 9cd70757c0851dc490804a43c153eda252a50987. --- config/raspberry/default | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/raspberry/default b/config/raspberry/default index 8279f8252..64a581579 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -16,8 +16,6 @@ MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinst DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" -BASE_BOOT_MOUNT_PATH=boot - # export Variables export DOWNLOAD_BASE_URL export DOWNLOAD_URL_CHECKSUM From 0b50f06a2509100b4ccba37c8f2637d654659cfe Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 16 Jun 2024 15:03:03 +0200 Subject: [PATCH 15/50] Revert "chore: reenable pkgupgrade for debug purpose" This reverts commit b3d0b1c6cc88d8c5855f6be53e90e7da26aee0ec. --- config/raspberry/default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/raspberry/default b/config/raspberry/default index 64a581579..0f19241c8 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -11,7 +11,7 @@ BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images # MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" # Disable pkgupgrade for now -MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" +MODULES="base(udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" From cd0992907050d932f6c2014c9cb9a11365034bd8 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 16 Jun 2024 15:35:44 +0200 Subject: [PATCH 16/50] Revert "fix: fix path in piconfig module" This reverts commit 77a0190176f5641880aa00cfbb83bb25ad06c0a9. --- src/modules/piconfig/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/piconfig/start_chroot_script b/src/modules/piconfig/start_chroot_script index 7c608d4ec..a4c365b98 100644 --- a/src/modules/piconfig/start_chroot_script +++ b/src/modules/piconfig/start_chroot_script @@ -25,7 +25,7 @@ install_cleanup_trap DISTS="bookworm bullseye" for dist in ${DISTS}; do - if [[ "$(grep -c "${dist}" /etc/os-release)" -gt 1 ]]; then + if [[ "$(grep -c "${dist}" ./os-release)" -gt 1 ]]; then printf "%s\n" "${dist}" PICONFIG_BASE_DIST="${dist}" fi From 782961c35fa7370057db2d1206a1e3c2f056f0ba Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 16 Jun 2024 15:36:53 +0200 Subject: [PATCH 17/50] Revert "fix: fix config paths for bookworm" This reverts commit 51d4abc51ec14ac833d25bbdf7bafc5d50927d60. --- src/modules/piconfig/config | 5 ++++ src/modules/piconfig/start_chroot_script | 35 ------------------------ 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/modules/piconfig/config b/src/modules/piconfig/config index 86965e9f0..53d69e678 100644 --- a/src/modules/piconfig/config +++ b/src/modules/piconfig/config @@ -1,6 +1,11 @@ #!/usr/bin/env bash # Shebang for better file detection +[ -n "$PICONFIG_CONFIG_TXT_FILE" ] || PICONFIG_CONFIG_TXT_FILE="/boot/config.txt" +[ -n "$PICONFIG_CMDLINE_TXT_FILE" ] || PICONFIG_CMDLINE_TXT_FILE="/boot/cmdline.txt" +[ -n "$PICONFIG_CONFIG_BAK_FILE" ] || PICONFIG_CONFIG_BAK_FILE="/boot/config.txt.backup" +[ -n "$PICONFIG_CMDLINE_BAK_FILE" ] || PICONFIG_CMDLINE_BAK_FILE="/boot/cmdline.txt.backup" + [ -n "$PICONFIG_SWAP_CONF_FILE" ] || PICONFIG_SWAP_CONF_FILE="/etc/dphys-swapfile" [ -n "$PICONFIG_SWAP_SIZE" ] || PICONFIG_SWAP_SIZE="256" [ -n "$PICONFIG_SWAP_MAX" ] || PICONFIG_SWAP_MAX="1024" diff --git a/src/modules/piconfig/start_chroot_script b/src/modules/piconfig/start_chroot_script index a4c365b98..2ac22c378 100644 --- a/src/modules/piconfig/start_chroot_script +++ b/src/modules/piconfig/start_chroot_script @@ -20,41 +20,6 @@ fi source /common.sh install_cleanup_trap -## Configuration helper - -DISTS="bookworm bullseye" - -for dist in ${DISTS}; do - if [[ "$(grep -c "${dist}" ./os-release)" -gt 1 ]]; then - printf "%s\n" "${dist}" - PICONFIG_BASE_DIST="${dist}" - fi -done - -case "${PICONFIG_BASE_DIST}" in - "bullseye") - echo "Set to Dist: bullseye" - [ -n "$PICONFIG_CONFIG_TXT_FILE" ] || PICONFIG_CONFIG_TXT_FILE="/boot/config.txt" - [ -n "$PICONFIG_CMDLINE_TXT_FILE" ] || PICONFIG_CMDLINE_TXT_FILE="/boot/cmdline.txt" - [ -n "$PICONFIG_CONFIG_BAK_FILE" ] || PICONFIG_CONFIG_BAK_FILE="/boot/config.txt.backup" - [ -n "$PICONFIG_CMDLINE_BAK_FILE" ] || PICONFIG_CMDLINE_BAK_FILE="/boot/cmdline.txt.backup" - ;; - - "bookworm") - echo "Set to Dist: bookworm" - [ -n "$PICONFIG_CONFIG_TXT_FILE" ] || PICONFIG_CONFIG_TXT_FILE="/boot/firmware/config.txt" - [ -n "$PICONFIG_CMDLINE_TXT_FILE" ] || PICONFIG_CMDLINE_TXT_FILE="/boot/firmware/cmdline.txt" - [ -n "$PICONFIG_CONFIG_BAK_FILE" ] || PICONFIG_CONFIG_BAK_FILE="/boot/firmware/config.txt.backup" - [ -n "$PICONFIG_CMDLINE_BAK_FILE" ] || PICONFIG_CMDLINE_BAK_FILE="/boot/firmware/cmdline.txt.backup" - ;; - - *) - echo "Unkown dist type... Exiting!" - exit 1 - ;; -esac - - # Step 1: Copy msos_config.txt echo_green "Copying temporary file ..." unpack /filesystem/tmp /tmp root From 2b0bacd9bc82363e3a2f65659aa1397e5ac41af1 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 16 Jun 2024 16:15:08 +0200 Subject: [PATCH 18/50] feat: add modified pkgupgrade Trying to fix module behavior on faulty kernel upgrades Signed-off-by: Stephan Wendel --- config/raspberry/default | 2 +- src/modules/pkgupgrade/config | 8 ++++ src/modules/pkgupgrade/end_chroot_script | 18 +++++++++ src/modules/pkgupgrade/start_chroot_script | 45 ++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/modules/pkgupgrade/config create mode 100644 src/modules/pkgupgrade/end_chroot_script create mode 100644 src/modules/pkgupgrade/start_chroot_script diff --git a/config/raspberry/default b/config/raspberry/default index 0f19241c8..64a581579 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -11,7 +11,7 @@ BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images # MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" # Disable pkgupgrade for now -MODULES="base(udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" +MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" diff --git a/src/modules/pkgupgrade/config b/src/modules/pkgupgrade/config new file mode 100644 index 000000000..51ffd372a --- /dev/null +++ b/src/modules/pkgupgrade/config @@ -0,0 +1,8 @@ +[ -n "${PKGUPGRADE_DISTUPGRADE}" ] || PKGUPGRADE_DISTUPGRADE=y # y/n +# upgrade vs full upgrade. +[ -n "$PKGUPGRADE_DISTUPGRADE_METHOD" ] || PKGUPGRADE_DISTUPGRADE_METHOD=full-upgrade +[ -n "$PKGUPGRADE_USE_PREINSTALLER" ] || PKGUPGRADE_USE_PREINSTALLER=n # y/n +# Add Packages that should be PKGUPGRADEed. +[ -n "$PKGUPGRADE_PRE_INSTALL_PKGS" ] || PKGUPGRADE_PRE_INSTALL_PKGS="" +# Cleanup apt-cache on exit +[ -n "$PKGUPGRADE_CLEANUP" ] || PKGUPGRADE_CLEANUP="y" diff --git a/src/modules/pkgupgrade/end_chroot_script b/src/modules/pkgupgrade/end_chroot_script new file mode 100644 index 000000000..cbd6eaeac --- /dev/null +++ b/src/modules/pkgupgrade/end_chroot_script @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 by Stephan Wendel aka KwadFan +# +# This file may distributed under GPLv3 +######## + +## Revert Fix initramfs-tools Error on RaspiOS +if [[ -f /etc/rpi-issue ]] && [[ -f /etc/initramfs-tools/initramfs.conf ]]; then + sed -i 's/FSTYPE=ext4/FSTYPE=auto/' /etc/initramfs-tools/initramfs.conf +fi + +### Cleanup +if [ "${PKGUPGRADE_CLEANUP}" = "y" ]; then + apt-get clean -y + apt-get autoclean -y +fi + diff --git a/src/modules/pkgupgrade/start_chroot_script b/src/modules/pkgupgrade/start_chroot_script new file mode 100644 index 000000000..3d295b922 --- /dev/null +++ b/src/modules/pkgupgrade/start_chroot_script @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# Copyright 2021 by Stephan Wendel aka KwadFan +# +# This file may distributed under GPLv3 +######## + +## Source error handling, leave this in place +set -xe + +# Source CustomPIOS common.sh +source /common.sh +install_cleanup_trap + +### noninteractive Check +if [ -z "${DEBIAN_FRONTEND}" ]; then + export DEBIAN_FRONTEND=noninteractive +fi + + +## Fix initramfs-tools Error on RaspiOS + +if [[ -f /etc/rpi-issue ]] && [[ -f /etc/initramfs-tools/initramfs.conf ]]; then + sed -i 's/FSTYPE=auto/FSTYPE=ext4/' /etc/initramfs-tools/initramfs.conf +fi + +## Force Update +apt-get update --allow-releaseinfo-change + +### Pre Update Section +if [ "${PKGUPGRADE_DISTUPGRADE}" = "y" ]; then + echo_green "Performing 'apt-get ${PKGUPGRADE_DISTUPGRADE_METHOD}' ... " + apt-get ${PKGUPGRADE_DISTUPGRADE_METHOD} -y +else + echo_green "Skipping Dist Upgrade ['apt-get ${PKGUPGRADE_DISTUPGRADE_METHOD}']." +fi + +### Pre Installer Section +# Make sure Cache is fresh +apt_update_skip +if [ "${PKGUPGRADE_USE_PREINSTALLER}" = "y" ]; then + apt-get install --yes --no-install-recommends "${PKGUPGRADE_PRE_INSTALL_PKGS}" +else + echo_red "PreInstall Mechanism not configured. [SKIPPED]" +fi From f7a7fea11941d7a68c7a73dbb81f05eebdb2f6d2 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 16 Jul 2024 14:06:54 +0200 Subject: [PATCH 19/50] test: debug pkgupgrade Signed-off-by: Stephan Wendel --- config/raspberry/rpi64 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/raspberry/rpi64 b/config/raspberry/rpi64 index 3a29f75e2..44d2028d2 100644 --- a/config/raspberry/rpi64 +++ b/config/raspberry/rpi64 @@ -5,9 +5,11 @@ # See https://www.shellcheck.net/wiki/SC2155 BASE_ARCH="arm64" +BASE_BOOT_MOUNT_PATH=boot # export variables export BASE_ARCH +export BASE_BOOT_MOUNT_PATH ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! From 8fa90ba24035a0db7b5b178cb78f45ab42e9869d Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 16 Jul 2024 14:09:53 +0200 Subject: [PATCH 20/50] fix: fix shellcheck errors Signed-off-by: Stephan Wendel --- src/modules/pkgupgrade/start_chroot_script | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/pkgupgrade/start_chroot_script b/src/modules/pkgupgrade/start_chroot_script index 3d295b922..d7ea42e78 100644 --- a/src/modules/pkgupgrade/start_chroot_script +++ b/src/modules/pkgupgrade/start_chroot_script @@ -9,6 +9,7 @@ set -xe # Source CustomPIOS common.sh +# shellcheck disable=SC1091 source /common.sh install_cleanup_trap @@ -30,7 +31,7 @@ apt-get update --allow-releaseinfo-change ### Pre Update Section if [ "${PKGUPGRADE_DISTUPGRADE}" = "y" ]; then echo_green "Performing 'apt-get ${PKGUPGRADE_DISTUPGRADE_METHOD}' ... " - apt-get ${PKGUPGRADE_DISTUPGRADE_METHOD} -y + apt-get "${PKGUPGRADE_DISTUPGRADE_METHOD}" -y else echo_green "Skipping Dist Upgrade ['apt-get ${PKGUPGRADE_DISTUPGRADE_METHOD}']." fi From c6105fd3e6eac0b5cb71983272b6b73c6a1e8833 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 16 Jul 2024 14:37:53 +0200 Subject: [PATCH 21/50] Revert "test: debug pkgupgrade" This reverts commit f7a7fea11941d7a68c7a73dbb81f05eebdb2f6d2. --- config/raspberry/rpi64 | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/raspberry/rpi64 b/config/raspberry/rpi64 index 44d2028d2..3a29f75e2 100644 --- a/config/raspberry/rpi64 +++ b/config/raspberry/rpi64 @@ -5,11 +5,9 @@ # See https://www.shellcheck.net/wiki/SC2155 BASE_ARCH="arm64" -BASE_BOOT_MOUNT_PATH=boot # export variables export BASE_ARCH -export BASE_BOOT_MOUNT_PATH ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! From 7c3f869168fe8e0bd2fc0a2b6b2690681c083bec Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 16 Jul 2024 15:35:54 +0200 Subject: [PATCH 22/50] chore: remove pkgupgrade module Using CustomPIOS default module Signed-off-by: Stephan Wendel --- src/modules/pkgupgrade/config | 8 ---- src/modules/pkgupgrade/end_chroot_script | 18 --------- src/modules/pkgupgrade/start_chroot_script | 46 ---------------------- 3 files changed, 72 deletions(-) delete mode 100644 src/modules/pkgupgrade/config delete mode 100644 src/modules/pkgupgrade/end_chroot_script delete mode 100644 src/modules/pkgupgrade/start_chroot_script diff --git a/src/modules/pkgupgrade/config b/src/modules/pkgupgrade/config deleted file mode 100644 index 51ffd372a..000000000 --- a/src/modules/pkgupgrade/config +++ /dev/null @@ -1,8 +0,0 @@ -[ -n "${PKGUPGRADE_DISTUPGRADE}" ] || PKGUPGRADE_DISTUPGRADE=y # y/n -# upgrade vs full upgrade. -[ -n "$PKGUPGRADE_DISTUPGRADE_METHOD" ] || PKGUPGRADE_DISTUPGRADE_METHOD=full-upgrade -[ -n "$PKGUPGRADE_USE_PREINSTALLER" ] || PKGUPGRADE_USE_PREINSTALLER=n # y/n -# Add Packages that should be PKGUPGRADEed. -[ -n "$PKGUPGRADE_PRE_INSTALL_PKGS" ] || PKGUPGRADE_PRE_INSTALL_PKGS="" -# Cleanup apt-cache on exit -[ -n "$PKGUPGRADE_CLEANUP" ] || PKGUPGRADE_CLEANUP="y" diff --git a/src/modules/pkgupgrade/end_chroot_script b/src/modules/pkgupgrade/end_chroot_script deleted file mode 100644 index cbd6eaeac..000000000 --- a/src/modules/pkgupgrade/end_chroot_script +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright 2021 by Stephan Wendel aka KwadFan -# -# This file may distributed under GPLv3 -######## - -## Revert Fix initramfs-tools Error on RaspiOS -if [[ -f /etc/rpi-issue ]] && [[ -f /etc/initramfs-tools/initramfs.conf ]]; then - sed -i 's/FSTYPE=ext4/FSTYPE=auto/' /etc/initramfs-tools/initramfs.conf -fi - -### Cleanup -if [ "${PKGUPGRADE_CLEANUP}" = "y" ]; then - apt-get clean -y - apt-get autoclean -y -fi - diff --git a/src/modules/pkgupgrade/start_chroot_script b/src/modules/pkgupgrade/start_chroot_script deleted file mode 100644 index d7ea42e78..000000000 --- a/src/modules/pkgupgrade/start_chroot_script +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright 2021 by Stephan Wendel aka KwadFan -# -# This file may distributed under GPLv3 -######## - -## Source error handling, leave this in place -set -xe - -# Source CustomPIOS common.sh -# shellcheck disable=SC1091 -source /common.sh -install_cleanup_trap - -### noninteractive Check -if [ -z "${DEBIAN_FRONTEND}" ]; then - export DEBIAN_FRONTEND=noninteractive -fi - - -## Fix initramfs-tools Error on RaspiOS - -if [[ -f /etc/rpi-issue ]] && [[ -f /etc/initramfs-tools/initramfs.conf ]]; then - sed -i 's/FSTYPE=auto/FSTYPE=ext4/' /etc/initramfs-tools/initramfs.conf -fi - -## Force Update -apt-get update --allow-releaseinfo-change - -### Pre Update Section -if [ "${PKGUPGRADE_DISTUPGRADE}" = "y" ]; then - echo_green "Performing 'apt-get ${PKGUPGRADE_DISTUPGRADE_METHOD}' ... " - apt-get "${PKGUPGRADE_DISTUPGRADE_METHOD}" -y -else - echo_green "Skipping Dist Upgrade ['apt-get ${PKGUPGRADE_DISTUPGRADE_METHOD}']." -fi - -### Pre Installer Section -# Make sure Cache is fresh -apt_update_skip -if [ "${PKGUPGRADE_USE_PREINSTALLER}" = "y" ]; then - apt-get install --yes --no-install-recommends "${PKGUPGRADE_PRE_INSTALL_PKGS}" -else - echo_red "PreInstall Mechanism not configured. [SKIPPED]" -fi From a8921f46a761241f18df225e71d2d7470384bf2d Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 19 Jul 2024 13:43:25 +0200 Subject: [PATCH 23/50] feat: add headless_mn module Signed-off-by: Stephan Wendel --- config/raspberry/default | 2 +- src/modules/headless_nm/config | 23 +++ .../filesystem/boot/WiFi-README.txt | 108 ++++++++++++++ .../filesystem/boot/headless_nm.txt.template | 15 ++ .../system/disable-wifi-pwr-mgmt.service | 22 +++ .../etc/systemd/system/headless_nm.service | 20 +++ .../etc/udev/rules.d/070-wifi-powersave.rules | 4 + .../filesystem/usr/local/bin/headless_nm | 140 ++++++++++++++++++ .../filesystem/usr/local/bin/pwrsave | 90 +++++++++++ .../filesystem/usr/local/bin/pwrsave-udev | 104 +++++++++++++ src/modules/headless_nm/start_chroot_script | 68 +++++++++ 11 files changed, 595 insertions(+), 1 deletion(-) create mode 100755 src/modules/headless_nm/config create mode 100644 src/modules/headless_nm/filesystem/boot/WiFi-README.txt create mode 100644 src/modules/headless_nm/filesystem/boot/headless_nm.txt.template create mode 100644 src/modules/headless_nm/filesystem/etc/systemd/system/disable-wifi-pwr-mgmt.service create mode 100644 src/modules/headless_nm/filesystem/etc/systemd/system/headless_nm.service create mode 100644 src/modules/headless_nm/filesystem/etc/udev/rules.d/070-wifi-powersave.rules create mode 100644 src/modules/headless_nm/filesystem/usr/local/bin/headless_nm create mode 100755 src/modules/headless_nm/filesystem/usr/local/bin/pwrsave create mode 100755 src/modules/headless_nm/filesystem/usr/local/bin/pwrsave-udev create mode 100755 src/modules/headless_nm/start_chroot_script diff --git a/config/raspberry/default b/config/raspberry/default index 64a581579..914f79e2d 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -11,7 +11,7 @@ BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images # MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" # Disable pkgupgrade for now -MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" +MODULES="base(pkgupgrade,udev_fix,mainsailos(headless_nm,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" diff --git a/src/modules/headless_nm/config b/src/modules/headless_nm/config new file mode 100755 index 000000000..709af4ff8 --- /dev/null +++ b/src/modules/headless_nm/config @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +#Shebang for better file detection +#### headless_nm install module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2024 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +# shellcheck disable=all + +# Use disable power save for wifi module +[ -n "$HEADLESS_NM_DISABLE_PWRSAVE" ] || HEADLESS_NM_DISABLE_PWRSAVE=yes + +# Type of power save rclocal/service/udev +# rclocal - backwards compatibility, runs via rc.local +# service - will add an systemd.service to enable or disable behavior +# on reboots +# udev - creates a udev rules that should affect all wifi devices. + +[ -n "$HEADLESS_NM_PWRSAVE_TYPE" ] || HEADLESS_NM_PWRSAVE_TYPE=udev diff --git a/src/modules/headless_nm/filesystem/boot/WiFi-README.txt b/src/modules/headless_nm/filesystem/boot/WiFi-README.txt new file mode 100644 index 000000000..5a0153fcb --- /dev/null +++ b/src/modules/headless_nm/filesystem/boot/WiFi-README.txt @@ -0,0 +1,108 @@ +Wifi-README.txt +############### + + +Due to changes in Raspberry Pi OS, which OS_NAME is based on, +there is no longer a OS_NAME-wpa-supplicant.txt available. + +How do I setup a (new) network on my Pi ? +----------------------------------------- + +As described in the original Raspberry Pi OS documentation. +See https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-headless-raspberry-pi. + + +Quote: + Connect to a wireless network + To configure wireless network access at first boot in a headless Raspberry Pi, + use the advanced settings menu in Raspberry Pi Imager. + Enter the SSID and password of your preferred wireless network. + Your Raspberry Pi will use these credentials to connect to the network on first boot. + Some wireless adapters and some Raspberry Pi boards do not support 5GHz networks; + check the documentation for your wireless module to ensure compatibility with your preferred network. + + NOTE + Previous versions of Raspberry Pi OS made use of a wpa_supplicant.conf file + which could be placed into the boot folder to configure wireless network settings. + This functionality is not available from Raspberry Pi OS Bookworm onwards. + + +What does that all mean? What do I have to do now? +---------------------------------------------- + +This means in an regular Raspberry Pi OS you are not able to change networks +after your first boot is done. +Unfortunatly, this applies to OS_NAME in the same way. +Which is very unpractical if you move you printer to a new location and +therefore a (possible) new network! + +That is, where this service called headless_nm comes to help you out. +In current state (may change in future) it only replaces Raspberrys preconfigured +connection. + + +First, ensure you have a proper text editor of your choice. +Recommendations are Notepad++, VSCode, Atom or SublimeText. + +################################################################################ +#### IMPORTANT! ATTENTION! #### +################################################################################ + +!!!!! HEADS-UP WINDOWS USERS !!!!! +---------------------------------- + +Do not use Wordpad for editing this file, it will mangle it and your +configuration won't work. Use a proper text editor instead. + +!!!!! HEADS-UP MacOS X USERS !!!!! +--------------------------------- + +If you use Textedit to edit this file make sure to use "plain text format" +and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit +will use none-compatible characters and your network configuration won't work! + + +1.) Please copy the 'headless_nm.txt.template' to your harddrive + +2.) Rename that file to 'headless_nm.txt' + +3.) Now open the file with your favorite text editor. + Windows and MacOS user please read the hint above! + + This file is pretty self explaining, just the 'REGDOMAIN' + needs some explaination: + +Valid Country Codes are: + + GB (United Kingdom) + FR (France) + DE (Germany) + US (United States) + SE (Sweden) + +For a full list, please visit https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + + +4.) Now navigate to the boot partition, + this partition is FAT32 formatted and should be visible if you plug the SD Card into your computer. + + Find the folder 'firmware' and put the 'headless_nm.txt' inside the mentioned folder. + +5.) Remove the SDcard afterwards + +6.) Almost done... Please reboot the pi and wait for it to connect. + +NOTE: + +Attach a screen and watch the console output to get its IP address or +consult your router setup page to grab that information. + +You could also try to reach it by its hostname. + + http://.local + +If you didnt change the hostname during initial flash, you could use + + http://OS_NAME.local + +7.) Enjoy OS_NAME :) diff --git a/src/modules/headless_nm/filesystem/boot/headless_nm.txt.template b/src/modules/headless_nm/filesystem/boot/headless_nm.txt.template new file mode 100644 index 000000000..fa0408a7c --- /dev/null +++ b/src/modules/headless_nm/filesystem/boot/headless_nm.txt.template @@ -0,0 +1,15 @@ +#### Headless Wifi configuration + +# Your Wifis SSID +SSID="" + +# Your Wifi password, remember it has to have at least 8 characters! +# Otherwise a password hash can not be created! +PASSWORD="" + +# Is your SSID in hidden state? [true/false] +HIDDEN="false" + +# Wifi Country code +# See Wifi-README.txt for details! +REGDOMAIN="US" diff --git a/src/modules/headless_nm/filesystem/etc/systemd/system/disable-wifi-pwr-mgmt.service b/src/modules/headless_nm/filesystem/etc/systemd/system/disable-wifi-pwr-mgmt.service new file mode 100644 index 000000000..ab9f2805d --- /dev/null +++ b/src/modules/headless_nm/filesystem/etc/systemd/system/disable-wifi-pwr-mgmt.service @@ -0,0 +1,22 @@ +#### Disable wifi power_save +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2022 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### +#### Note: This is based on: +#### https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html + +[Unit] +Description=Disable power management for wlan0 +After=network.target + +[Service] +Type=oneshot +StandardOutput=tty +ExecStart=/usr/local/bin/pwrsave off + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/src/modules/headless_nm/filesystem/etc/systemd/system/headless_nm.service b/src/modules/headless_nm/filesystem/etc/systemd/system/headless_nm.service new file mode 100644 index 000000000..3b32501eb --- /dev/null +++ b/src/modules/headless_nm/filesystem/etc/systemd/system/headless_nm.service @@ -0,0 +1,20 @@ +#### headless_nm service +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2022 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +[Unit] +Description=Setup Wifi on headless machines using NetworkManager +Before=network.target NetworkManager.service + +[Service] +Type=oneshot +StandardOutput=tty +ExecStart=/usr/local/bin/headless_nm + +[Install] +WantedBy=multi-user.target diff --git a/src/modules/headless_nm/filesystem/etc/udev/rules.d/070-wifi-powersave.rules b/src/modules/headless_nm/filesystem/etc/udev/rules.d/070-wifi-powersave.rules new file mode 100644 index 000000000..6ff2774c4 --- /dev/null +++ b/src/modules/headless_nm/filesystem/etc/udev/rules.d/070-wifi-powersave.rules @@ -0,0 +1,4 @@ +ACTION=="add", \ +SUBSYSTEM=="net", \ +KERNEL=="wlan*" \ +RUN+="/usr/sbin/iw %k set power_save off" \ No newline at end of file diff --git a/src/modules/headless_nm/filesystem/usr/local/bin/headless_nm b/src/modules/headless_nm/filesystem/usr/local/bin/headless_nm new file mode 100644 index 000000000..022ba26ab --- /dev/null +++ b/src/modules/headless_nm/filesystem/usr/local/bin/headless_nm @@ -0,0 +1,140 @@ +#!/usr/bin/env bash +#### headless_nm +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2024 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +#### Description: +#### This is a wrapper for network manager to be able to setup +#### Wifi connections on headless SBC. +#### Takes setup from a file in /boot (/boot/firmware) and recreates +#### Raspberrys 'preconfigured.nmconnection' + +#### Copyright hint: This file contains code snippets from +#### Raspberrys raspi-config therefore it applies also there license +#### and copyrights! +#### See https://github.com/RPi-Distro/raspi-config/blob/bookworm/LICENSE + +#### It also reuses parts of raspberry-sys-mods +#### See https://github.com/RPi-Distro/raspberrypi-sys-mods/blob/bookworm/usr/lib/raspberrypi-sys-mods/imager_custom + +set -e + +# Global Vars +#CMDLINE="/boot/firmware/cmdline.txt" +CMDLINE="/boot/firmware/cmdline.txt" +UUID="" +PSK_HASH="" +KEYMGMT="wpa-psk" +CONNFILE=/etc/NetworkManager/system-connections/preconfigured.nmconnection +SETUPFILE="/boot/firmware/headless_nm.txt" +REGDOMAIN="" + + +# functions +get_config() { + # shellcheck disable=SC1090 + source "${SETUPFILE}" +} + +gen_uuid() { + UUID="$(uuid -v4)" + declare -r UUID +} + +gen_nmconnection() { +cat <<- EOF >"${CONNFILE}" +[connection] +id=preconfigured +uuid=${UUID} +type=wifi +[wifi] +mode=infrastructure +ssid=${SSID} +hidden=${HIDDEN} +[ipv4] +method=auto +[ipv6] +addr-gen-mode=default +method=auto +[proxy] +EOF +} + +gen_keymgmt() { + PSK_HASH="$(gen_psk)" + if [[ -n "${PASSWORD}" ]]; then + cat <<- EOF >>${CONNFILE} +[wifi-security] +key-mgmt=${KEYMGMT} +psk=${PSK_HASH} +EOF +fi +} + +gen_psk() { + wpa_passphrase "${SSID}" "${PASSWORD}" | sed -n "/^.*[ \t]psk.*/s/[ \t]psk=//p" +} + +set_regdomain() { + # Shameless borrowed from + # https://github.com/RPi-Distro/raspi-config/blob/d22643ade3851c42648f3676e577a622c34af49a/raspi-config#L830C3-L832C5 + if ! ischroot; then + iw reg set "$REGDOMAIN" + fi + # set permanent + # Shameless borrowed from + # https://github.com/RPi-Distro/raspi-config/blob/d22643ade3851c42648f3676e577a622c34af49a/raspi-config#L822C3-L825C15 + sed -i \ + -e "s/\s*cfg80211.ieee80211_regdom=\S*//" \ + -e "s/\(.*\)/\1 cfg80211.ieee80211_regdom=$REGDOMAIN/" \ + "${CMDLINE}" +} + +# MAIN +main() { + + if [[ -f "${SETUPFILE}" ]]; then + printf "Configuration file found in %s, continuing...\n" "${SETUPFILE}" + else + printf "Configuration file not found in %s, Exiting...\n" "${SETUPFILE}" + exit 0 + fi + # Generate UUID + gen_uuid + + # Remove preconfiguration if present + if [[ -f "${CONNFILE}" ]]; then + rm -f "${CONNFILE}" + fi + + # Read config file + get_config + + # Generate preconfigured.nmconnection file + gen_nmconnection + + # Add key management and psk to preconfigured.nmconnection file + gen_keymgmt + + # Set REGDOMAIN + set_regdomain + + # NetworkManager only accepts 0600 permissions for configs + chmod 0600 "${CONNFILE}" + + # Cleanup + PSK_HASH="" + PASSWORD="" + SSID="" + printf "Configuration successful written...\n" + rm -f "${SETUPFILE}" +} + +if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then + main +fi diff --git a/src/modules/headless_nm/filesystem/usr/local/bin/pwrsave b/src/modules/headless_nm/filesystem/usr/local/bin/pwrsave new file mode 100755 index 000000000..c9d9417c8 --- /dev/null +++ b/src/modules/headless_nm/filesystem/usr/local/bin/pwrsave @@ -0,0 +1,90 @@ +#!/bin/bash +#### Disable wifi power_save +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2022 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### +#### Note: This is based on: +#### https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html + + +## Error handling +set -eou pipefail + +## Debug Mode +#set -x + +### Message func +function help_msg { + echo -e "Usage:\n" + echo -e "\tpwrsave [ on | off ]" + echo -e "\t\ton\tEnables Power Management of 'wlan0'" + echo -e "\t\toff\tDisables Power Management of 'wlan0'\n" + exit 1 +} + +function has_wifi { + LC_ALL=C iwconfig wlan0 &> /dev/null && echo "0" || echo "1" +} + +function check_wifi_present { + # make sure to exit if command missing + if [ -z "$(command -v iwconfig)" ]; then + echo -e "Command 'iwconfig' not found ... [EXITING]" + exit 1 + fi + if [ "$(has_wifi)" != "0" ]; then + echo -e "[ \e[33mWARN\e[0m ] No WiFi hardware present ... [SKIPPED]" + exit 0 + fi +} + +function disable_pwr_save { + iwconfig wlan0 power off + echo -e "[ \e[32mOK\e[0m ] Disabled Power Management for wlan0" +} + + +function enable_pwr_save { + iwconfig wlan0 power on + echo -e "[ \e[32mOK\e[0m ] Enabled Power Management for wlan0" +} + + +### MAIN +function main { + local arg + if [ "$(id -u)" != "0" ]; then + echo -e "\n$(basename "${0}"): This script needs root priviledges!\n" + exit 1 + fi + if [ "${#}" == "0" ]; then + echo -e "$(basename "${0}"): No argument set!" + help_msg + fi + if [ "${#}" -gt 1 ]; then + echo -e "$(basename "${0}"): Too many arguments set!" + help_msg + fi + arg="${1}" + case "${arg}" in + "on") + check_wifi_present + enable_pwr_save + ;; + "off") + check_wifi_present + disable_pwr_save + ;; + ?|*) + echo -e "$(basename "${0}"): Unknown argument '${arg}' !" + help_msg + ;; + esac +} + +main "${@}" +exit 0 diff --git a/src/modules/headless_nm/filesystem/usr/local/bin/pwrsave-udev b/src/modules/headless_nm/filesystem/usr/local/bin/pwrsave-udev new file mode 100755 index 000000000..45c6a5030 --- /dev/null +++ b/src/modules/headless_nm/filesystem/usr/local/bin/pwrsave-udev @@ -0,0 +1,104 @@ +#!/bin/bash +#### Disable wifi power_save +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2022 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### +#### Note: This is based on: +#### https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html + + +## Error handling +set -eou pipefail + +## Debug Mode +#set -x + +### Message func +function help_msg { + echo -e "Usage:\n" + echo -e "\tpwrsave-udev [ on | off | create ]" + echo -e "\t\ton\tEnables Power Management via udev rule" + echo -e "\t\toff\tDisables Power Management via udev rule" + echo -e "\t\tcreate\tCreate Power Management udev rule\n" + exit 1 +} + + +### Check rule exist +function check_rule { + if [ ! -f /etc/udev/rules.d/070-wifi-powersave.rules ]; then + echo -e "[ \e[31mERROR\e[0m ] Udev Rule for WiFi Powermanagement not found!" + help_msg + fi +} + +function disable_pwr_save { + sed -i 's/on/off/' /etc/udev/rules.d/070-wifi-powersave.rules + echo -e "[ \e[32mOK\e[0m ] Disabled Power Management" +} + + +function enable_pwr_save { + sed -i 's/off/on/' /etc/udev/rules.d/070-wifi-powersave.rules + echo -e "[ \e[32mOK\e[0m ] Enabled Power Management" +} + +function create_rule { +if [ -f /etc/udev/rules.d/070-wifi-powersave.rules ]; then + echo -e "[ \e[33mSKIPPED\e[0m ] Udev rule already exists!" + exit 0 +fi + +cat << EOF > /etc/udev/rules.d/070-wifi-powersave.rules +ACTION=="add", \ +SUBSYSTEM=="net", \ +KERNEL=="wlan*" \ +RUN+="/usr/sbin/iw %k set power_save off" +EOF +echo -e "[ \e[32mOK\e[0m ] Created Udev rule ... \n" +echo -e "Please 'reboot' to take changes effect.\n" +} + + + +### MAIN +function main { + local arg + if [ "$(id -u)" != "0" ]; then + echo -e "\n$(basename "${0}"): This script needs root priviledges!\n" + exit 1 + fi + if [ "${#}" == "0" ]; then + echo -e "$(basename "${0}"): No argument set!" + help_msg + fi + if [ "${#}" -gt 1 ]; then + echo -e "$(basename "${0}"): Too many arguments set!" + help_msg + fi + arg="${1}" + if [ "${arg}" == "create" ]; then + create_rule + exit 0 + fi + check_rule + case "${arg}" in + "on") + enable_pwr_save + ;; + "off") + disable_pwr_save + ;; + ?|*) + echo -e "$(basename "${0}"): Unknown argument '${arg}' !" + help_msg + ;; + esac +} + +main "${@}" +exit 0 diff --git a/src/modules/headless_nm/start_chroot_script b/src/modules/headless_nm/start_chroot_script new file mode 100755 index 000000000..ecdd735be --- /dev/null +++ b/src/modules/headless_nm/start_chroot_script @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +#Shebang for better file detection +#### headless_nm install module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2024 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +set -Ee + +export LC_ALL=C + +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + +# Install dependencies +apt-get update +apt-get install -y uuid + +# Install scripts +unpack filesystem/usr/local/bin /usr/local/bin root +unpack filesystem/boot /boot root +unpack filesystem/etc /etc root + +# set OS_NAME in Wifi-README.txt according to DIST_NAME +if [ -f "/boot/WiFi-README.txt" ]; then + sed -i 's|OS_NAME|'"${DIST_NAME}"'|g' /boot/WiFi-README.txt +fi + +# Install powersave option +if [ "$HEADLESS_NM_DISABLE_PWRSAVE" == "yes" ]; then + + # Use rc.local + if [ "$HEADLESS_NM_PWRSAVE_TYPE" == "rclocal" ]; then + echo_green "Modifying /etc/rc.local ..." + sed -i 's@exit 0@@' /etc/rc.local + (echo "# Disable WiFi Power Management"; \ + echo 'echo "Disabling power management for wlan0 ..."' ; \ + echo "/usr/local/bin/pwrsave off"; echo "exit 0") >> /etc/rc.local + fi + # Use service + if [ "$HEADLESS_NM_PWRSAVE_TYPE" == "service" ]; then + echo_green "Installing disable-wifi-pwr-mgmt service ..." + unpack filesystem/etc/systemd/system /etc/systemd/system root + systemctl_if_exists enable disable-wifi-pwr-mgmt.service + fi + # Use udev rule + if [ "$HEADLESS_NM_PWRSAVE_TYPE" == "udev" ]; then + echo_green "Installing WiFi Power Management udev rule ..." + unpack filesystem/etc/udev/rules.d /etc/udev/rules.d root + fi + # strip out unneeded script, depending on choose + if [ "$HEADLESS_NM_PWRSAVE_TYPE" != "udev" ]; then + rm -f /usr/local/bin/pwrsave-udev + else + rm -f /usr/local/bin/pwrsave + fi +fi + +# Remove scripts if powersave option is not used. +if [ "$HEADLESS_NM_DISABLE_PWRSAVE" == "no" ]; then + rm -f /usr/local/bin/pwrsave-udev + rm -f /usr/local/bin/pwrsave +fi From 59c471cfa2196dd6ded1b130e876c89aaa35475a Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 19 Jul 2024 13:52:31 +0200 Subject: [PATCH 24/50] fix: fix headless_nm module Signed-off-by: Stephan Wendel --- src/modules/headless_nm/start_chroot_script | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/headless_nm/start_chroot_script b/src/modules/headless_nm/start_chroot_script index ecdd735be..e51059cd1 100755 --- a/src/modules/headless_nm/start_chroot_script +++ b/src/modules/headless_nm/start_chroot_script @@ -26,6 +26,9 @@ unpack filesystem/usr/local/bin /usr/local/bin root unpack filesystem/boot /boot root unpack filesystem/etc /etc root +# Enable Service +systemctl_if_exists enable headless_nm.service + # set OS_NAME in Wifi-README.txt according to DIST_NAME if [ -f "/boot/WiFi-README.txt" ]; then sed -i 's|OS_NAME|'"${DIST_NAME}"'|g' /boot/WiFi-README.txt From 1532acdf3e38b5989e406d798f4b8a69584f5f9e Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 20 Jul 2024 11:09:34 +0200 Subject: [PATCH 25/50] fix: fix execustion permission Signed-off-by: Stephan Wendel --- src/modules/headless_nm/filesystem/usr/local/bin/headless_nm | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/modules/headless_nm/filesystem/usr/local/bin/headless_nm diff --git a/src/modules/headless_nm/filesystem/usr/local/bin/headless_nm b/src/modules/headless_nm/filesystem/usr/local/bin/headless_nm old mode 100644 new mode 100755 From 7470002c4bb9db6cf926c243bd858df769cb975b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 20 Jul 2024 11:14:55 +0200 Subject: [PATCH 26/50] fix: fix modules for bullseye images Cleanup default config Signed-off-by: Stephan Wendel --- config/raspberry/default | 2 -- config/raspberry/rpi64-bullseye | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/raspberry/default b/config/raspberry/default index 914f79e2d..912eab802 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -9,8 +9,6 @@ BASE_IMAGE_RESIZEROOT=600 # Compress not needed due compression done in workflow BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images -# MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" -# Disable pkgupgrade for now MODULES="base(pkgupgrade,udev_fix,mainsailos(headless_nm,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" diff --git a/config/raspberry/rpi64-bullseye b/config/raspberry/rpi64-bullseye index b300c976b..ae4b08528 100644 --- a/config/raspberry/rpi64-bullseye +++ b/config/raspberry/rpi64-bullseye @@ -4,6 +4,7 @@ # Declare Variables before exporting. # See https://www.shellcheck.net/wiki/SC2155 + BASE_ARCH="arm64" DOWNLOAD_BASE_URL="https://downloads.raspberrypi.org/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-12-06/2023-12-05-raspios-bullseye-arm64-lite.img.xz" @@ -12,11 +13,14 @@ DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}.torrent" BASE_BOOT_MOUNT_PATH=boot +MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" + # export variables export BASE_ARCH export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE export BASE_BOOT_MOUNT_PATH +export MODULES ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! From 8490976d17833e0f5a2266fcaefc0490c9bcfb5f Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 20 Jul 2024 12:25:54 +0200 Subject: [PATCH 27/50] chore: refactor wifi readme Signed-off-by: Stephan Wendel --- .../filesystem/boot/WiFi-README.txt | 74 +++++++++---------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/src/modules/headless_nm/filesystem/boot/WiFi-README.txt b/src/modules/headless_nm/filesystem/boot/WiFi-README.txt index 5a0153fcb..f498bc629 100644 --- a/src/modules/headless_nm/filesystem/boot/WiFi-README.txt +++ b/src/modules/headless_nm/filesystem/boot/WiFi-README.txt @@ -27,81 +27,79 @@ Quote: This functionality is not available from Raspberry Pi OS Bookworm onwards. -What does that all mean? What do I have to do now? +What does this all mean? What do I need to do now? ---------------------------------------------- -This means in an regular Raspberry Pi OS you are not able to change networks -after your first boot is done. -Unfortunatly, this applies to OS_NAME in the same way. -Which is very unpractical if you move you printer to a new location and -therefore a (possible) new network! +This means that in a normal Raspberry Pi OS you will not able to change networks +after the first boot. +Unfortunately, this also true for OS_NAME. +Which is very inconvenient if you move your printer to a new location and +therefore (possible) a new network! -That is, where this service called headless_nm comes to help you out. -In current state (may change in future) it only replaces Raspberrys preconfigured -connection. +This is where this service called headless_nm comes in. +In its current state (which may change in the future), +it simply replaces Raspberry's preconfigured connection. -First, ensure you have a proper text editor of your choice. -Recommendations are Notepad++, VSCode, Atom or SublimeText. +First, make sure you have a decent text editor of your choice. +Notepad++, VSCode, SublimeText or similar are recommended. ################################################################################ -#### IMPORTANT! ATTENTION! #### +#### IMPORTANT! WARNING! #### ################################################################################ !!!!! HEADS-UP WINDOWS USERS !!!!! ---------------------------------- -Do not use Wordpad for editing this file, it will mangle it and your -configuration won't work. Use a proper text editor instead. +Do not use Wordpad to edit this file, it will corrupt it and your +configuration will not work. Use a proper text editor instead. !!!!! HEADS-UP MacOS X USERS !!!!! --------------------------------- -If you use Textedit to edit this file make sure to use "plain text format" +If you use Textedit to edit this file,be sure to use "plain text format" and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit -will use none-compatible characters and your network configuration won't work! +will use incompatible characters and your network configuration won't work! +1.) If you haven't already done so, insert the SDCard into your computer. -1.) Please copy the 'headless_nm.txt.template' to your harddrive +2.) Open the 'boot' partition. + This partition is FAT32 formatted and should be visible, + when you insert the SD Card into your computer. -2.) Rename that file to 'headless_nm.txt' +3.) Copy and paste the 'headless_nm.txt.template'. + Rename this file to 'headless_nm.txt' -3.) Now open the file with your favorite text editor. - Windows and MacOS user please read the hint above! +4.) Now open the file with your favourite text editor. + Windows and MacOS users please read the note above! This file is pretty self explaining, just the 'REGDOMAIN' needs some explaination: -Valid Country Codes are: + Valid country codes are: - GB (United Kingdom) - FR (France) - DE (Germany) - US (United States) - SE (Sweden) + GB (United Kingdom) + FR (France) + DE (Germany) + US (United States) + SE (Sweden) -For a full list, please visit https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + For a complete list, please visit https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 +5.) Remove the SD card afterwards. -4.) Now navigate to the boot partition, - this partition is FAT32 formatted and should be visible if you plug the SD Card into your computer. - - Find the folder 'firmware' and put the 'headless_nm.txt' inside the mentioned folder. - -5.) Remove the SDcard afterwards - -6.) Almost done... Please reboot the pi and wait for it to connect. +6.) Almost done... Please put the SD card back into your Pi and wait for it to connect. NOTE: -Attach a screen and watch the console output to get its IP address or -consult your router setup page to grab that information. +Plug in a monitor and watch the console output to get its IP address or +consult your router's setup page to get this information. You could also try to reach it by its hostname. http://.local -If you didnt change the hostname during initial flash, you could use +If you did not change the hostname during the initial flash, you could use http://OS_NAME.local From 235dd2af32eb9bc9df1903b765832a65a20993eb Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 20 Jul 2024 12:30:23 +0200 Subject: [PATCH 28/50] chore: add pi5 to json supported sbcs Signed-off-by: Stephan Wendel --- config/raspberry/rpi64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/raspberry/rpi64 b/config/raspberry/rpi64 index 3a29f75e2..bcc9e8e66 100644 --- a/config/raspberry/rpi64 +++ b/config/raspberry/rpi64 @@ -12,4 +12,4 @@ export BASE_ARCH ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! # shellcheck disable=SC2034 -JSON_SUPPORTED_SBC="pi3-64bit pi4-64bit" +JSON_SUPPORTED_SBC="pi3-64bit pi4-64bit pi5-64bit" From d1d728e11a0cefc0519f220c67927389bfd8cec0 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 20 Jul 2024 14:13:19 +0200 Subject: [PATCH 29/50] fix: fix postrename script Signed-off-by: Stephan Wendel --- src/modules/postrename/filesystem/root/postrename | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/postrename/filesystem/root/postrename b/src/modules/postrename/filesystem/root/postrename index afd2f994f..a762a7bcf 100644 --- a/src/modules/postrename/filesystem/root/postrename +++ b/src/modules/postrename/filesystem/root/postrename @@ -121,7 +121,7 @@ patch_polkit_rules() { sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_dir}/moonraker.rules" fi if [[ -f "${polkit_usr_dir}/moonraker.rules" ]]; then - sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_usr_dir}/moonraker.rules" + sed -i 's/ "pi"/ \"'"${DEFAULT_USER}"'\"/g' "${polkit_usr_dir}/moonraker.rules" fi if [[ -f "${polkit_legacy_dir}/10-moonraker.pkla" ]]; then sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_legacy_dir}/10-moonraker.pkla" From 19622a4a650a44fae8e050335ed00aa2be5e1c14 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 28 Jul 2024 11:08:44 +0200 Subject: [PATCH 30/50] chore: refactor wifi-readme.txt Signed-off-by: Stephan Wendel --- .../filesystem/boot/WiFi-README.txt | 75 +++++-------------- 1 file changed, 17 insertions(+), 58 deletions(-) diff --git a/src/modules/headless_nm/filesystem/boot/WiFi-README.txt b/src/modules/headless_nm/filesystem/boot/WiFi-README.txt index f498bc629..7e54cfc2b 100644 --- a/src/modules/headless_nm/filesystem/boot/WiFi-README.txt +++ b/src/modules/headless_nm/filesystem/boot/WiFi-README.txt @@ -1,65 +1,24 @@ Wifi-README.txt -############### - - -Due to changes in Raspberry Pi OS, which OS_NAME is based on, -there is no longer a OS_NAME-wpa-supplicant.txt available. - -How do I setup a (new) network on my Pi ? ------------------------------------------ - -As described in the original Raspberry Pi OS documentation. -See https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-headless-raspberry-pi. - - -Quote: - Connect to a wireless network - To configure wireless network access at first boot in a headless Raspberry Pi, - use the advanced settings menu in Raspberry Pi Imager. - Enter the SSID and password of your preferred wireless network. - Your Raspberry Pi will use these credentials to connect to the network on first boot. - Some wireless adapters and some Raspberry Pi boards do not support 5GHz networks; - check the documentation for your wireless module to ensure compatibility with your preferred network. - - NOTE - Previous versions of Raspberry Pi OS made use of a wpa_supplicant.conf file - which could be placed into the boot folder to configure wireless network settings. - This functionality is not available from Raspberry Pi OS Bookworm onwards. - - -What does this all mean? What do I need to do now? ----------------------------------------------- - -This means that in a normal Raspberry Pi OS you will not able to change networks -after the first boot. -Unfortunately, this also true for OS_NAME. -Which is very inconvenient if you move your printer to a new location and -therefore (possible) a new network! - -This is where this service called headless_nm comes in. -In its current state (which may change in the future), -it simply replaces Raspberry's preconfigured connection. - - -First, make sure you have a decent text editor of your choice. -Notepad++, VSCode, SublimeText or similar are recommended. ################################################################################ -#### IMPORTANT! WARNING! #### +#### IMPORTANT WARNING #### +################################################################################ +#### #### +#### First, make sure you have a decent text editor of your choice. #### +#### Notepad++, VSCode, SublimeText or similar are recommended. #### +#### #### +#### Do not use Wordpad to edit this file, it will corrupt it and your #### +#### configuration will not work. #### +#### #### +#### If you use Textedit to edit this file, #### +#### be sure to use "plain text format" and "disable smart quotes" #### +#### in "Textedit > Preferences", otherwise Textedit will use #### +#### incompatible characters and your network configuration won't work! #### +#### #### ################################################################################ -!!!!! HEADS-UP WINDOWS USERS !!!!! ----------------------------------- - -Do not use Wordpad to edit this file, it will corrupt it and your -configuration will not work. Use a proper text editor instead. - -!!!!! HEADS-UP MacOS X USERS !!!!! ---------------------------------- - -If you use Textedit to edit this file,be sure to use "plain text format" -and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit -will use incompatible characters and your network configuration won't work! +How do I setup a new network on my OS_NAME ? +-------------------------------------------- 1.) If you haven't already done so, insert the SDCard into your computer. @@ -88,7 +47,7 @@ will use incompatible characters and your network configuration won't work! 5.) Remove the SD card afterwards. -6.) Almost done... Please put the SD card back into your Pi and wait for it to connect. +6.) Almost done... Please put the SD card back into your SBC and wait for it to connect. NOTE: From a3a82d922fe2e6a461995c389cde7b7c8d07b21c Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 28 Jul 2024 12:52:52 +0200 Subject: [PATCH 31/50] chore: use headless_nm for armbian images Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- config/armbian/orangepi4lts-bullseye | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/armbian/default b/config/armbian/default index 283900e05..c6e329839 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -23,7 +23,7 @@ BASE_IMAGE_RESIZEROOT=600 # Compress not needed due compression done in workflow BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images -MODULES="base(pkgupgrade,udev_fix,armbian(mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar))" +MODULES="base(pkgupgrade,udev_fix,armbian(headless_nm,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar))" # export Variables export DOWNLOAD_BASE_URL diff --git a/config/armbian/orangepi4lts-bullseye b/config/armbian/orangepi4lts-bullseye index 09a8bc6fb..03f0d30f8 100644 --- a/config/armbian/orangepi4lts-bullseye +++ b/config/armbian/orangepi4lts-bullseye @@ -8,14 +8,14 @@ BASE_ARCH="arm64" DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz.sha256" DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz" -MODULES="base(pkgupgrade,udev_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar))" +# MODULES="base(pkgupgrade,udev_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar))" # export Variables export BASE_ARCH export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE -export MODULES +# export MODULES ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! From 027f4baac337482a1a131f0d779543a955c9d905 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 4 Aug 2024 09:35:50 +0200 Subject: [PATCH 32/50] chore: extend headless_nm for armbian based images Signed-off-by: Stephan Wendel --- .../filesystem/usr/local/bin/headless_nm | 69 +++++++++++++++---- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/src/modules/headless_nm/filesystem/usr/local/bin/headless_nm b/src/modules/headless_nm/filesystem/usr/local/bin/headless_nm index 022ba26ab..44649e34f 100755 --- a/src/modules/headless_nm/filesystem/usr/local/bin/headless_nm +++ b/src/modules/headless_nm/filesystem/usr/local/bin/headless_nm @@ -25,23 +25,51 @@ set -e # Global Vars -#CMDLINE="/boot/firmware/cmdline.txt" +DISTRO="" CMDLINE="/boot/firmware/cmdline.txt" +ARMBIANENV="/boot/armbianEnv.txt" UUID="" PSK_HASH="" KEYMGMT="wpa-psk" CONNFILE=/etc/NetworkManager/system-connections/preconfigured.nmconnection -SETUPFILE="/boot/firmware/headless_nm.txt" +SETUPFILE="$(find /boot -name "headless_nm.txt")" REGDOMAIN="" +CFG80211="/etc/modprobe.d/cfg80211.conf" # functions +log() { + local msg + msg="${1}" + logger -t headless_nm "${msg}" +} + +get_distro() { + local armbian rpi + armbian="$(find /boot -name "$(basename ${ARMBIANENV})")" + rpi="$(find /boot -name "$(basename ${CMDLINE})")" + log "Determine distribution ..." + if [[ -n "${armbian}" ]]; then + DISTRO="armbian" + elif [[ -n "${rpi}" ]]; then + DISTRO="rpi" + else + DISTRO="" + log "Could not determine distribution ... Exiting!" + exit 1 + fi + if [[ -n "${DISTRO}" ]]; then + log "Using setup profile: ${DISTRO} ..." + fi +} + get_config() { # shellcheck disable=SC1090 source "${SETUPFILE}" } gen_uuid() { + log "Generating UUID for connection..." UUID="$(uuid -v4)" declare -r UUID } @@ -55,7 +83,7 @@ type=wifi [wifi] mode=infrastructure ssid=${SSID} -hidden=${HIDDEN} +hidden=${HIDDEN,,} [ipv4] method=auto [ipv6] @@ -81,29 +109,44 @@ gen_psk() { } set_regdomain() { + log "Set registration domain to '${REGDOMAIN}' ..." # Shameless borrowed from # https://github.com/RPi-Distro/raspi-config/blob/d22643ade3851c42648f3676e577a622c34af49a/raspi-config#L830C3-L832C5 if ! ischroot; then - iw reg set "$REGDOMAIN" + iw reg set "${REGDOMAIN}" fi # set permanent - # Shameless borrowed from - # https://github.com/RPi-Distro/raspi-config/blob/d22643ade3851c42648f3676e577a622c34af49a/raspi-config#L822C3-L825C15 - sed -i \ - -e "s/\s*cfg80211.ieee80211_regdom=\S*//" \ - -e "s/\(.*\)/\1 cfg80211.ieee80211_regdom=$REGDOMAIN/" \ - "${CMDLINE}" + case "${DISTRO}" in + "rpi") + # Shameless borrowed from + # https://github.com/RPi-Distro/raspi-config/blob/d22643ade3851c42648f3676e577a622c34af49a/raspi-config#L822C3-L825C15 + sed -i \ + -e "s/\s*cfg80211.ieee80211_regdom=\S*//" \ + -e "s/\(.*\)/\1 cfg80211.ieee80211_regdom=$REGDOMAIN/" \ + "${CMDLINE}" + ;; + "armbian") + if [[ -f "${CFG80211}" ]]; then + rm -f "${CFG80211}" + fi + echo "options cfg80211 ieee80211_regdom=${REGDOMAIN}" > "${CFG80211}" + ;; + esac } # MAIN main() { + # Determine base distribution + get_distro + # Check setup file is present if [[ -f "${SETUPFILE}" ]]; then - printf "Configuration file found in %s, continuing...\n" "${SETUPFILE}" + log "Configuration file found in ${SETUPFILE}, continuing...\n" else - printf "Configuration file not found in %s, Exiting...\n" "${SETUPFILE}" + log "Configuration file not found! Nothing to do, exiting...\n" exit 0 fi + # Generate UUID gen_uuid @@ -131,7 +174,7 @@ main() { PSK_HASH="" PASSWORD="" SSID="" - printf "Configuration successful written...\n" + log "Configuration successful written ..." rm -f "${SETUPFILE}" } From bc23b1b5ec2cc706a0395e39290f1fd2d5cd9958 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 5 Aug 2024 10:32:37 +0200 Subject: [PATCH 33/50] test: Use altered DNS servers This will be removed if test for FR https://github.com/guysoft/CustomPiOS/pull/223 was successful and get merged to upstream Signed-off-by: Stephan Wendel --- src/modules/base/config | 113 +++++++++++ src/modules/base/end_chroot_script | 45 +++++ .../lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant | 112 +++++++++++ src/modules/base/start_chroot_script | 189 ++++++++++++++++++ 4 files changed, 459 insertions(+) create mode 100644 src/modules/base/config create mode 100755 src/modules/base/end_chroot_script create mode 100644 src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant create mode 100644 src/modules/base/start_chroot_script diff --git a/src/modules/base/config b/src/modules/base/config new file mode 100644 index 000000000..da791a6a1 --- /dev/null +++ b/src/modules/base/config @@ -0,0 +1,113 @@ +#!/bin/bash +############################################################################### +# All our config settings must start with BASE_ + +# CustomPiOS version +BASE_VERSION=1.5.0 + +[ -n "$BASE_PRESCRIPT" ] || BASE_PRESCRIPT= +[ -n "$BASE_POSTSCRIPT" ] || BASE_POSTSCRIPT= + +#[ -n "$BASE_SCRIPT_PATH" ] || BASE_SCRIPT_PATH=$CONFIG_DIR +[ -n "$BASE_IMAGE_PATH" ] || BASE_IMAGE_PATH=${DIST_PATH}/image +[ -n "$BASE_IMAGE_RASPBIAN" ] || BASE_IMAGE_RASPBIAN=yes + +# Distro +[ -n "$BASE_DISTRO" ] || BASE_DISTRO=raspbian + +# Note: Set BASE_ZIP_IMG relative to the distro/src/workspace directory to pass a custom named file or an already extracted '.img'-file. +if [ "${BASE_DISTRO}" = "ubuntu" ]; then + # Default image ubuntu + [ -n "$BASE_ZIP_IMG" ] || BASE_ZIP_IMG=$(ls -t $BASE_IMAGE_PATH/ubuntu-*.xz | head -n 1) + # Default user ubuntu + [ -n "$BASE_USER" ] || BASE_USER=ubuntu + + # Add base user if does not exist + [ -n "$BASE_ADD_USER" ] || BASE_ADD_USER=yes + # When adding a base user which password to use + [ -n "$BASE_USER_PASSWORD" ] || BASE_USER_PASSWORD=ubuntu +else + # Default image raspbian + if [ "${BASE_DISTRO}" = "raspios64" ]; then + [ -n "$BASE_ZIP_IMG" ] || BASE_ZIP_IMG=$(ls -t $BASE_IMAGE_PATH/*-{raspbian,raspios}-*-arm64-*.{zip,7z,xz} | head -n 1) + else + [ -n "$BASE_ZIP_IMG" ] || BASE_ZIP_IMG=$(ls -t $BASE_IMAGE_PATH/*-{raspbian,raspios}*.{zip,7z,xz} | head -n 1) + fi + # Default user raspbian + [ -n "$BASE_USER" ] || BASE_USER=pi + [ -n "$BASE_ADD_USER" ] || BASE_ADD_USER=yes + [ -n "$BASE_USER_PASSWORD" ] || BASE_USER_PASSWORD=raspberry +fi + +# Release compression +[ -n "$BASE_RELEASE_COMPRESS" ] || BASE_RELEASE_COMPRESS=yes + +[ -n "$BASE_RELEASE_IMG_NAME" ] || BASE_RELEASE_IMG_NAME=default +[ -n "$BASE_RELEASE_ZIP_NAME" ] || BASE_RELEASE_ZIP_NAME=default + +[ -n "$BASE_WORKSPACE" ] || BASE_WORKSPACE=${DIST_PATH}/workspace$WORKSPACE_POSTFIX +# [ -n "$BASE_CHROOT_SCRIPT_PATH" ] || BASE_CHROOT_SCRIPT_PATH=$BASE_SCRIPT_PATH/chroot_script +[ -n "$BASE_MOUNT_PATH" ] || BASE_MOUNT_PATH=$BASE_WORKSPACE/mount + +[ -n "${BASE_BOOT_MOUNT_PATH}" ] || BASE_BOOT_MOUNT_PATH=boot/firmware + +# The root partition of the image filesystem, 2 for raspbian +[ -n "$BASE_ROOT_PARTITION" ] || BASE_ROOT_PARTITION=2 + +# if set will enlarge root partition prior to build by provided size in MB +[ -n "$BASE_IMAGE_ENLARGEROOT" ] || BASE_IMAGE_ENLARGEROOT=200 + +# if set will resize root partition on image after build to minimum size + +# provided size in MB +[ -n "$BASE_IMAGE_RESIZEROOT" ] || BASE_IMAGE_RESIZEROOT=200 + +# a local directory on the build server to bind mount under /var/cache/apt +[ -n "$BASE_APT_CACHE" ] || BASE_APT_CACHE=$BASE_WORKSPACE/aptcache + +# a host:port combo for a apt-proxy (such as apt-cacher-ng) to use +[ -n "$BASE_APT_PROXY" ] || BASE_APT_PROXY= + +[ -n "$BASE_APT_MIRROR" ] || BASE_APT_MIRROR= + +# an alternative pypi index url to use, e.g. a proxy such as devpi +[ -n "$BASE_PYPI_INDEX" ] || BASE_PYPI_INDEX= + +[ -n "$BASE_OVERRIDE_HOSTNAME" ] || BASE_OVERRIDE_HOSTNAME=${DIST_NAME,,} + +# Alter DNS servers used during build (space seperated) +# e.g. BASE_USE_ALT_DNS="1.1.1.1 8.8.8.8" +[ -n "$BASE_USE_ALT_DNS" ] || BASE_USE_ALT_DNS= + +# a git mirror to use for git clones instead of original remotes +[ -n "$BASE_BUILD_REPO_MIRROR" ] || BASE_BUILD_REPO_MIRROR= + +# Enable ssh daemon +[ -n "$BASE_SSH_ENABLE" ] || BASE_SSH_ENABLE=yes + +#Store the commit used for CustomPiOS +[ -n "$BASE_COMMIT" ] || BASE_COMMIT=$(git -C "${CUSTOM_PI_OS_PATH}" rev-parse HEAD) || true + +#Memory split +[ -n "$BASE_CONFIG_MEMSPLIT" ] || BASE_CONFIG_MEMSPLIT=default + +#Timezone +[ -n "$BASE_CONFIG_TIMEZONE" ] || BASE_CONFIG_TIMEZONE=default + +#Locale +[ -n "$BASE_CONFIG_LOCALE" ] || BASE_CONFIG_LOCALE=default + +#Keyboard +[ -n "$BASE_CONFIG_KEYBOARD" ] || BASE_CONFIG_KEYBOARD=default + +# Arch for now either armv7l, arm64 or aarch64 +[ -n "$BASE_ARCH" ] || BASE_ARCH=armv7l + +# If you want your variant not to have the name appending, enable this +[ -n "$BASE_IGNORE_VARIANT_NAME" ] || BASE_IGNORE_VARIANT_NAME=no + +# Enable uart console on boot +[ -n "$BASE_ENABLE_UART" ] || BASE_ENABLE_UART=no + + +# Clean apt-cache after all the work is done +: ${BASE_APT_CLEAN:=yes} diff --git a/src/modules/base/end_chroot_script b/src/modules/base/end_chroot_script new file mode 100755 index 000000000..37b21c722 --- /dev/null +++ b/src/modules/base/end_chroot_script @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Base script +# Basic and manditory settings for the base of a CustomPiOS build +# Written by Guy Sheffer +# GPL V3 +######## +set -ex + +if [ -n "$BASE_APT_PROXY" ] +then + rm -r /etc/apt/apt.conf.d/02octopi_build_proxy +fi + +if [ -n "${BASE_APT_MIRROR}" ]; then + sed -i '1d' /etc/apt/sources.list +fi + +if [ -n "$BASE_PYPI_INDEX" ] +then + rm -r /root/.pip + rm -r /root/.pydistutils.cfg + rm -r /home/"${BASE_USER}"/.pip/pip.conf + rm -r /home/"${BASE_USER}"/.pydistutils.cfg +fi + +#reach device by name +if [ -f /etc/hostname ]; then + read FILE_HOST_NAME < /etc/hostname + FILE_HOST_NAME=${FILE_HOST_NAME//$'\n'/} + else + FILE_HOST_NAME=raspberrypi +fi + +echo "$BASE_OVERRIDE_HOSTNAME" > /etc/hostname +sed -i -e "s@${FILE_HOST_NAME}@$BASE_OVERRIDE_HOSTNAME@g" /etc/hosts + +if [ "${BASE_DISTRO}" == "ubuntu" ];then + echo "127.0.0.1 ${BASE_OVERRIDE_HOSTNAME}" > /etc/hosts +fi + +#cleanup +if [ "${BASE_APT_CLEAN}" = "yes" ]; then + apt-get clean +fi +apt-get autoremove -y diff --git a/src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant b/src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant new file mode 100644 index 000000000..b0cf51842 --- /dev/null +++ b/src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant @@ -0,0 +1,112 @@ +# Start, reconfigure and stop wpa_supplicant per wireless interface. +# This is needed because wpa_supplicant lacks hotplugging of any kind +# and the user should not be expected to have to wire it into their system +# if the base system doesn't do this itself. + +if [ -z "$wpa_supplicant_conf" ]; then + for x in \ + /etc/wpa_supplicant/wpa_supplicant-"$interface".conf \ + /etc/wpa_supplicant/wpa_supplicant.conf \ + /etc/wpa_supplicant-"$interface".conf \ + /etc/wpa_supplicant.conf \ + ; do + if [ -s "$x" ]; then + wpa_supplicant_conf="$x" + break + fi + done +fi +: ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf} + +wpa_supplicant_ctrldir() +{ + dir=$(key_get_value "[[:space:]]*ctrl_interface=" \ + "$wpa_supplicant_conf") + dir=$(trim "$dir") + case "$dir" in + DIR=*) + dir=${dir##DIR=} + dir=${dir%%[[:space:]]GROUP=*} + dir=$(trim "$dir") + ;; + esac + printf %s "$dir" +} + +wpa_supplicant_start() +{ + # If the carrier is up, don't bother checking anything + [ "$ifcarrier" = "up" ] && return 0 + + # Pre flight checks + if [ ! -s "$wpa_supplicant_conf" ]; then + syslog warn \ + "$wpa_supplicant_conf does not exist" + syslog warn "not interacting with wpa_supplicant(8)" + return 1 + fi + dir=$(wpa_supplicant_ctrldir) + if [ -z "$dir" ]; then + syslog warn \ + "ctrl_interface not defined in $wpa_supplicant_conf" + syslog warn "not interacting with wpa_supplicant(8)" + return 1 + fi + + wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1 && return 0 + syslog info "starting wpa_supplicant" + wpa_supplicant_driver="${wpa_supplicant_driver:-nl80211,wext}" + driver=${wpa_supplicant_driver:+-D}$wpa_supplicant_driver + err=$(wpa_supplicant -B -c"$wpa_supplicant_conf" -i"$interface" \ + "$driver" 2>&1) + errn=$? + if [ $errn != 0 ]; then + syslog err "failed to start wpa_supplicant" + syslog err "$err" + fi + return $errn +} + +wpa_supplicant_reconfigure() +{ + dir=$(wpa_supplicant_ctrldir) + [ -z "$dir" ] && return 1 + if ! wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1; then + wpa_supplicant_start + return $? + fi + syslog info "reconfiguring wpa_supplicant" + err=$(wpa_cli -p "$dir" -i "$interface" reconfigure 2>&1) + errn=$? + if [ $errn != 0 ]; then + syslog err "failed to reconfigure wpa_supplicant" + syslog err "$err" + fi + return $errn +} + +wpa_supplicant_stop() +{ + dir=$(wpa_supplicant_ctrldir) + [ -z "$dir" ] && return 1 + wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1 || return 0 + syslog info "stopping wpa_supplicant" + err=$(wpa_cli -i"$interface" terminate 2>&1) + errn=$? + if [ $errn != 0 ]; then + syslog err "failed to start wpa_supplicant" + syslog err "$err" + fi + return $errn +} + +if [ "$ifwireless" = "1" ] && \ + type wpa_supplicant >/dev/null 2>&1 && \ + type wpa_cli >/dev/null 2>&1 +then + case "$reason" in + PREINIT) wpa_supplicant_start;; + RECONFIGURE) wpa_supplicant_reconfigure;; + DEPARTED) wpa_supplicant_stop;; + esac +fi diff --git a/src/modules/base/start_chroot_script b/src/modules/base/start_chroot_script new file mode 100644 index 000000000..9e92cf85a --- /dev/null +++ b/src/modules/base/start_chroot_script @@ -0,0 +1,189 @@ +#!/usr/bin/env bash +# Base script +# Basic and manditory settings for the base of a CustomPiOS build +# Written by Guy Sheffer +# GPL V3 +######## +set -x +set -e + +export LC_ALL=C + +source /common.sh +install_cleanup_trap +if [ -n "${BASE_APT_MIRROR}" ]; then + echo "${BASE_APT_MIRROR}" | cat - /etc/apt/sources.list > /tmp/filename.tmp + mv /tmp/filename.tmp /etc/apt/sources.list +fi + +if [ "${BASE_DISTRO}" == "ubuntu" ]; then + unpack /filesystem/ubuntu / root + + mv /etc/resolv.conf /etc/resolv.conf.orig || true + if [ -z "${BASE_USE_ALT_DNS}" ]; then + echo "nameserver 8.8.8.8" > /etc/resolv.conf + echo "nameserver 8.8.4.4" >> /etc/resolv.conf + echo "nameserver 1.1.1.1" >> /etc/resolv.conf + else + touch /etc/resolv.conf + for dns in ${BASE_USE_ALT_DNS}; do + echo "nameserver ${dns}" >> /etc/resolv.conf + done + fi + + + apt-get update --allow-releaseinfo-change + apt-get install -y net-tools wireless-tools dhcpcd5 + if [ $( is_in_apt policykit-1 ) -eq 1 ]; then + apt-get -y install policykit-1 + fi + + # prevent any installed services from automatically starting + echo exit 101 > /usr/sbin/policy-rc.d + chmod +x /usr/sbin/policy-rc.d + systemctl enable dhcpcd.service + + #Undo prevent any installed services from automatically starting + rm -r /usr/sbin/policy-rc.d || true + +fi + +#Helper Function for create_userconf +function get_os_version { + local os_version + grep -c "buster" /etc/os-release +} + +if [ "${BASE_ADD_USER}" == "yes" ]; then + if [ "${BASE_DISTRO}" == "raspbian" ] || [ "${BASE_DISTRO}" == "raspios64" ] || [ "${BASE_DISTRO}" == "raspios" ]; then + # Setup first user, reference: + # https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-a-user + echo_green "Setup default user and password ..." + function create_userconf { + local pw_encrypt + if [ -n "${BASE_USER}" ] || [ -n "${BASE_USER_PASSWORD}" ]; then + pw_encrypt="$(echo "${BASE_USER_PASSWORD}" | openssl passwd -6 -stdin)" + echo "${BASE_USER}:${pw_encrypt}" > /"${BASE_BOOT_MOUNT_PATH}"/userconf.txt + + # Upgrade pkg first, make sure latest version will be patched + apt-get install --yes --only-upgrade userconf-pi + + # Patch cancel-rename due to https://github.com/RPi-Distro/userconf-pi/issues/2 + # And https://github.com/guysoft/CustomPiOS/issues/163 + # Since the new version has changed an lead to Error described in + # https://github.com/guysoft/CustomPiOS/issues/176 + # use a more generic way to patch the script. + if [[ -f "/usr/bin/cancel-rename" ]]; then + sed -i 's|do_boot_behaviour B2|do_boot_behaviour B1|g' /usr/bin/cancel-rename + fi + + else + echo_red "First user name and password not set! [FAILED]" + exit 1 + fi + } + # Do not patch if raspian="buster" + if [ "$(get_os_version)" == "0" ]; then + create_userconf + else + echo "Base Image use Version 'buster' no patching of userconf-pi needed" + fi + else + if id -u "${BASE_USER}" >/dev/null 2>&1; then + echo "Base user exists, not adding" + else + echo "Adding base user ${BASE_USER}" + password=$(perl -e 'printf("%s\n", crypt($ARGV[0], "password"))' "${BASE_USER_PASSWORD}") + useradd -m -p "${password}" -s /bin/bash "${BASE_USER}" + usermod -a -G sudo "${BASE_USER}" + fi + fi +fi + +if [ -n "$BASE_APT_PROXY" ] +then + echo "Acquire::http { Proxy \"http://$BASE_APT_PROXY\"; };" > /etc/apt/apt.conf.d/02octopi_build_proxy +fi + +if [ -n "$BASE_PYPI_INDEX" ] +then + pip_index_config="[global]\nindex-url = $BASE_PYPI_INDEX" + easyinstall_index_config="[easy_install]\nindex-url = $BASE_PYPI_INDEX" + + mkdir -p /root/.pip + echo -e "$pip_index_config" > /root/.pip/pip.conf + echo -e "$easyinstall_index_config" > /root/.pydistutils.cfg + + mkdir -p /home/"${BASE_USER}"/.pip + sudo -u "${BASE_USER}" echo -e "$pip_index_config" > /home/pi/.pip/pip.conf + sudo -u "${BASE_USER}" echo -e "$easyinstall_index_config" > /home/pi/.pydistutils.cfg + + echo "Configured pypi index url $BASE_PYPI_INDEX" + cat /home/"${BASE_USER}"/.pip/pip.conf + cat /home/"${BASE_USER}"/.pydistutils.cfg +fi + +if [ "$BASE_SSH_ENABLE" == "yes" ] +then + touch /"${BASE_BOOT_MOUNT_PATH}"/ssh + ### Fix SSH incoming + echo "IPQoS 0x00" >> /etc/ssh/sshd_config + + ### Fix SSH outgoing + echo "IPQoS 0x00" >> /etc/ssh/ssh_config + + ### Try and fix https://github.com/guysoft/OctoPi/issues/424 + if [ -f "/lib/systemd/system/regenerate_ssh_host_keys.service" ]; then + sed -i "s@ExecStart=/usr/bin/ssh-keygen -A -v@ExecStart=/bin/bash -c ' /usr/bin/ssh-keygen -A -v >> /var/log/regenerate_ssh_host_keys.log 2>\&1'@g" /lib/systemd/system/regenerate_ssh_host_keys.service + sed -i "s@ExecStartPost=/bin/systemctl disable regenerate_ssh_host_keys@ExecStartPost=/bin/bash -c 'for i in /etc/ssh/ssh_host_*_key*; do actualsize=\$(wc -c <\"\$i\") ;if [ \$actualsize -eq 0 ]; then echo size is 0 bytes ; exit 1 ; fi ; done ; /bin/systemctl disable regenerate_ssh_host_keys'@g" /lib/systemd/system/regenerate_ssh_host_keys.service + fi +fi + +# Store version buildbase +echo "$CUSTOM_PI_OS_BUILDBASE" > /etc/custompios_buildbase + +# Store dist version +echo "$DIST_VERSION" > /etc/${DIST_NAME,,}_version + +# Store dist variant +echo "$BUILD_VARIANT" > /etc/dist_variant + +########################## +# Raspi-config stuff +# https://github.com/RPi-Distro/raspi-config/blob/master/raspi-config + +# Memory split +if [ $BASE_CONFIG_MEMSPLIT != 'default' ] +then + echo "Configuring memory" + raspi-config nonint do_memory_split $BASE_CONFIG_MEMSPLIT +fi + +# timezone +if [ $BASE_CONFIG_TIMEZONE != 'default' ] +then + echo "Configuring timezone" + raspi-config nonint do_change_timezone $BASE_CONFIG_TIMEZONE +fi + +# locale +if [ $BASE_CONFIG_LOCALE != 'default' ] +then + echo "Configuring locales" + raspi-config nonint do_change_locale $BASE_CONFIG_LOCALE +fi + +# keyboard +if [ $BASE_CONFIG_KEYBOARD != 'default' ] +then + echo "Configuring keyboard" + raspi-config nonint do_configure_keyboard $BASE_CONFIG_KEYBOARD +fi + +# Enable uart on boot +if [ ${BASE_ENABLE_UART} == "yes" ] +then + if ! grep -q "^enable_uart=1" /"${BASE_BOOT_MOUNT_PATH}"/config.txt ; then + echo "enable_uart=1" >> /"${BASE_BOOT_MOUNT_PATH}"/config.txt + fi +fi From d86f9addd1be931a889c907613442767725401d0 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 5 Aug 2024 10:46:42 +0200 Subject: [PATCH 34/50] test: renamed module Signed-off-by: Stephan Wendel --- src/modules/{base => base_alt}/config | 0 src/modules/{base => base_alt}/end_chroot_script | 0 .../ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant | 0 src/modules/{base => base_alt}/start_chroot_script | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/modules/{base => base_alt}/config (100%) rename src/modules/{base => base_alt}/end_chroot_script (100%) rename src/modules/{base => base_alt}/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant (100%) rename src/modules/{base => base_alt}/start_chroot_script (100%) diff --git a/src/modules/base/config b/src/modules/base_alt/config similarity index 100% rename from src/modules/base/config rename to src/modules/base_alt/config diff --git a/src/modules/base/end_chroot_script b/src/modules/base_alt/end_chroot_script similarity index 100% rename from src/modules/base/end_chroot_script rename to src/modules/base_alt/end_chroot_script diff --git a/src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant b/src/modules/base_alt/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant similarity index 100% rename from src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant rename to src/modules/base_alt/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant diff --git a/src/modules/base/start_chroot_script b/src/modules/base_alt/start_chroot_script similarity index 100% rename from src/modules/base/start_chroot_script rename to src/modules/base_alt/start_chroot_script From d1cc8a207398717b871f4ccab6bf0700d011d454 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 5 Aug 2024 10:52:05 +0200 Subject: [PATCH 35/50] Revert "test: renamed module" This reverts commit d86f9addd1be931a889c907613442767725401d0. --- src/modules/{base_alt => base}/config | 0 src/modules/{base_alt => base}/end_chroot_script | 0 .../ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant | 0 src/modules/{base_alt => base}/start_chroot_script | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/modules/{base_alt => base}/config (100%) rename src/modules/{base_alt => base}/end_chroot_script (100%) rename src/modules/{base_alt => base}/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant (100%) rename src/modules/{base_alt => base}/start_chroot_script (100%) diff --git a/src/modules/base_alt/config b/src/modules/base/config similarity index 100% rename from src/modules/base_alt/config rename to src/modules/base/config diff --git a/src/modules/base_alt/end_chroot_script b/src/modules/base/end_chroot_script similarity index 100% rename from src/modules/base_alt/end_chroot_script rename to src/modules/base/end_chroot_script diff --git a/src/modules/base_alt/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant b/src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant similarity index 100% rename from src/modules/base_alt/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant rename to src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant diff --git a/src/modules/base_alt/start_chroot_script b/src/modules/base/start_chroot_script similarity index 100% rename from src/modules/base_alt/start_chroot_script rename to src/modules/base/start_chroot_script From f3d3a10dfd44948f7f2f828cd825f7892372b936 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 5 Aug 2024 10:52:12 +0200 Subject: [PATCH 36/50] Revert "test: Use altered DNS servers" This reverts commit bc23b1b5ec2cc706a0395e39290f1fd2d5cd9958. --- src/modules/base/config | 113 ----------- src/modules/base/end_chroot_script | 45 ----- .../lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant | 112 ----------- src/modules/base/start_chroot_script | 189 ------------------ 4 files changed, 459 deletions(-) delete mode 100644 src/modules/base/config delete mode 100755 src/modules/base/end_chroot_script delete mode 100644 src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant delete mode 100644 src/modules/base/start_chroot_script diff --git a/src/modules/base/config b/src/modules/base/config deleted file mode 100644 index da791a6a1..000000000 --- a/src/modules/base/config +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -############################################################################### -# All our config settings must start with BASE_ - -# CustomPiOS version -BASE_VERSION=1.5.0 - -[ -n "$BASE_PRESCRIPT" ] || BASE_PRESCRIPT= -[ -n "$BASE_POSTSCRIPT" ] || BASE_POSTSCRIPT= - -#[ -n "$BASE_SCRIPT_PATH" ] || BASE_SCRIPT_PATH=$CONFIG_DIR -[ -n "$BASE_IMAGE_PATH" ] || BASE_IMAGE_PATH=${DIST_PATH}/image -[ -n "$BASE_IMAGE_RASPBIAN" ] || BASE_IMAGE_RASPBIAN=yes - -# Distro -[ -n "$BASE_DISTRO" ] || BASE_DISTRO=raspbian - -# Note: Set BASE_ZIP_IMG relative to the distro/src/workspace directory to pass a custom named file or an already extracted '.img'-file. -if [ "${BASE_DISTRO}" = "ubuntu" ]; then - # Default image ubuntu - [ -n "$BASE_ZIP_IMG" ] || BASE_ZIP_IMG=$(ls -t $BASE_IMAGE_PATH/ubuntu-*.xz | head -n 1) - # Default user ubuntu - [ -n "$BASE_USER" ] || BASE_USER=ubuntu - - # Add base user if does not exist - [ -n "$BASE_ADD_USER" ] || BASE_ADD_USER=yes - # When adding a base user which password to use - [ -n "$BASE_USER_PASSWORD" ] || BASE_USER_PASSWORD=ubuntu -else - # Default image raspbian - if [ "${BASE_DISTRO}" = "raspios64" ]; then - [ -n "$BASE_ZIP_IMG" ] || BASE_ZIP_IMG=$(ls -t $BASE_IMAGE_PATH/*-{raspbian,raspios}-*-arm64-*.{zip,7z,xz} | head -n 1) - else - [ -n "$BASE_ZIP_IMG" ] || BASE_ZIP_IMG=$(ls -t $BASE_IMAGE_PATH/*-{raspbian,raspios}*.{zip,7z,xz} | head -n 1) - fi - # Default user raspbian - [ -n "$BASE_USER" ] || BASE_USER=pi - [ -n "$BASE_ADD_USER" ] || BASE_ADD_USER=yes - [ -n "$BASE_USER_PASSWORD" ] || BASE_USER_PASSWORD=raspberry -fi - -# Release compression -[ -n "$BASE_RELEASE_COMPRESS" ] || BASE_RELEASE_COMPRESS=yes - -[ -n "$BASE_RELEASE_IMG_NAME" ] || BASE_RELEASE_IMG_NAME=default -[ -n "$BASE_RELEASE_ZIP_NAME" ] || BASE_RELEASE_ZIP_NAME=default - -[ -n "$BASE_WORKSPACE" ] || BASE_WORKSPACE=${DIST_PATH}/workspace$WORKSPACE_POSTFIX -# [ -n "$BASE_CHROOT_SCRIPT_PATH" ] || BASE_CHROOT_SCRIPT_PATH=$BASE_SCRIPT_PATH/chroot_script -[ -n "$BASE_MOUNT_PATH" ] || BASE_MOUNT_PATH=$BASE_WORKSPACE/mount - -[ -n "${BASE_BOOT_MOUNT_PATH}" ] || BASE_BOOT_MOUNT_PATH=boot/firmware - -# The root partition of the image filesystem, 2 for raspbian -[ -n "$BASE_ROOT_PARTITION" ] || BASE_ROOT_PARTITION=2 - -# if set will enlarge root partition prior to build by provided size in MB -[ -n "$BASE_IMAGE_ENLARGEROOT" ] || BASE_IMAGE_ENLARGEROOT=200 - -# if set will resize root partition on image after build to minimum size + -# provided size in MB -[ -n "$BASE_IMAGE_RESIZEROOT" ] || BASE_IMAGE_RESIZEROOT=200 - -# a local directory on the build server to bind mount under /var/cache/apt -[ -n "$BASE_APT_CACHE" ] || BASE_APT_CACHE=$BASE_WORKSPACE/aptcache - -# a host:port combo for a apt-proxy (such as apt-cacher-ng) to use -[ -n "$BASE_APT_PROXY" ] || BASE_APT_PROXY= - -[ -n "$BASE_APT_MIRROR" ] || BASE_APT_MIRROR= - -# an alternative pypi index url to use, e.g. a proxy such as devpi -[ -n "$BASE_PYPI_INDEX" ] || BASE_PYPI_INDEX= - -[ -n "$BASE_OVERRIDE_HOSTNAME" ] || BASE_OVERRIDE_HOSTNAME=${DIST_NAME,,} - -# Alter DNS servers used during build (space seperated) -# e.g. BASE_USE_ALT_DNS="1.1.1.1 8.8.8.8" -[ -n "$BASE_USE_ALT_DNS" ] || BASE_USE_ALT_DNS= - -# a git mirror to use for git clones instead of original remotes -[ -n "$BASE_BUILD_REPO_MIRROR" ] || BASE_BUILD_REPO_MIRROR= - -# Enable ssh daemon -[ -n "$BASE_SSH_ENABLE" ] || BASE_SSH_ENABLE=yes - -#Store the commit used for CustomPiOS -[ -n "$BASE_COMMIT" ] || BASE_COMMIT=$(git -C "${CUSTOM_PI_OS_PATH}" rev-parse HEAD) || true - -#Memory split -[ -n "$BASE_CONFIG_MEMSPLIT" ] || BASE_CONFIG_MEMSPLIT=default - -#Timezone -[ -n "$BASE_CONFIG_TIMEZONE" ] || BASE_CONFIG_TIMEZONE=default - -#Locale -[ -n "$BASE_CONFIG_LOCALE" ] || BASE_CONFIG_LOCALE=default - -#Keyboard -[ -n "$BASE_CONFIG_KEYBOARD" ] || BASE_CONFIG_KEYBOARD=default - -# Arch for now either armv7l, arm64 or aarch64 -[ -n "$BASE_ARCH" ] || BASE_ARCH=armv7l - -# If you want your variant not to have the name appending, enable this -[ -n "$BASE_IGNORE_VARIANT_NAME" ] || BASE_IGNORE_VARIANT_NAME=no - -# Enable uart console on boot -[ -n "$BASE_ENABLE_UART" ] || BASE_ENABLE_UART=no - - -# Clean apt-cache after all the work is done -: ${BASE_APT_CLEAN:=yes} diff --git a/src/modules/base/end_chroot_script b/src/modules/base/end_chroot_script deleted file mode 100755 index 37b21c722..000000000 --- a/src/modules/base/end_chroot_script +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -# Base script -# Basic and manditory settings for the base of a CustomPiOS build -# Written by Guy Sheffer -# GPL V3 -######## -set -ex - -if [ -n "$BASE_APT_PROXY" ] -then - rm -r /etc/apt/apt.conf.d/02octopi_build_proxy -fi - -if [ -n "${BASE_APT_MIRROR}" ]; then - sed -i '1d' /etc/apt/sources.list -fi - -if [ -n "$BASE_PYPI_INDEX" ] -then - rm -r /root/.pip - rm -r /root/.pydistutils.cfg - rm -r /home/"${BASE_USER}"/.pip/pip.conf - rm -r /home/"${BASE_USER}"/.pydistutils.cfg -fi - -#reach device by name -if [ -f /etc/hostname ]; then - read FILE_HOST_NAME < /etc/hostname - FILE_HOST_NAME=${FILE_HOST_NAME//$'\n'/} - else - FILE_HOST_NAME=raspberrypi -fi - -echo "$BASE_OVERRIDE_HOSTNAME" > /etc/hostname -sed -i -e "s@${FILE_HOST_NAME}@$BASE_OVERRIDE_HOSTNAME@g" /etc/hosts - -if [ "${BASE_DISTRO}" == "ubuntu" ];then - echo "127.0.0.1 ${BASE_OVERRIDE_HOSTNAME}" > /etc/hosts -fi - -#cleanup -if [ "${BASE_APT_CLEAN}" = "yes" ]; then - apt-get clean -fi -apt-get autoremove -y diff --git a/src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant b/src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant deleted file mode 100644 index b0cf51842..000000000 --- a/src/modules/base/filesystem/ubuntu/usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant +++ /dev/null @@ -1,112 +0,0 @@ -# Start, reconfigure and stop wpa_supplicant per wireless interface. -# This is needed because wpa_supplicant lacks hotplugging of any kind -# and the user should not be expected to have to wire it into their system -# if the base system doesn't do this itself. - -if [ -z "$wpa_supplicant_conf" ]; then - for x in \ - /etc/wpa_supplicant/wpa_supplicant-"$interface".conf \ - /etc/wpa_supplicant/wpa_supplicant.conf \ - /etc/wpa_supplicant-"$interface".conf \ - /etc/wpa_supplicant.conf \ - ; do - if [ -s "$x" ]; then - wpa_supplicant_conf="$x" - break - fi - done -fi -: ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf} - -wpa_supplicant_ctrldir() -{ - dir=$(key_get_value "[[:space:]]*ctrl_interface=" \ - "$wpa_supplicant_conf") - dir=$(trim "$dir") - case "$dir" in - DIR=*) - dir=${dir##DIR=} - dir=${dir%%[[:space:]]GROUP=*} - dir=$(trim "$dir") - ;; - esac - printf %s "$dir" -} - -wpa_supplicant_start() -{ - # If the carrier is up, don't bother checking anything - [ "$ifcarrier" = "up" ] && return 0 - - # Pre flight checks - if [ ! -s "$wpa_supplicant_conf" ]; then - syslog warn \ - "$wpa_supplicant_conf does not exist" - syslog warn "not interacting with wpa_supplicant(8)" - return 1 - fi - dir=$(wpa_supplicant_ctrldir) - if [ -z "$dir" ]; then - syslog warn \ - "ctrl_interface not defined in $wpa_supplicant_conf" - syslog warn "not interacting with wpa_supplicant(8)" - return 1 - fi - - wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1 && return 0 - syslog info "starting wpa_supplicant" - wpa_supplicant_driver="${wpa_supplicant_driver:-nl80211,wext}" - driver=${wpa_supplicant_driver:+-D}$wpa_supplicant_driver - err=$(wpa_supplicant -B -c"$wpa_supplicant_conf" -i"$interface" \ - "$driver" 2>&1) - errn=$? - if [ $errn != 0 ]; then - syslog err "failed to start wpa_supplicant" - syslog err "$err" - fi - return $errn -} - -wpa_supplicant_reconfigure() -{ - dir=$(wpa_supplicant_ctrldir) - [ -z "$dir" ] && return 1 - if ! wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1; then - wpa_supplicant_start - return $? - fi - syslog info "reconfiguring wpa_supplicant" - err=$(wpa_cli -p "$dir" -i "$interface" reconfigure 2>&1) - errn=$? - if [ $errn != 0 ]; then - syslog err "failed to reconfigure wpa_supplicant" - syslog err "$err" - fi - return $errn -} - -wpa_supplicant_stop() -{ - dir=$(wpa_supplicant_ctrldir) - [ -z "$dir" ] && return 1 - wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1 || return 0 - syslog info "stopping wpa_supplicant" - err=$(wpa_cli -i"$interface" terminate 2>&1) - errn=$? - if [ $errn != 0 ]; then - syslog err "failed to start wpa_supplicant" - syslog err "$err" - fi - return $errn -} - -if [ "$ifwireless" = "1" ] && \ - type wpa_supplicant >/dev/null 2>&1 && \ - type wpa_cli >/dev/null 2>&1 -then - case "$reason" in - PREINIT) wpa_supplicant_start;; - RECONFIGURE) wpa_supplicant_reconfigure;; - DEPARTED) wpa_supplicant_stop;; - esac -fi diff --git a/src/modules/base/start_chroot_script b/src/modules/base/start_chroot_script deleted file mode 100644 index 9e92cf85a..000000000 --- a/src/modules/base/start_chroot_script +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env bash -# Base script -# Basic and manditory settings for the base of a CustomPiOS build -# Written by Guy Sheffer -# GPL V3 -######## -set -x -set -e - -export LC_ALL=C - -source /common.sh -install_cleanup_trap -if [ -n "${BASE_APT_MIRROR}" ]; then - echo "${BASE_APT_MIRROR}" | cat - /etc/apt/sources.list > /tmp/filename.tmp - mv /tmp/filename.tmp /etc/apt/sources.list -fi - -if [ "${BASE_DISTRO}" == "ubuntu" ]; then - unpack /filesystem/ubuntu / root - - mv /etc/resolv.conf /etc/resolv.conf.orig || true - if [ -z "${BASE_USE_ALT_DNS}" ]; then - echo "nameserver 8.8.8.8" > /etc/resolv.conf - echo "nameserver 8.8.4.4" >> /etc/resolv.conf - echo "nameserver 1.1.1.1" >> /etc/resolv.conf - else - touch /etc/resolv.conf - for dns in ${BASE_USE_ALT_DNS}; do - echo "nameserver ${dns}" >> /etc/resolv.conf - done - fi - - - apt-get update --allow-releaseinfo-change - apt-get install -y net-tools wireless-tools dhcpcd5 - if [ $( is_in_apt policykit-1 ) -eq 1 ]; then - apt-get -y install policykit-1 - fi - - # prevent any installed services from automatically starting - echo exit 101 > /usr/sbin/policy-rc.d - chmod +x /usr/sbin/policy-rc.d - systemctl enable dhcpcd.service - - #Undo prevent any installed services from automatically starting - rm -r /usr/sbin/policy-rc.d || true - -fi - -#Helper Function for create_userconf -function get_os_version { - local os_version - grep -c "buster" /etc/os-release -} - -if [ "${BASE_ADD_USER}" == "yes" ]; then - if [ "${BASE_DISTRO}" == "raspbian" ] || [ "${BASE_DISTRO}" == "raspios64" ] || [ "${BASE_DISTRO}" == "raspios" ]; then - # Setup first user, reference: - # https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-a-user - echo_green "Setup default user and password ..." - function create_userconf { - local pw_encrypt - if [ -n "${BASE_USER}" ] || [ -n "${BASE_USER_PASSWORD}" ]; then - pw_encrypt="$(echo "${BASE_USER_PASSWORD}" | openssl passwd -6 -stdin)" - echo "${BASE_USER}:${pw_encrypt}" > /"${BASE_BOOT_MOUNT_PATH}"/userconf.txt - - # Upgrade pkg first, make sure latest version will be patched - apt-get install --yes --only-upgrade userconf-pi - - # Patch cancel-rename due to https://github.com/RPi-Distro/userconf-pi/issues/2 - # And https://github.com/guysoft/CustomPiOS/issues/163 - # Since the new version has changed an lead to Error described in - # https://github.com/guysoft/CustomPiOS/issues/176 - # use a more generic way to patch the script. - if [[ -f "/usr/bin/cancel-rename" ]]; then - sed -i 's|do_boot_behaviour B2|do_boot_behaviour B1|g' /usr/bin/cancel-rename - fi - - else - echo_red "First user name and password not set! [FAILED]" - exit 1 - fi - } - # Do not patch if raspian="buster" - if [ "$(get_os_version)" == "0" ]; then - create_userconf - else - echo "Base Image use Version 'buster' no patching of userconf-pi needed" - fi - else - if id -u "${BASE_USER}" >/dev/null 2>&1; then - echo "Base user exists, not adding" - else - echo "Adding base user ${BASE_USER}" - password=$(perl -e 'printf("%s\n", crypt($ARGV[0], "password"))' "${BASE_USER_PASSWORD}") - useradd -m -p "${password}" -s /bin/bash "${BASE_USER}" - usermod -a -G sudo "${BASE_USER}" - fi - fi -fi - -if [ -n "$BASE_APT_PROXY" ] -then - echo "Acquire::http { Proxy \"http://$BASE_APT_PROXY\"; };" > /etc/apt/apt.conf.d/02octopi_build_proxy -fi - -if [ -n "$BASE_PYPI_INDEX" ] -then - pip_index_config="[global]\nindex-url = $BASE_PYPI_INDEX" - easyinstall_index_config="[easy_install]\nindex-url = $BASE_PYPI_INDEX" - - mkdir -p /root/.pip - echo -e "$pip_index_config" > /root/.pip/pip.conf - echo -e "$easyinstall_index_config" > /root/.pydistutils.cfg - - mkdir -p /home/"${BASE_USER}"/.pip - sudo -u "${BASE_USER}" echo -e "$pip_index_config" > /home/pi/.pip/pip.conf - sudo -u "${BASE_USER}" echo -e "$easyinstall_index_config" > /home/pi/.pydistutils.cfg - - echo "Configured pypi index url $BASE_PYPI_INDEX" - cat /home/"${BASE_USER}"/.pip/pip.conf - cat /home/"${BASE_USER}"/.pydistutils.cfg -fi - -if [ "$BASE_SSH_ENABLE" == "yes" ] -then - touch /"${BASE_BOOT_MOUNT_PATH}"/ssh - ### Fix SSH incoming - echo "IPQoS 0x00" >> /etc/ssh/sshd_config - - ### Fix SSH outgoing - echo "IPQoS 0x00" >> /etc/ssh/ssh_config - - ### Try and fix https://github.com/guysoft/OctoPi/issues/424 - if [ -f "/lib/systemd/system/regenerate_ssh_host_keys.service" ]; then - sed -i "s@ExecStart=/usr/bin/ssh-keygen -A -v@ExecStart=/bin/bash -c ' /usr/bin/ssh-keygen -A -v >> /var/log/regenerate_ssh_host_keys.log 2>\&1'@g" /lib/systemd/system/regenerate_ssh_host_keys.service - sed -i "s@ExecStartPost=/bin/systemctl disable regenerate_ssh_host_keys@ExecStartPost=/bin/bash -c 'for i in /etc/ssh/ssh_host_*_key*; do actualsize=\$(wc -c <\"\$i\") ;if [ \$actualsize -eq 0 ]; then echo size is 0 bytes ; exit 1 ; fi ; done ; /bin/systemctl disable regenerate_ssh_host_keys'@g" /lib/systemd/system/regenerate_ssh_host_keys.service - fi -fi - -# Store version buildbase -echo "$CUSTOM_PI_OS_BUILDBASE" > /etc/custompios_buildbase - -# Store dist version -echo "$DIST_VERSION" > /etc/${DIST_NAME,,}_version - -# Store dist variant -echo "$BUILD_VARIANT" > /etc/dist_variant - -########################## -# Raspi-config stuff -# https://github.com/RPi-Distro/raspi-config/blob/master/raspi-config - -# Memory split -if [ $BASE_CONFIG_MEMSPLIT != 'default' ] -then - echo "Configuring memory" - raspi-config nonint do_memory_split $BASE_CONFIG_MEMSPLIT -fi - -# timezone -if [ $BASE_CONFIG_TIMEZONE != 'default' ] -then - echo "Configuring timezone" - raspi-config nonint do_change_timezone $BASE_CONFIG_TIMEZONE -fi - -# locale -if [ $BASE_CONFIG_LOCALE != 'default' ] -then - echo "Configuring locales" - raspi-config nonint do_change_locale $BASE_CONFIG_LOCALE -fi - -# keyboard -if [ $BASE_CONFIG_KEYBOARD != 'default' ] -then - echo "Configuring keyboard" - raspi-config nonint do_configure_keyboard $BASE_CONFIG_KEYBOARD -fi - -# Enable uart on boot -if [ ${BASE_ENABLE_UART} == "yes" ] -then - if ! grep -q "^enable_uart=1" /"${BASE_BOOT_MOUNT_PATH}"/config.txt ; then - echo "enable_uart=1" >> /"${BASE_BOOT_MOUNT_PATH}"/config.txt - fi -fi From 70f27681bf3eab031f23f83fe000b33d2cb1783d Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 5 Aug 2024 10:58:57 +0200 Subject: [PATCH 37/50] test: test PR repo This will be reverted! Signed-off-by: Stephan Wendel --- .github/workflows/BuildImages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index a0813ad53..922cdcbdd 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -64,6 +64,8 @@ jobs: uses: ./repository/.github/actions/build with: config: ${{ matrix.config }} + custompios-repository: KwadFan/CustomPiOS + custompios-ref: "base/dnsresolv" - name: Rename image file id: move-image From c24708f87718680bb39907a4f43bb2980740dacd Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 5 Aug 2024 11:14:05 +0200 Subject: [PATCH 38/50] test: run with altered dns Signed-off-by: Stephan Wendel --- config/default | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/default b/config/default index 4b619ac76..e3fb9a54e 100644 --- a/config/default +++ b/config/default @@ -22,11 +22,14 @@ DIST_NAME="MainsailOS" BASE_BOOT_MOUNT_PATH=boot +BASE_USE_ALT_DNS="1.0.0.1 1.1.1.1 8.8.8.8 8.8.4.4 9.9.9.9 149.112.112.112 208.67.222.222 208.67.220.220" + # export Variables export BASE_BOOT_MOUNT_PATH export DIST_NAME export DIST_VERSION export BASE_ZIP_IMG +export BASE_USE_ALT_DNS ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! From 13861831415cd4ccd03bcd157f3ea53ae8320a05 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 5 Aug 2024 12:38:15 +0200 Subject: [PATCH 39/50] Revert "test: run with altered dns" This reverts commit c24708f87718680bb39907a4f43bb2980740dacd. --- config/default | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/default b/config/default index e3fb9a54e..4b619ac76 100644 --- a/config/default +++ b/config/default @@ -22,14 +22,11 @@ DIST_NAME="MainsailOS" BASE_BOOT_MOUNT_PATH=boot -BASE_USE_ALT_DNS="1.0.0.1 1.1.1.1 8.8.8.8 8.8.4.4 9.9.9.9 149.112.112.112 208.67.222.222 208.67.220.220" - # export Variables export BASE_BOOT_MOUNT_PATH export DIST_NAME export DIST_VERSION export BASE_ZIP_IMG -export BASE_USE_ALT_DNS ### JSON sniplet Setup ### NOTE: Please see all config files for setup variables!!! From 6afb601911bd518ee4ec4ee86b2dad4404edb2d9 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 5 Aug 2024 12:38:28 +0200 Subject: [PATCH 40/50] Revert "test: test PR repo" This reverts commit 70f27681bf3eab031f23f83fe000b33d2cb1783d. --- .github/workflows/BuildImages.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index 922cdcbdd..a0813ad53 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -64,8 +64,6 @@ jobs: uses: ./repository/.github/actions/build with: config: ${{ matrix.config }} - custompios-repository: KwadFan/CustomPiOS - custompios-ref: "base/dnsresolv" - name: Rename image file id: move-image From 0309feab2d2c37327bc2b25ab2b3251620ca37f7 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 5 Aug 2024 14:02:34 +0200 Subject: [PATCH 41/50] test: test potential PR to custompios This will be reverted! Signed-off-by: Stephan Wendel --- .github/workflows/BuildImages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index a0813ad53..84cbe5ea8 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -64,6 +64,8 @@ jobs: uses: ./repository/.github/actions/build with: config: ${{ matrix.config }} + custompios-repository: KwadFan/CustomPiOS + custompios-ref: fix/chrootmount - name: Rename image file id: move-image From a0985b0d00ee0fdbdd6d38e58e92fc8e93179964 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 6 Aug 2024 12:10:38 +0200 Subject: [PATCH 42/50] test: test run for fix/armbiandns pr This run is to proof function of https://github.com/guysoft/CustomPiOS/pull/226 Signed-off-by: Stephan Wendel --- .github/workflows/BuildImages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index 84cbe5ea8..0f5e1f41c 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -65,7 +65,7 @@ jobs: with: config: ${{ matrix.config }} custompios-repository: KwadFan/CustomPiOS - custompios-ref: fix/chrootmount + custompios-ref: fix/armbiandns - name: Rename image file id: move-image From 09bcaf31260106bab7518cd84ca8bacfd36f7862 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 31 Aug 2024 08:58:14 +0200 Subject: [PATCH 43/50] chore: revert to original custompios repo Signed-off-by: Stephan Wendel --- .github/workflows/BuildImages.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index 0f5e1f41c..a0813ad53 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -64,8 +64,6 @@ jobs: uses: ./repository/.github/actions/build with: config: ${{ matrix.config }} - custompios-repository: KwadFan/CustomPiOS - custompios-ref: fix/armbiandns - name: Rename image file id: move-image From beecb249d6700cdf57bff5aa94401ac60ce6bdec Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 31 Aug 2024 09:51:12 +0200 Subject: [PATCH 44/50] chore: remove bullseye control builds Signed-off-by: Stephan Wendel --- config/armbian/orangepi4lts-bullseye | 25 ------------------------- config/raspberry/rpi64-bullseye | 28 ---------------------------- 2 files changed, 53 deletions(-) delete mode 100644 config/armbian/orangepi4lts-bullseye delete mode 100644 config/raspberry/rpi64-bullseye diff --git a/config/armbian/orangepi4lts-bullseye b/config/armbian/orangepi4lts-bullseye deleted file mode 100644 index 03f0d30f8..000000000 --- a/config/armbian/orangepi4lts-bullseye +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# Shebang for better file detection -# shellcheck enable=require-variable-braces - -BASE_ARCH="arm64" - -# Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz" - -# MODULES="base(pkgupgrade,udev_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar))" - - -# export Variables -export BASE_ARCH -export DOWNLOAD_URL_CHECKSUM -export DOWNLOAD_URL_IMAGE -# export MODULES - -### JSON sniplet Setup -### NOTE: Please see all config files for setup variables!!! -# shellcheck disable=SC2034 -JSON_PRETTY_SBC_NAME="Orange Pi 4 LTS" -# shellcheck disable=SC2034 -JSON_SUPPORTED_SBC="orangepi4lts-64bit" diff --git a/config/raspberry/rpi64-bullseye b/config/raspberry/rpi64-bullseye deleted file mode 100644 index ae4b08528..000000000 --- a/config/raspberry/rpi64-bullseye +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# Shebang for better file detection - -# Declare Variables before exporting. -# See https://www.shellcheck.net/wiki/SC2155 - - -BASE_ARCH="arm64" - -DOWNLOAD_BASE_URL="https://downloads.raspberrypi.org/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-12-06/2023-12-05-raspios-bullseye-arm64-lite.img.xz" -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}.torrent" - -BASE_BOOT_MOUNT_PATH=boot - -MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename)" - -# export variables -export BASE_ARCH -export DOWNLOAD_URL_CHECKSUM -export DOWNLOAD_URL_IMAGE -export BASE_BOOT_MOUNT_PATH -export MODULES - -### JSON sniplet Setup -### NOTE: Please see all config files for setup variables!!! -# shellcheck disable=SC2034 -JSON_SUPPORTED_SBC="pi3-64bit pi4-64bit" From b8409b6c8af3b0d452bf314f55cf6bc4e8c2091e Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 31 Aug 2024 09:53:34 +0200 Subject: [PATCH 45/50] fix: fix workflow_config.yml Signed-off-by: Stephan Wendel --- .github/workflow_config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflow_config.yml b/.github/workflow_config.yml index 14fbd989b..1e6b40b30 100644 --- a/.github/workflow_config.yml +++ b/.github/workflow_config.yml @@ -26,9 +26,6 @@ buildtest: - raspberry/rpi64 # rpi 64 with KS - raspberry/rpi64-ks - # Control group - - raspberry/rpi64-bullseye - - armbian/orangepi4lts-bullseye # This is used to setup release build chain. # Each entry will be used in setup matrix for releases From 714283d14a0a1ce8845be13d3e7d7b37dd5ac20a Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 3 Sep 2024 08:05:23 +0200 Subject: [PATCH 46/50] fix: fix missing newline Signed-off-by: Stephan Wendel --- .../filesystem/etc/udev/rules.d/070-wifi-powersave.rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/headless_nm/filesystem/etc/udev/rules.d/070-wifi-powersave.rules b/src/modules/headless_nm/filesystem/etc/udev/rules.d/070-wifi-powersave.rules index 6ff2774c4..61a7f8591 100644 --- a/src/modules/headless_nm/filesystem/etc/udev/rules.d/070-wifi-powersave.rules +++ b/src/modules/headless_nm/filesystem/etc/udev/rules.d/070-wifi-powersave.rules @@ -1,4 +1,4 @@ ACTION=="add", \ SUBSYSTEM=="net", \ KERNEL=="wlan*" \ -RUN+="/usr/sbin/iw %k set power_save off" \ No newline at end of file +RUN+="/usr/sbin/iw %k set power_save off" From 012d6a03ff0220f6dd8bc1a8faf60fc9f808c309 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 3 Sep 2024 09:52:38 +0200 Subject: [PATCH 47/50] chore: fix copyright date Signed-off-by: Stephan Wendel --- .../filesystem/etc/systemd/system/headless_nm.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/headless_nm/filesystem/etc/systemd/system/headless_nm.service b/src/modules/headless_nm/filesystem/etc/systemd/system/headless_nm.service index 3b32501eb..a9e226805 100644 --- a/src/modules/headless_nm/filesystem/etc/systemd/system/headless_nm.service +++ b/src/modules/headless_nm/filesystem/etc/systemd/system/headless_nm.service @@ -1,7 +1,7 @@ #### headless_nm service #### #### Written by Stephan Wendel aka KwadFan -#### Copyright 2022 +#### Copyright 2024 #### https://github.com/mainsail-crew/MainsailOS #### #### This File is distributed under GPLv3 From 30548c4fed8416fe0f58ba8c354c0ecc37669924 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 3 Sep 2024 09:53:51 +0200 Subject: [PATCH 48/50] chore: update wifi-readme.txt Signed-off-by: Stephan Wendel --- .../headless_nm/filesystem/boot/WiFi-README.txt | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/modules/headless_nm/filesystem/boot/WiFi-README.txt b/src/modules/headless_nm/filesystem/boot/WiFi-README.txt index 7e54cfc2b..e32757a63 100644 --- a/src/modules/headless_nm/filesystem/boot/WiFi-README.txt +++ b/src/modules/headless_nm/filesystem/boot/WiFi-README.txt @@ -20,16 +20,10 @@ Wifi-README.txt How do I setup a new network on my OS_NAME ? -------------------------------------------- -1.) If you haven't already done so, insert the SDCard into your computer. - -2.) Open the 'boot' partition. - This partition is FAT32 formatted and should be visible, - when you insert the SD Card into your computer. - -3.) Copy and paste the 'headless_nm.txt.template'. +1.) Copy and paste the 'headless_nm.txt.template'. Rename this file to 'headless_nm.txt' -4.) Now open the file with your favourite text editor. +2.) Now open the file with your favourite text editor. Windows and MacOS users please read the note above! This file is pretty self explaining, just the 'REGDOMAIN' @@ -45,9 +39,9 @@ How do I setup a new network on my OS_NAME ? For a complete list, please visit https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 -5.) Remove the SD card afterwards. +3.) Remove the SD card afterwards. -6.) Almost done... Please put the SD card back into your SBC and wait for it to connect. +4.) Almost done... Please put the SD card back into your SBC and wait for it to connect. NOTE: @@ -62,4 +56,4 @@ If you did not change the hostname during the initial flash, you could use http://OS_NAME.local -7.) Enjoy OS_NAME :) +5.) Enjoy OS_NAME :) From 162cd86904e005cd08913b7dd646be51acc5bc7d Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 3 Sep 2024 09:54:59 +0200 Subject: [PATCH 49/50] chore: reenable pkgupgrade for ks version Signed-off-by: Stephan Wendel --- config/raspberry/rpi64-ks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/raspberry/rpi64-ks b/config/raspberry/rpi64-ks index f50bf6a1f..dc19b6aea 100644 --- a/config/raspberry/rpi64-ks +++ b/config/raspberry/rpi64-ks @@ -9,7 +9,7 @@ BASE_ARCH="arm64" BASE_IMAGE_ENLARGEROOT=6500 # Changed modules -MODULES="base(udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,klipperscreen,crowsnest,sonar,password-for-sudo),postrename)" +MODULES="base(pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,klipperscreen,crowsnest,sonar,password-for-sudo),postrename)" # export variables export BASE_ARCH From 0b81ae4eb5115ef72123247b86e91cc85879b58b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 3 Sep 2024 09:56:24 +0200 Subject: [PATCH 50/50] chore: update headless_nm.txt.template Signed-off-by: Stephan Wendel --- .../headless_nm/filesystem/boot/headless_nm.txt.template | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/headless_nm/filesystem/boot/headless_nm.txt.template b/src/modules/headless_nm/filesystem/boot/headless_nm.txt.template index fa0408a7c..18d5d1a3f 100644 --- a/src/modules/headless_nm/filesystem/boot/headless_nm.txt.template +++ b/src/modules/headless_nm/filesystem/boot/headless_nm.txt.template @@ -3,8 +3,7 @@ # Your Wifis SSID SSID="" -# Your Wifi password, remember it has to have at least 8 characters! -# Otherwise a password hash can not be created! +# Your WiFis password PASSWORD="" # Is your SSID in hidden state? [true/false]