Skip to content

Commit

Permalink
Uee reflash-board instead of custom plugins for switching boot media
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasbakken committed Dec 15, 2023
1 parent 80f58f5 commit cadfac6
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 81 deletions.
30 changes: 9 additions & 21 deletions armbian/customize-image-barebone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]

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"
4 changes: 4 additions & 0 deletions armbian/customize-image-fluidd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."

Expand All @@ -46,8 +47,11 @@ install_klipperscreen
install_ustreamer
install_bins
install_autohotspot
install_reflash_board
add_overlays
fix_netplan
post_build

systemctl disable [email protected]

echo "🍰 Rebuild finished"
2 changes: 2 additions & 0 deletions armbian/customize-image-mainsail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand All @@ -45,6 +46,7 @@ install_klipperscreen
install_ustreamer
install_bins
install_autohotspot
install_reflash_board
add_overlays
fix_netplan
post_build
Expand Down
2 changes: 2 additions & 0 deletions armbian/customize-image-octoprint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -38,6 +39,7 @@ install_octoprint
install_ustreamer
install_bins
install_autohotspot
install_reflash_board
add_overlays
fix_netplan
post_build
Expand Down
71 changes: 20 additions & 51 deletions armbian/customize-image-reflash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]

}

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"
2 changes: 1 addition & 1 deletion armbian/recore.csc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion userpatches/config-rebuild.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -31,3 +31,5 @@ BOARD=recore
BRANCH=legacy
RELEASE=bullseye
ARTIFACT_IGNORE_CACHE=yes
BOOT_FS_LABEL="Recore_boot"
ROOT_FS_LABEL="Recore_root"
1 change: 0 additions & 1 deletion userpatches/overlay/install_components/moonraker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 0 additions & 5 deletions userpatches/overlay/install_components/octoprint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
26 changes: 25 additions & 1 deletion userpatches/overlay/install_components/prep_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}


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 [email protected]

cp /tmp/overlay/rebuild/rebuild-version /etc/
}
23 changes: 23 additions & 0 deletions userpatches/overlay/install_components/reflash.sh
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit cadfac6

Please sign in to comment.