From cadfac6f316a2080da39d93205bc96fd88130f0a Mon Sep 17 00:00:00 2001 From: Elias Bakken Date: Fri, 15 Dec 2023 01:48:26 +0100 Subject: [PATCH] Uee reflash-board instead of custom plugins for switching boot media --- armbian/customize-image-barebone.sh | 30 +++----- armbian/customize-image-fluidd.sh | 4 ++ armbian/customize-image-mainsail.sh | 2 + armbian/customize-image-octoprint.sh | 2 + armbian/customize-image-reflash.sh | 71 ++++++------------- armbian/recore.csc | 2 +- userpatches/config-rebuild.conf | 4 +- .../overlay/install_components/moonraker.sh | 1 - .../overlay/install_components/octoprint.sh | 5 -- .../install_components/prep_install.sh | 26 ++++++- .../overlay/install_components/reflash.sh | 23 ++++++ 11 files changed, 89 insertions(+), 81 deletions(-) create mode 100644 userpatches/overlay/install_components/reflash.sh diff --git a/armbian/customize-image-barebone.sh b/armbian/customize-image-barebone.sh index 6290711..3aec871 100644 --- a/armbian/customize-image-barebone.sh +++ b/armbian/customize-image-barebone.sh @@ -17,36 +17,24 @@ LINUXFAMILY=$2 BOARD=$3 BUILD_DESKTOP=$4 -install_bins(){ - cp /tmp/overlay/bins/* /usr/local/bin - chmod +x /usr/local/bin/* -} - -add_overlays(){ - mkdir /boot/overlay-user - cp /tmp/overlay/dts/* /boot/overlay-user -} +PREP_PACKAGE_LIST="avahi-daemon iptables dnsmasq-base" -fix_netplan(){ - cat <<- EOF > /etc/netplan/armbian-default.yaml - network: - version: 2 - renderer: NetworkManager - EOF -} +source /tmp/overlay/install_components/reflash.sh +source /tmp/overlay/install_components/add_overlays.sh +source /tmp/overlay/install_components/fix_netplan.sh -prepare_build() { +post_build() { echo "ttyGS0" >> /etc/securetty systemctl enable serial-getty@ttyGS0.service + + cp /tmp/overlay/rebuild/rebuild-version /etc/ } echo "🍰 Rebuild starting..." -prepare_build -install_bins add_overlays fix_netplan - -cp /tmp/overlay/rebuild/rebuild-version /etc/ +install_reflash_board +post_build echo "🍰 Rebuild finished" diff --git a/armbian/customize-image-fluidd.sh b/armbian/customize-image-fluidd.sh index 771d20e..d383c31 100644 --- a/armbian/customize-image-fluidd.sh +++ b/armbian/customize-image-fluidd.sh @@ -32,6 +32,7 @@ source /tmp/overlay/install_components/prep_install.sh source /tmp/overlay/install_components/add_overlays.sh source /tmp/overlay/install_components/fix_netplan.sh source /tmp/overlay/install_components/post_build.sh +source /tmp/overlay/install_components/reflash.sh echo "🍰 Rebuild starting..." @@ -46,8 +47,11 @@ install_klipperscreen install_ustreamer install_bins install_autohotspot +install_reflash_board add_overlays fix_netplan post_build +systemctl disable getty@tty1.service + echo "🍰 Rebuild finished" diff --git a/armbian/customize-image-mainsail.sh b/armbian/customize-image-mainsail.sh index d7d50db..3b4f27e 100644 --- a/armbian/customize-image-mainsail.sh +++ b/armbian/customize-image-mainsail.sh @@ -33,6 +33,7 @@ source /tmp/overlay/install_components/autohotspot.sh source /tmp/overlay/install_components/post_build.sh source /tmp/overlay/install_components/add_overlays.sh source /tmp/overlay/install_components/fix_netplan.sh +source /tmp/overlay/install_components/reflash.sh set -e echo "🍰 Rebuild starting..." @@ -45,6 +46,7 @@ install_klipperscreen install_ustreamer install_bins install_autohotspot +install_reflash_board add_overlays fix_netplan post_build diff --git a/armbian/customize-image-octoprint.sh b/armbian/customize-image-octoprint.sh index e6c1eaf..531e725 100644 --- a/armbian/customize-image-octoprint.sh +++ b/armbian/customize-image-octoprint.sh @@ -27,6 +27,7 @@ source /tmp/overlay/install_components/prep_install.sh source /tmp/overlay/install_components/add_overlays.sh source /tmp/overlay/install_components/fix_netplan.sh source /tmp/overlay/install_components/post_build.sh +source /tmp/overlay/install_components/reflash.sh set -e @@ -38,6 +39,7 @@ install_octoprint install_ustreamer install_bins install_autohotspot +install_reflash_board add_overlays fix_netplan post_build diff --git a/armbian/customize-image-reflash.sh b/armbian/customize-image-reflash.sh index c9c114f..c34a038 100644 --- a/armbian/customize-image-reflash.sh +++ b/armbian/customize-image-reflash.sh @@ -17,62 +17,31 @@ LINUXFAMILY=$2 BOARD=$3 BUILD_DESKTOP=$4 -prepare_install(){ - apt update - apt install -y python3-flask python3-requests pv xz-utils avahi-daemon unzip nginx gunicorn expect iptables dnsmasq-base - - # Set new password for root - sh -c 'echo root:temppwd | chpasswd' - - # Add lost+found catalog and make it readable - cd /boot - mklost+found - chmod +r /boot/lost+found - - echo "ttyGS0" >> /etc/securetty - systemctl enable serial-getty@ttyGS0.service - -} - -install_reflash() { - cd /usr/src - wget https://github.com/intelligent-agent/Reflash/releases/download/v0.1.2-RC2/reflash.tar.gz - tar -xf reflash.tar.gz - cd reflash - chmod +x ./scripts/install_reflash.sh - ./scripts/install_reflash.sh -} - -install_autohotspot() { - # Install autohotspot script - cp /tmp/overlay/autohotspot/autohotspot /usr/local/bin - chmod +x /usr/local/bin/autohotspot - - # Install autohotspot service file - cp /tmp/overlay/autohotspot/autohotspot.service /etc/systemd/system/ - - systemctl enable autohotspot.service -} - -add_overlays(){ - mkdir /boot/overlay-user - cp /tmp/overlay/dts/* /boot/overlay-user -} - -fix_netplan(){ - cat <<- EOF > /etc/netplan/armbian-default.yaml - network: - version: 2 - renderer: NetworkManager - EOF +PREP_PACKAGE_LIST="avahi-daemon iptables dnsmasq-base" + +source /tmp/overlay/install_components/prep_install.sh +source /tmp/overlay/install_components/add_overlays.sh +source /tmp/overlay/install_components/reflash.sh + +local_fixups() { + # Add lost+found catalog and make it readable + cd /boot + mklost+found + chmod +r /boot/lost+found + + # Fix netplan error. This is probably a bugfix for Armbian. + cat <<- EOF > /etc/netplan/armbian-default.yaml + network: + version: 2 + renderer: NetworkManager +EOF } set -e echo "🍰 Reflash starting..." -prepare_install +prepare_build_reflash install_reflash -install_autohotspot add_overlays -fix_netplan +local_fixups echo "🍰 Custom script completed" diff --git a/armbian/recore.csc b/armbian/recore.csc index fd62437..0928168 100644 --- a/armbian/recore.csc +++ b/armbian/recore.csc @@ -7,7 +7,7 @@ MODULES="g_serial" BOOT_LOGO="yes" function post_family_config__shrink_atf() { - echo "🍰CHoose ATF branch" + echo "🍰Choose ATF branch" declare -g ATFBRANCH="tag:v2.8.0" echo "🍰Shrink ATF" diff --git a/userpatches/config-rebuild.conf b/userpatches/config-rebuild.conf index b831371..1db87ea 100644 --- a/userpatches/config-rebuild.conf +++ b/userpatches/config-rebuild.conf @@ -15,7 +15,7 @@ KERNEL_CONFIGURE="no" # "images" = delete "./output/images", # "cache" = delete "./output/cache", "sources" = delete "./sources" # "oldcache" = remove old cached rootfs except for the newest 8 files -CLEAN_LEVEL="images,oldcache,debs,make" +CLEAN_LEVEL="images,oldcache" PACKAGE_LIST_BOARD="avahi-daemon plymouth" @@ -31,3 +31,5 @@ BOARD=recore BRANCH=legacy RELEASE=bullseye ARTIFACT_IGNORE_CACHE=yes +BOOT_FS_LABEL="Recore_boot" +ROOT_FS_LABEL="Recore_root" diff --git a/userpatches/overlay/install_components/moonraker.sh b/userpatches/overlay/install_components/moonraker.sh index 323dc27..0912e4d 100644 --- a/userpatches/overlay/install_components/moonraker.sh +++ b/userpatches/overlay/install_components/moonraker.sh @@ -8,5 +8,4 @@ install_moonraker(){ su -c "/home/debian/moonraker/scripts/install-moonraker.sh" debian su -c "/home/debian/moonraker/scripts/set-policykit-rules.sh" debian cp /tmp/overlay/moonraker/moonraker.conf /home/debian/printer_data/config - cp /tmp/overlay/moonraker/recore.py /home/debian/moonraker/moonraker/components } \ No newline at end of file diff --git a/userpatches/overlay/install_components/octoprint.sh b/userpatches/overlay/install_components/octoprint.sh index b158901..2ab6e86 100644 --- a/userpatches/overlay/install_components/octoprint.sh +++ b/userpatches/overlay/install_components/octoprint.sh @@ -32,11 +32,6 @@ install_octoprint(){ git clone https://github.com/LazeMSS/OctoPrint-TopTemp.git cd OctoPrint-TopTemp /home/debian/OctoPrint/venv/bin/python setup.py install - - cd /home/debian - git clone https://github.com/intelligent-agent/octoprint_refactor.git - cd octoprint_refactor/ - /home/debian/OctoPrint/venv/bin/python setup.py install } install_octodash() { diff --git a/userpatches/overlay/install_components/prep_install.sh b/userpatches/overlay/install_components/prep_install.sh index d1911c0..1ebf92f 100644 --- a/userpatches/overlay/install_components/prep_install.sh +++ b/userpatches/overlay/install_components/prep_install.sh @@ -29,4 +29,28 @@ prepare_build() { cp /tmp/overlay/rebuild/rebuild-version /etc/ # Backwards compatibility with refactor cp /tmp/overlay/rebuild/rebuild-version /etc/refactor.version -} \ No newline at end of file +} + + +prepare_build_reflash() { + echo "🍰 Prepare build" + + apt update + apt install -y $PREP_PACKAGE_LIST --no-install-recommends --no-install-suggests + + # Ensure the debian user exists + useradd debian -d /home/debian -G tty,dialout -m -s /bin/bash -e -1 + echo "debian ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/debian + + # Set default passwords + echo debian:temppwd | chpasswd + echo root:temppwd | chpasswd + + # Disable SSH root access + sed -i 's/^PermitRootLogin.*$/#PermitRootLogin/g' /etc/ssh/sshd_config + + echo "ttyGS0" >> /etc/securetty + systemctl enable serial-getty@ttyGS0.service + + cp /tmp/overlay/rebuild/rebuild-version /etc/ +} diff --git a/userpatches/overlay/install_components/reflash.sh b/userpatches/overlay/install_components/reflash.sh new file mode 100644 index 0000000..3542cf1 --- /dev/null +++ b/userpatches/overlay/install_components/reflash.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +install_reflash() { + apt install -y python3-gevent python3-flask python3-requests python3-pip pv xz-utils unzip nginx gunicorn --no-install-recommends --no-install-suggests + pip install sqlitedict + cd /usr/src + wget https://github.com/intelligent-agent/Reflash/releases/download/v0.2.0-RC1/reflash.tar.gz + tar -xf reflash.tar.gz + cd reflash + chmod +x ./scripts/install_reflash.sh + ./scripts/install_reflash.sh +} + +install_reflash_board() { + apt install -y python3-gevent python3-flask python3-requests python3-pip nginx gunicorn --no-install-recommends --no-install-suggests + pip install sqlitedict + cd /usr/src + wget https://github.com/intelligent-agent/Reflash/releases/download/v0.2.0-RC1/reflash-board.tar.gz + tar -xf reflash-board.tar.gz + cd reflash + chmod +x ./scripts/install_reflash_board.sh + ./scripts/install_reflash_board.sh +}