From cb890afafaa1ab6dc68fbfdc103ceca61432e064 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 30 Dec 2022 23:05:36 +0100 Subject: [PATCH 01/39] fix: fix syntax error in net module (#191) * fix: fix syntax error in net module Signed-off-by: Stephan Wendel * chore: add patch script This adds a script that can be used to patch MainsailOS to latest changes Adds README.md for usage Signed-off-by: Stephan Wendel Signed-off-by: Stephan Wendel --- patches/Readme.md | 11 +++ patches/patch.sh | 135 ++++++++++++++++++++++++++++ src/modules/net/config | 4 +- src/modules/net/start_chroot_script | 13 ++- 4 files changed, 154 insertions(+), 9 deletions(-) create mode 100644 patches/Readme.md create mode 100755 patches/patch.sh diff --git a/patches/Readme.md b/patches/Readme.md new file mode 100644 index 000000000..a7c2e15dd --- /dev/null +++ b/patches/Readme.md @@ -0,0 +1,11 @@ +# Patches + +This Folder contains a script to patch MainsailOS to latest changes. + +## Usage + +`curl -sSL https://raw.githubusercontent.com/mainsail-crew/MainsailOS/develop/patches/patch.sh | bash` + +This will ask you for sudo password! + +In most cases a reboot is required! diff --git a/patches/patch.sh b/patches/patch.sh new file mode 100755 index 000000000..486c785ca --- /dev/null +++ b/patches/patch.sh @@ -0,0 +1,135 @@ +#!/usr/bin/env bash + +#### Patch Script +#### This will patch MainsailOS to the Latest Changes +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2021 +#### https://github.com/mainsail-crew/crowsnest +#### +#### This File is distributed under GPLv3 +#### + +# Error Handling +set -eo pipefail + +# Debug +# set -x + +### Variables +# shellcheck disable=SC2034 +DEBIAN_FRONTEND="noninteractive" + +# Global Vars +MAINSAILOS_VER="1.0.1" + +TITLE="\e[31mMainsailOS Patcher\e[0m - Patch OS to latest changes (MainsailOS ${MAINSAILOS_VER})" +RELEASE_FILE="/etc/mainsailos-release" +BASE_DL_URL="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/develop" + +# Message Vars +MP_OK="\e[32mOK\e[0m" +MP_SK="\e[33mSKIPPED\e[0m" + +## Helper funcs + +## Message Funcs + +echo_green(){ + echo -e "\e[32m${1}\e[0m" +} + +echo_red(){ + echo -e "\e[31m${1}\e[0m" +} + +echo_blue(){ + echo -e "\e[34m${1}\e[0m" +} + +echo_yellow(){ + echo -e "\e[33m${1}\e[0m" +} + +print_header(){ + echo -e "${TITLE}\n" + echo_blue "Ahoi!" + echo -e "Please be patient, this might take a while ..." + echo_red "\tYou'll be prompted for sudo password!\n" + # Dirty hack to grant root priviledges + sudo echo -e "\n" + echo -e "Trying to patch your system ..." +} + +print_footer(){ + echo -e "\nThank you for being patient ..." + echo_red "Reboot as soon as possible!\n" +} + +# Helper Funcs + +## CHeck Version +check_version(){ + local version + version="$(grep "1\.[0-9]\.[0-9]" "${RELEASE_FILE}" 2> /dev/null || true)" + if [[ -z "${version}" ]]; then + echo_red "Minimum required MainsailOS Version is 1.0.0! ... [Exiting]" + exit 1 + fi +} + +# Patch Funcs + +# patch mainsailos-release file +patch_release_file(){ + sudo sed -i 's|[0-9]\.[0-9]\.[0-9]|'"${MAINSAILOS_VER}"'|' "${RELEASE_FILE}" +} + +## This patches udev rules error +## See https://github.com/mainsail-crew/MainsailOS/issues/190 +## Keep function naming convention for patches! +## For ex: patch from 1.0.0 to 1.0.1 is named patch_101 + +patch_101(){ + local dl_file + dl_file="${BASE_DL_URL}/src/modules/net/filesystem/usr/local/bin/pwrsave-udev" + echo_blue "Running Wifi Powersave Patch ..." + echo -e "Search for pwrsave-udev script ..." + if [[ ! -f "/usr/local/bin/powersave-udev" ]]; then + echo -e "Script not found! Installing ..." + sudo wget -O "/usr/local/bin/pwrsave-udev" "${dl_file}" + sudo chmod +x "/usr/local/bin/pwrsave-udev" + echo -e "Script not found! Installing ... \t${MP_OK}" + else + echo -e "Script found! ... \t${MP_SK}" + fi + + echo -e "Search for udev Rule file ..." + if [[ ! -f "/etc/udev/rules.d/070-wifi-powersave.rules" ]]; then + echo -e "udev rule not found! Installing ..." + sudo bash -c '/usr/local/bin/pwrsave-udev create' + sudo bash -c '/usr/local/bin/pwrsave-udev off' + echo -e "udev rule not found! Installing ...\t${MP_OK}" + else + echo -e "udev Rule found! ... \t${MP_SK}" + fi + echo_blue "Running Wifi Powersave Patch ... ${MP_OK}" +} + + +### Main + +# Step 1: Print Header +print_header + +# Step 2: Check Version requirement +check_version + +# Step 3: Apply patches +patch_101 + +# Step 4: Patch release file to match versions +patch_release_file + +# Step 5: Print footer +print_footer diff --git a/src/modules/net/config b/src/modules/net/config index 3b5df77d8..1cf106409 100755 --- a/src/modules/net/config +++ b/src/modules/net/config @@ -2,7 +2,7 @@ # shellcheck disable=all # Use disable power save for wifi module -[ -n "$NETWORK_DISABLE_PWRSAVE" ] || NETWORK_DISABLE_PWRSAVE=yes +[ -n "$NET_DISABLE_PWRSAVE" ] || NET_DISABLE_PWRSAVE=yes # Type of power save rclocal/service/udev # rclocal - backwards compatibility, runs via rc.local @@ -10,4 +10,4 @@ # on reboots # udev - creates a udev rules that should affect all wifi devices. -[ -n "$NETWORK_PWRSAVE_TYPE" ] || NETWORK_PWRSAVE_TYPE=udev +[ -n "$NET_PWRSAVE_TYPE" ] || NET_PWRSAVE_TYPE=udev diff --git a/src/modules/net/start_chroot_script b/src/modules/net/start_chroot_script index c9982e04b..762816c31 100755 --- a/src/modules/net/start_chroot_script +++ b/src/modules/net/start_chroot_script @@ -9,8 +9,7 @@ # Last modification: August/2022 # ######## -set -x -set -e +set -Ee export LC_ALL=C @@ -56,13 +55,13 @@ echo '/sbin/iptables -t mangle -I POSTROUTING 1 -o wlan0 -p udp --dport 123 -j T echo 'exit 0' >> /etc/rc.local # Install powersave option -if [ "$NETWORK_DISABLE_PWRSAVE" == "yes" ]; then +if [ "$NET_DISABLE_PWRSAVE" == "yes" ]; then # Copy pwrsave script unpack filesystem/usr/local/bin /usr/local/bin root # Use rc.local - if [ "$NETWORK_PWRSAVE_TYPE" == "rclocal" ]; then + if [ "$NET_PWRSAVE_TYPE" == "rclocal" ]; then echo_green "Modifying /etc/rc.local ..." sed -i 's@exit 0@@' /etc/rc.local (echo "# Disable WiFi Power Management"; \ @@ -70,18 +69,18 @@ if [ "$NETWORK_DISABLE_PWRSAVE" == "yes" ]; then echo "/usr/local/bin/pwrsave off"; echo "exit 0") >> /etc/rc.local fi # Use service - if [ "$NETWORK_PWRSAVE_TYPE" == "service" ]; then + if [ "$NET_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 [ "$NETWORK_PWRSAVE_TYPE" == "udev" ]; then + if [ "$NET_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 [ "$NETWORK_PWRSAVE_TYPE" != "udev" ]; then + if [ "$NET_PWRSAVE_TYPE" != "udev" ]; then rm -f /usr/local/bin/pwrsave-udev else rm -f /usr/local/bin/pwrsave From bdfca558a96415063e19e293803b2ca5649b47fe Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 31 Dec 2022 14:12:05 +0000 Subject: [PATCH 02/39] chore: push version number to v1.0.1 --- src/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version b/src/version index 3eefcb9dd..7dea76edb 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.0.0 +1.0.1 From b6c08c7f8f3c6a69d20aeea188c4e52ed66e6c8f Mon Sep 17 00:00:00 2001 From: meteyou Date: Sat, 31 Dec 2022 14:57:28 +0000 Subject: [PATCH 03/39] docs(changelog): update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb2d8dedf..26b7ea0b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ All notable changes to Mainsail will be documented in this file. - Add otg_mode=1 for CM4 in config.txt (#167) | [cb0bf60](cb0bf600e8526a79ae534a64e9fccd584eb20388) - Fix SC2086 in armbian module (#173) | [2f4f8b1](2f4f8b13737b3f95582b9c8b824136413e9884eb) - Fixes error setting link to macro (#175) | [d1ad3f8](d1ad3f8006ad7c9b84a9a34acc4798f15ab605e4) +- Fix shellcheck errors (#185) | [efe1b68](efe1b68d0a8cd5ccf3238d280c83ae523c331688) +- Fix syntax error in net module (#191) | [cb890af](cb890afafaa1ab6dc68fbfdc103ceca61432e064) ### Refactor From 9cebd0c8545fa41a826112658dfe401b4306a2bd Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sat, 28 Jan 2023 12:59:21 +0100 Subject: [PATCH 04/39] feat: enable I2C by default (#196) * feat: enable I2C by default Signed-off-by: Stephan Wendel Signed-off-by: Stephan Wendel --- src/modules/piconfig/filesystem/tmp/msos_config.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/piconfig/filesystem/tmp/msos_config.txt b/src/modules/piconfig/filesystem/tmp/msos_config.txt index dfc17571e..e784214cc 100644 --- a/src/modules/piconfig/filesystem/tmp/msos_config.txt +++ b/src/modules/piconfig/filesystem/tmp/msos_config.txt @@ -44,6 +44,13 @@ dtparam=spi=on enable_uart=1 dtoverlay=disable-bt +## Enable I2C by default. +## This is used by Klipper's Host MCU +## See https://www.klipper3d.org/RPi_microcontroller.html#optional-enabling-i2c +## for destails. +## For MPU Accelrometer please use +## dtparam=i2c_arm=on,i2c_arm_baudrate=400000 +dtparam=i2c_arm=on ## Disable libcamera (interferes with ustreamer, when using raspicams) camera_auto_detect=0 From 2f556c3232b3d01ac48d30e08ae230cd5fda13fe Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 19 Feb 2023 10:51:59 +0100 Subject: [PATCH 05/39] feat: add Orange Pi 3 and 4 LTS (#186) * feat: add Orange Pi 3 and 4 LTS This builds an basic Image for Orange Pi 3 LTS and 4 LTS Includes: - mainsail - klipper - moonraker - timelapse - crowsnest - sonar - Input Shaper PreInstall - Hardware preconfiguration - Network-configurator Network-configurator mimics behavior of wpa_supplicant.conf in /boot on Raspberry Images. Every restart, if file exist, network configuration will be applied. Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel --- config/armbian/default | 49 ++++++++++++--- config/armbian/orangepi3lts | 14 +++++ config/armbian/orangepi4lts | 14 +++++ src/modules/armbian_net/config | 16 +++++ .../root/boot/network_config.txt.template | 49 +++++++++++++++ .../system/network-configurator.service | 20 ++++++ src/modules/armbian_net/start_chroot_script | 55 +++++++++++++++++ src/modules/is_req_preinstall/config | 2 +- src/modules/klipper/config | 2 +- src/modules/opiconfig/config | 16 +++++ src/modules/opiconfig/start_chroot_script | 61 +++++++++++++++++++ 11 files changed, 286 insertions(+), 12 deletions(-) create mode 100644 config/armbian/orangepi3lts create mode 100644 config/armbian/orangepi4lts create mode 100644 src/modules/armbian_net/config create mode 100644 src/modules/armbian_net/filesystem/root/boot/network_config.txt.template create mode 100644 src/modules/armbian_net/filesystem/root/etc/systemd/system/network-configurator.service create mode 100644 src/modules/armbian_net/start_chroot_script create mode 100644 src/modules/opiconfig/config create mode 100644 src/modules/opiconfig/start_chroot_script diff --git a/config/armbian/default b/config/armbian/default index 4748088c7..80ea95e19 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -1,10 +1,39 @@ -export BASE_APT_CACHE=no -export OCTOPI_INCLUDE_WIRINGPI=no -export BASE_DISTRO=armbian -export BASE_ROOT_PARTITION=2 -export BASE_IMAGE_RESIZEROOT=500 -export BASE_IMAGE_RASPBIAN=no -export BASE_IMAGE_ENLARGEROOT=1000 -export BASE_ARCH=arm64 - -export MODULES="base,pkgupgrade" +#!/usr/bin/env bash +# Shebang for better file detection + +# Declare Variables before exporting. +# See https://www.shellcheck.net/wiki/SC2155 + +# Download Base Url +DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" + +# Base User +BASE_ADD_USER="yes" +BASE_USER="pi" +BASE_USER_PASSWORD="armbian" + +# Needed while building for non rpi sbc +BASE_DISTRO="armbian" +BASE_IMAGE_RASPBIAN="no" + +# partition resizing +BASE_ROOT_PARTITION="2" +BASE_IMAGE_ENLARGEROOT=2500 +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,armbian(armbian_net,opiconfig,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" + +# export Variables +export DOWNLOAD_BASE_URL +export BASE_ADD_USER +export BASE_USER +export BASE_USER_PASSWORD +export BASE_DISTRO +export BASE_IMAGE_RASPBIAN +export BASE_ROOT_PARTITION +export BASE_IMAGE_ENLARGEROOT +export BASE_IMAGE_RESIZEROOT +export BASE_RELEASE_COMPRESS +export MODULES diff --git a/config/armbian/orangepi3lts b/config/armbian/orangepi3lts new file mode 100644 index 000000000..46ea21610 --- /dev/null +++ b/config/armbian/orangepi3lts @@ -0,0 +1,14 @@ +#!/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-orangepi3_lts.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts.img.xz" + +# export Variables +export BASE_ARCH +export DOWNLOAD_URL_CHECKSUM +export DOWNLOAD_URL_IMAGE diff --git a/config/armbian/orangepi4lts b/config/armbian/orangepi4lts new file mode 100644 index 000000000..f68c354df --- /dev/null +++ b/config/armbian/orangepi4lts @@ -0,0 +1,14 @@ +#!/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.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts.img.xz" + +# export Variables +export BASE_ARCH +export DOWNLOAD_URL_CHECKSUM +export DOWNLOAD_URL_IMAGE diff --git a/src/modules/armbian_net/config b/src/modules/armbian_net/config new file mode 100644 index 000000000..6a0ab8317 --- /dev/null +++ b/src/modules/armbian_net/config @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +#Shebang for better file detection +#### mainsail module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +# shellcheck disable=all + +[ -n "$ARMBIAN_NET_FIRSTRUN_FILE" ] || ARMBIAN_NET_FIRSTRUN_FILE="/boot/armbian_first_run.txt.template" +[ -n "$ARMBIAN_NET_FIRSTRUN_SCRIPT" ] || ARMBIAN_NET_FIRSTRUN_SCRIPT="/usr/lib/armbian/armbian-firstrun-config" +[ -n "$ARMBIAN_NET_NC_PATH" ] || ARMBIAN_NET_NC_PATH="/usr/local/bin/network-configurator" diff --git a/src/modules/armbian_net/filesystem/root/boot/network_config.txt.template b/src/modules/armbian_net/filesystem/root/boot/network_config.txt.template new file mode 100644 index 000000000..1ee72d296 --- /dev/null +++ b/src/modules/armbian_net/filesystem/root/boot/network_config.txt.template @@ -0,0 +1,49 @@ +#----------------------------------------------------------------- +# +# MainsailOS (armbian edition) Network Configuration +# Set optional end user configuration +# - Rename this file from /boot/network_config.txt.template to /boot/network_config.txt +# - Settings below will be applied every time you reboot your machine. +# Be aware, old configurations will be deleted! +# +# This file is based on work of the armbian developer team +# https://github.com/armbian/build/blob/master/packages/bsp/armbian_first_run.txt.template +#----------------------------------------------------------------- + +#----------------------------------------------------------------- +# General: +# 1 = delete this file, after first run setup is completed. + +NC_general_delete_this_file_after_completion=1 + +#----------------------------------------------------------------- +#Networking: +# Change default network settings +# Set to 1 to apply any network related settings below + +NC_net_change_defaults=0 + +# Enable WiFi or Ethernet. +# NB: If both are enabled, WiFi will take priority and Ethernet will be disabled. + +NC_net_ethernet_enabled=1 +NC_net_wifi_enabled=0 + +#Enter your WiFi creds +# SECURITY WARN: Your wifi keys will be stored in plaintext, no encryption. + +NC_net_wifi_ssid='MySSID' +NC_net_wifi_key='MyWiFiKEY' + +# Country code to enable power ratings and channels for your country. eg: GB US DE | https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + +NC_net_wifi_countrycode='GB' + +# If you want to use a static ip, set it here + +NC_net_use_static=0 +NC_net_static_ip='192.168.0.100' +NC_net_static_mask='255.255.255.0' +NC_net_static_gateway='192.168.0.1' +NC_net_static_dns='8.8.8.8 8.8.4.4' # Two entries max, seperated by a space. +#----------------------------------------------------------------- diff --git a/src/modules/armbian_net/filesystem/root/etc/systemd/system/network-configurator.service b/src/modules/armbian_net/filesystem/root/etc/systemd/system/network-configurator.service new file mode 100644 index 000000000..6568ee6d4 --- /dev/null +++ b/src/modules/armbian_net/filesystem/root/etc/systemd/system/network-configurator.service @@ -0,0 +1,20 @@ +# MainsailOS network-configurator +# This service will run in parallel with other services +# This is based on +# https://github.com/armbian/build/blob/master/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service + + +[Unit] +Description=MainsailOS network configurator +Wants=network-online.target +After=network.target network-online.target +ConditionPathExists=/boot/network_config.txt + +[Service] +Type=idle +RemainAfterExit=yes +ExecStart=/usr/local/bin/network-configurator +TimeoutStartSec=2min + +[Install] +WantedBy=multi-user.target diff --git a/src/modules/armbian_net/start_chroot_script b/src/modules/armbian_net/start_chroot_script new file mode 100644 index 000000000..7797d17b7 --- /dev/null +++ b/src/modules/armbian_net/start_chroot_script @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# MainsailOS network configurator for armbian images +# written by Stephan Wendel aka KwadFan +# +# GPL V3 +######## + +# shellcheck enable=require-variable-braces + +# Description: +# This file installs a service based on armbians armbian_firstrun_config +# The original work is done by the armbian developer's team +# sources of files can be found here: https://github.com/armbian/build + +# Source error handling, leave this in place +set -Ee + +# Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + + +## Step 1: Install files +unpack filesystem/root / root + +## Step 2: remove original template +if [[ -f "${ARMBIAN_NET_FIRSTRUN_FILE}" ]]; then + sudo rm -rf "${ARMBIAN_NET_FIRSTRUN_FILE}" +fi + +## Step 3: Disable first run service +systemctl_if_exists disable armbian-firstrun-config.service + +## Step 4: Copy original script to /usr/local/bin/network-configurator +if [[ -f "${ARMBIAN_NET_FIRSTRUN_SCRIPT}" ]]; then + sudo cp -p "${ARMBIAN_NET_FIRSTRUN_SCRIPT}" "${ARMBIAN_NET_NC_PATH}" +fi + +## Step 5: patch /usr/local/bin/network-configurator +if [[ -f "${ARMBIAN_NET_NC_PATH}" ]]; then + ### Substep 1: replace any amrbian_first_run.txt with network_config.txt + sed -i 's|armbian_first_run.txt|network_config.txt|g' "${ARMBIAN_NET_NC_PATH}" + ### Substep 2: replace any FR* Variable name with NC* + sed -i 's|FR|NC|g' "${ARMBIAN_NET_NC_PATH}" + ### Supstep 3: Rename function + sed -i 's|do_firstrun_automated_user_configuration|do_network_configuration|g' "${ARMBIAN_NET_NC_PATH}" + ### Substep 4: Add a patch note + sed -i '8 i \\n\# This is a patched version of armbian-firstrun-config for MainsailOS' "${ARMBIAN_NET_NC_PATH}" + sed -i '10 i # Original located at /usr/lib/armbian/armbian-firstrun-config' "${ARMBIAN_NET_NC_PATH}" + sed -i '11 i # Changes made by https:\/\/github.com/mainsail-crew' "${ARMBIAN_NET_NC_PATH}" +fi + +## Step 6: Enable systemd service +systemctl_if_exists enable network-configurator.service diff --git a/src/modules/is_req_preinstall/config b/src/modules/is_req_preinstall/config index 1ea69c1bb..eca97bb2a 100644 --- a/src/modules/is_req_preinstall/config +++ b/src/modules/is_req_preinstall/config @@ -4,4 +4,4 @@ [ -n "$IS_REQ_PREINSTALL_DEPS" ] || IS_REQ_PREINSTALL_DEPS="python3-numpy python3-matplotlib \ libatlas3-base libatlas-base-dev libgfortran5" [ -n "$IS_REQ_PREINSTALL_PIP" ] || IS_REQ_PREINSTALL_PIP="numpy<=1.23.4" -[ -n "$IS_REQ_PREINSTALL_CFG_FILE" ] || IS_REQ_PREINSTALL_CFG_FILE="/boot/config.txt" + diff --git a/src/modules/klipper/config b/src/modules/klipper/config index 8bf45fb9f..ac6a5acb4 100644 --- a/src/modules/klipper/config +++ b/src/modules/klipper/config @@ -21,7 +21,7 @@ [ -n "$KLIPPER_DEPS" ] || KLIPPER_DEPS="git virtualenv python3-dev \ python3-matplotlib libffi-dev build-essential libncurses-dev libusb-dev \ avrdude gcc-avr binutils-avr avr-libc stm32flash dfu-util libnewlib-arm-none-eabi \ -gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0-0 libusb-1.0-0-dev" +gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0-0 libusb-1.0-0-dev pkg-config" [ -n "$KLIPPER_USER_GROUPS" ] || KLIPPER_USER_GROUPS="tty,dialout" diff --git a/src/modules/opiconfig/config b/src/modules/opiconfig/config new file mode 100644 index 000000000..9c564b3ed --- /dev/null +++ b/src/modules/opiconfig/config @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +#### opiconfig - OrangePi Configuration Module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2021 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +# Shebang for better file detection +# shellcheck disable=all + +[ -n "$OPICONFIG_CONFIG_TXT_FILE" ] || OPICONFIG_CONFIG_TXT_FILE="/boot/armbianEnv.txt" +[ -n "$OPICONFIG_CONFIG_BAK_FILE" ] || OPICONFIG_CONFIG_BAK_FILE="/boot/armbianEnv.txt.backup" +[ -n "$OPICONFIG_MODULES_FILE" ] || OPICONFIG_MODULES_FILE="/etc/modules" diff --git a/src/modules/opiconfig/start_chroot_script b/src/modules/opiconfig/start_chroot_script new file mode 100644 index 000000000..ae8bd0c56 --- /dev/null +++ b/src/modules/opiconfig/start_chroot_script @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +#### opiconfig - OrangePi Configuration Module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2021 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +#### NOTE: This module has to be used after armbian module!!! + +# shellcheck enable=require-variable-braces + +## Source error handling, leave this in place +set -Ee + +# Set DEBIAN_FRONTEND to noninteractive +if [[ "${DEBIAN_FRONTEND}" != "noninteractive" ]]; then + export DEBIAN_FRONTEND=noninteractive +fi + +## Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + +### Helper func +is_board_type() { + local board releasefile + board="" + releasefile="/etc/armbian-release-info.txt" + if [[ -f "${releasefile}" ]]; then + board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" + fi + echo "${board}" +} + + +echo_green "Enable SPI interface on Orange Pi SBC's ..." + +# Step 1: Copy default config to backup file +cp "${OPICONFIG_CONFIG_TXT_FILE}" "${OPICONFIG_CONFIG_BAK_FILE}" + +# Step 2: Enable SPI in armbianEnv.txt depending on device + +## OrangePi 3 LTS +if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then + echo "overlays=spi-spidev1" >> "${OPICONFIG_CONFIG_TXT_FILE}" +fi + +## OrangePi 4 LTS +if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then + echo "overlays=spi-spidev" >> "${OPICONFIG_CONFIG_TXT_FILE}" + echo "param_spidev_spi_bus=1" >> "${OPICONFIG_CONFIG_TXT_FILE}" +fi + +# Step 3: add spi-dev module to /etc/modules +echo "spi-dev" >> "${OPICONFIG_MODULES_FILE}" + +echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" From b7acb1e49c02d2d9f50dfdc3541c10f4f2b2becc Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Mar 2023 19:33:01 +0100 Subject: [PATCH 06/39] refactor: use mv to move the image from the workspace to the root (#203) --- .github/workflows/BuildImages.yml | 2 +- .github/workflows/Release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index c2fe4853a..2739d3eb6 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -63,7 +63,7 @@ jobs: NOW="$(date +"%Y-%m-%d")" IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}" - cp repository/src/workspace/*.img $IMAGE.img + mv repository/src/workspace/*.img $IMAGE.img echo "image=${IMAGE}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 948c4ad14..02ed76adb 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -141,7 +141,7 @@ jobs: source repository/src/config base_name="${{ needs.release.outputs.date }}-${DIST_NAME}-${DIST_VERSION}" image="${base_name}-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}" - cp repository/src/workspace/*.img $image.img + mv repository/src/workspace/*.img $image.img echo "base_name=${base_name}" >> $GITHUB_OUTPUT echo "image=${image}" >> $GITHUB_OUTPUT From dc8c588df649fd3dff86602d13d3ae3fbea31b66 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 12 Mar 2023 12:36:44 +0100 Subject: [PATCH 07/39] fix(build): fix mv of image file (#204) --- .github/workflows/BuildImages.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index 2739d3eb6..e9ee23cc4 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -54,8 +54,8 @@ jobs: with: config: ${{ matrix.config }} - - name: Copy output - id: copy-image + - name: Rename image file + id: move-image if: always() shell: bash run: | @@ -63,7 +63,7 @@ jobs: NOW="$(date +"%Y-%m-%d")" IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}" - mv repository/src/workspace/*.img $IMAGE.img + sudo mv repository/src/workspace/*.img $IMAGE.img echo "image=${IMAGE}" >> $GITHUB_OUTPUT @@ -71,7 +71,7 @@ jobs: if: failure() uses: actions/upload-artifact@v3 with: - name: failed-${{ steps.copy-image.outputs.image }}.log + name: failed-${{ steps.move-image.outputs.image }}.log path: repository/src/build.log - name: Compressing Image @@ -79,28 +79,28 @@ jobs: run: | CPU_COUNT="$(nproc)" echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m" - xz -efkvz9T"${CPU_COUNT}" ${{ steps.copy-image.outputs.image }}.img + xz -efkvz9T"${CPU_COUNT}" ${{ steps.move-image.outputs.image }}.img - name: Calculating checksums shell: bash run: | - sha256sum ${{ steps.copy-image.outputs.image }}.img > ${{ steps.copy-image.outputs.image }}.img.sha256 - sha256sum ${{ steps.copy-image.outputs.image }}.img.xz > ${{ steps.copy-image.outputs.image }}.img.xz.sha256 + sha256sum ${{ steps.move-image.outputs.image }}.img > ${{ steps.move-image.outputs.image }}.img.sha256 + sha256sum ${{ steps.move-image.outputs.image }}.img.xz > ${{ steps.move-image.outputs.image }}.img.xz.sha256 - name: Upload Compressed Image uses: actions/upload-artifact@v3 with: - name: ${{ steps.copy-image.outputs.image }}.img.xz - path: ${{ steps.copy-image.outputs.image }}.img.xz + name: ${{ steps.move-image.outputs.image }}.img.xz + path: ${{ steps.move-image.outputs.image }}.img.xz - name: Upload Compressed Image Checksum uses: actions/upload-artifact@v3 with: - name: ${{ steps.copy-image.outputs.image }}.img.xz.sha256 - path: ${{ steps.copy-image.outputs.image }}.img.xz.sha256 + name: ${{ steps.move-image.outputs.image }}.img.xz.sha256 + path: ${{ steps.move-image.outputs.image }}.img.xz.sha256 - name: Upload Image Checksum uses: actions/upload-artifact@v3 with: - name: ${{ steps.copy-image.outputs.image }}.img.sha256 - path: ${{ steps.copy-image.outputs.image }}.img.sha256 + name: ${{ steps.move-image.outputs.image }}.img.sha256 + path: ${{ steps.move-image.outputs.image }}.img.sha256 From fec24320ea4bdcf51c9430e89443035b4ade70f1 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 12 Mar 2023 16:08:33 +0100 Subject: [PATCH 08/39] fix: fix compress step (#205) --- .github/workflows/BuildImages.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index e9ee23cc4..9d8d8019a 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -63,7 +63,11 @@ jobs: NOW="$(date +"%Y-%m-%d")" IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}" - sudo mv repository/src/workspace/*.img $IMAGE.img + WORKSPACE=$(echo ${{ github.workspace }}) + sudo chown -R $USER:$USER $WORKSPACE/repository/src/workspace || true + sudo chmod 0775 -R $WORKSPACE/repository/src/workspace || true + + mv repository/src/workspace/*.img $IMAGE.img echo "image=${IMAGE}" >> $GITHUB_OUTPUT @@ -79,7 +83,7 @@ jobs: run: | CPU_COUNT="$(nproc)" echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m" - xz -efkvz9T"${CPU_COUNT}" ${{ steps.move-image.outputs.image }}.img + xz -efkvz9T"${CPU_COUNT}" ${{ steps.move-image.outputs.image }}.img || true - name: Calculating checksums shell: bash From a03626a54a21b1fa1175b458665ae14e9b755037 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 12 Mar 2023 19:37:28 +0100 Subject: [PATCH 09/39] fix: fix rpi-image.json workflow in Release.yml (#206) --- .github/workflows/Release.yml | 140 +++++++++++++++++----------------- 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 02ed76adb..d32590abf 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -120,7 +120,7 @@ jobs: needs: [ release, matrix ] runs-on: ubuntu-latest outputs: - base_name: ${{ steps.copy-image.outputs.base_name }} + base_name: ${{ steps.move-image.outputs.base_name }} strategy: fail-fast: false matrix: @@ -133,11 +133,21 @@ jobs: config: ${{ matrix.config }} build-ref: master - - name: Copy output - id: copy-image - if: always() + - name: Upload failed Logfile + if: failure() + uses: actions/upload-artifact@v3 + with: + name: failed-${{ steps.move-image.outputs.image }}.log + path: repository/src/build.log + + - name: Rename image file + id: move-image shell: bash run: | + WORKSPACE=$(echo ${{ github.workspace }}) + sudo chown -R $USER:$USER $WORKSPACE/repository/src/workspace || true + sudo chmod 0775 -R $WORKSPACE/repository/src/workspace || true + source repository/src/config base_name="${{ needs.release.outputs.date }}-${DIST_NAME}-${DIST_VERSION}" image="${base_name}-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}" @@ -146,22 +156,12 @@ jobs: echo "base_name=${base_name}" >> $GITHUB_OUTPUT echo "image=${image}" >> $GITHUB_OUTPUT - - name: Upload failed Logfile - if: failure() - uses: actions/upload-artifact@v3 - with: - name: failed-${{ steps.copy-image.outputs.image }}.log - path: repository/src/build.log - - - name: Debug output - run: echo ${{ steps.copy-image.outputs.image }} - - name: Compressing Image shell: bash run: | CPU_COUNT="$(nproc)" echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m" - xz -efkvz9T"${CPU_COUNT}" ${{ steps.copy-image.outputs.image }}.img + xz -efkvz9T"${CPU_COUNT}" ${{ steps.move-image.outputs.image }}.img || true - name: Upload Compressing Image if: success() @@ -170,18 +170,18 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: release_id: ${{ needs.release.outputs.id }} - file: ${{ steps.copy-image.outputs.image }}.img.xz + file: ${{ steps.move-image.outputs.image }}.img.xz - name: Calculating checksums id: checksums shell: bash run: | - sha256sum ${{ steps.copy-image.outputs.image }}.img > ${{ steps.copy-image.outputs.image }}.img.sha256 - image_checksum=`cat ${{ steps.copy-image.outputs.image }}.img.sha256 | awk '{ print $1 }'` + sha256sum ${{ steps.move-image.outputs.image }}.img > ${{ steps.move-image.outputs.image }}.img.sha256 + image_checksum=`cat ${{ steps.move-image.outputs.image }}.img.sha256 | awk '{ print $1 }'` echo "image=${image_checksum}" >> $GITHUB_OUTPUT - sha256sum ${{ steps.copy-image.outputs.image }}.img.xz > ${{ steps.copy-image.outputs.image }}.img.xz.sha256 - zip_checksum=`cat ${{ steps.copy-image.outputs.image }}.img.xz.sha256 | awk '{ print $1 }'` + sha256sum ${{ steps.move-image.outputs.image }}.img.xz > ${{ steps.move-image.outputs.image }}.img.xz.sha256 + zip_checksum=`cat ${{ steps.move-image.outputs.image }}.img.xz.sha256 | awk '{ print $1 }'` echo "zip=${zip_checksum}" >> $GITHUB_OUTPUT - name: Upload Checksums @@ -191,51 +191,56 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: release_id: ${{ needs.release.outputs.id }} - file: ${{ steps.copy-image.outputs.image }}.img.sha256;${{ steps.copy-image.outputs.image }}.img.xz.sha256 + file: ${{ steps.move-image.outputs.image }}.img.sha256;${{ steps.move-image.outputs.image }}.img.xz.sha256 - name: Calculating filesizes id: filesizes shell: bash run: | - image_filesize=`wc -c ${{ steps.copy-image.outputs.image }}.img | awk '{print $1}'` + image_filesize=`wc -c ${{ steps.move-image.outputs.image }}.img | awk '{print $1}'` echo "image=${image_filesize}" >> $GITHUB_OUTPUT - zip_filesize=`wc -c ${{ steps.copy-image.outputs.image }}.img.xz | awk '{print $1}'` + zip_filesize=`wc -c ${{ steps.move-image.outputs.image }}.img.xz | awk '{print $1}'` echo "zip=${zip_filesize}" >> $GITHUB_OUTPUT - name: Debug output run: | - echo ${{ needs.release.outputs.id }} - echo ${{ needs.release.outputs.version }} + echo "release-id: ${{ needs.release.outputs.id }}" + echo "release-version: ${{ needs.release.outputs.version }}" - echo ${{ steps.copy-image.outputs.image }} + echo "image-name: ${{ steps.move-image.outputs.image }}" - echo ${{ steps.checksums.outputs.image }} - echo ${{ steps.checksums.outputs.zip }} + echo "checksum image: ${{ steps.checksums.outputs.image }}" + echo "checksum zip: ${{ steps.checksums.outputs.zip }}" - echo ${{ steps.filesizes.outputs.image }} - echo ${{ steps.filesizes.outputs.zip }} + echo "filesize-image: ${{ steps.filesizes.outputs.image }}" + echo "filesize-zip: ${{ steps.filesizes.outputs.zip }}" - name: Generate JSON id: json uses: actions/github-script@v6 env: - name: '"Mainsail OS ${{ github.event.inputs.version }}"' - description: '"Type: ${{ steps.build.outputs.type }}, SBC: ${{ steps.build.outputs.sbc }}"' - url: '"https://github.com/mainsail-crew/MainsailOS/releases/download/${{ github.event.inputs.version }}/${{ steps.copy-image.outputs.image }}.img.xz"' - icon: '"https://os.mainsail.xyz/rpi-imager.png"' - init_format: '"systemd"' - release_date: '"${{ needs.release.outputs.date }}"' + name: "Mainsail OS ${{ github.event.inputs.version }}" + description: "Type: ${{ steps.build.outputs.type }}, SBC: ${{ steps.build.outputs.sbc }}" + type: "${{ steps.build.outputs.type }}" + sbc: "${{ steps.build.outputs.sbc }}" + url: "https://github.com/mainsail-crew/MainsailOS/releases/download/${{ github.event.inputs.version }}/${{ steps.move-image.outputs.image }}.img.xz" + icon: "https://os.mainsail.xyz/rpi-imager.png" + init_format: "systemd" + release_date: "${{ needs.release.outputs.date }}" extract_size: ${{ steps.filesizes.outputs.image }} - extract_sha256: '"${{ steps.checksums.outputs.image }}"' + extract_sha256: "${{ steps.checksums.outputs.image }}" image_download_size: ${{ steps.filesizes.outputs.zip }} - image_download_sha256: '"${{ steps.checksums.outputs.zip }}"' + image_download_sha256: "${{ steps.checksums.outputs.zip }}" with: result-encoding: string script: | - const { name, description, url, icon, init_format, release_date, extract_size, extract_sha256, image_download_size, image_download_sha256 } = process.env + const fs = require('fs') + let { name, description, type, sbc, url, icon, init_format, release_date, extract_size, extract_sha256, image_download_size, image_download_sha256 } = process.env + if (sbc === 'rpi32') name += ' 32-Bit (recommend)' + else if (sbc === 'rpi64') name += ' 64-Bit' - return JSON.stringify({ + const json = JSON.stringify({ name, description, url, @@ -248,8 +253,12 @@ jobs: image_download_sha256 }) - - name: Write JSON - run: echo "${{steps.json.outputs.result}}" > "./${{ steps.copy-image.outputs.image }}.json" + fs.writeFileSync("./${{ steps.move-image.outputs.image }}.json", json) + + - name: Debug output + shell: bash + run: | + cat "./${{ steps.move-image.outputs.image }}.json" - name: Upload JSON if: success() @@ -258,7 +267,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: release_id: ${{ needs.release.outputs.id }} - file: ${{ steps.copy-image.outputs.image }}.json + file: ${{ steps.move-image.outputs.image }}.json finish: name: Finish Release @@ -284,34 +293,27 @@ jobs: fileName: "${{ needs.build.outputs.base_name }}-raspberry-*.json" out-file-path: "downloads" - - name: Debug - run: | - ls ./downloads/* - touch rpi-imager.json - - - name: setup python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Run script - uses: jannekem/run-python-script-action@v1 + - name: Combine JSON + id: json + uses: actions/github-script@v6 with: + result-encoding: string script: | - import os, json, shutil - with open("rpi-imager.json", "r+") as t: - t.truncate(0) - t.write('{ "os_list": [') - for filename in os.scandir('downloads'): - print(filename) - with open(filename, "r") as f: - content = f.read() - t.write(content) - t.write(',') - t.write('] }') - barak = open("rpi-imager.json", "r+") - contentb = barak.read() - print(contentb) + const downloadFolder = './downloads/' + const fs = require('fs') + const os_list = [] + + fs.readdirSync(downloadFolder).forEach(file => { + const raw = fs.readFileSync('./downloads/' + file, {encoding:'utf8', flag:'r'}) + try { + os_list.push(JSON.parse(raw)) + } catch (err) { + console.log("Error parsing JSON string:", err) + } + }) + + const json = JSON.stringify({os_list}) + fs.writeFileSync('rpi-imager.json', json) - name: Upload JSON if: success() From df2aa3528142f144b1c9928f90458c3a6d6c78c7 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Wed, 15 Mar 2023 18:07:00 +0100 Subject: [PATCH 10/39] feat: add orange pi zero2 (#189) * feat: add orange pi zero2 Also includes: * fixes error in armbian based build if kernel recieves update * Split Orangepi OS based ans Armbian based configurations * Adds GPIO udev rule to Armbian based images * Uses a modified version of armbain-firstrun-config script to setup network, colled network_config * patched version of armbian's dynamic motd * enabled SPI for all models Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel Co-authored-by: Stefan Dej --- config/armbian/default | 2 +- config/orangepi/default | 39 ++++ config/orangepi/orangepi_zero2 | 14 ++ src/modules/armbian/config | 17 +- src/modules/armbian/end_chroot_script | 50 +++-- .../root/etc/udev/rules.d/97-gpio.rules | 1 + .../root/etc/update-motd.d/10-mainsailos | 21 -- src/modules/armbian/start_chroot_script | 119 ++++++++--- src/modules/armbian_net/config | 10 +- src/modules/armbian_net/start_chroot_script | 19 +- .../armbian_pkgupgrade/start_chroot_script | 78 +++++++ src/modules/opiconfig/config | 16 -- src/modules/opiconfig/start_chroot_script | 61 ------ src/modules/orangepi/config | 29 +++ src/modules/orangepi/end_chroot_script | 44 ++++ .../root/etc/udev/rules.d/97-gpio.rules | 1 + .../root/etc/update-motd.d/10-mainsailos | 66 ++++++ src/modules/orangepi/start_chroot_script | 194 ++++++++++++++++++ src/modules/orangepi_net/config | 16 ++ .../root/boot/network_config.txt.template | 49 +++++ .../system/network-configurator.service | 20 ++ src/modules/orangepi_net/start_chroot_script | 64 ++++++ src/version | 2 +- 23 files changed, 781 insertions(+), 151 deletions(-) create mode 100644 config/orangepi/default create mode 100644 config/orangepi/orangepi_zero2 create mode 100644 src/modules/armbian/filesystem/root/etc/udev/rules.d/97-gpio.rules create mode 100644 src/modules/armbian_pkgupgrade/start_chroot_script delete mode 100644 src/modules/opiconfig/config delete mode 100644 src/modules/opiconfig/start_chroot_script create mode 100644 src/modules/orangepi/config create mode 100644 src/modules/orangepi/end_chroot_script create mode 100644 src/modules/orangepi/filesystem/root/etc/udev/rules.d/97-gpio.rules create mode 100755 src/modules/orangepi/filesystem/root/etc/update-motd.d/10-mainsailos create mode 100644 src/modules/orangepi/start_chroot_script create mode 100644 src/modules/orangepi_net/config create mode 100644 src/modules/orangepi_net/filesystem/root/boot/network_config.txt.template create mode 100644 src/modules/orangepi_net/filesystem/root/etc/systemd/system/network-configurator.service create mode 100644 src/modules/orangepi_net/start_chroot_script diff --git a/config/armbian/default b/config/armbian/default index 80ea95e19..f8efce374 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,armbian(armbian_net,opiconfig,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,armbian_pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL diff --git a/config/orangepi/default b/config/orangepi/default new file mode 100644 index 000000000..96a23ebbb --- /dev/null +++ b/config/orangepi/default @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Shebang for better file detection + +# Declare Variables before exporting. +# See https://www.shellcheck.net/wiki/SC2155 + +# Download Base Url +DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" + +# Base User +BASE_ADD_USER="yes" +BASE_USER="pi" +BASE_USER_PASSWORD="armbian" + +# Needed while building for non rpi sbc +BASE_DISTRO="armbian" +BASE_IMAGE_RASPBIAN="no" + +# partition resizing +BASE_ROOT_PARTITION="2" +BASE_IMAGE_ENLARGEROOT=2500 +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,orangepi(orangepi_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" + +# export Variables +export DOWNLOAD_BASE_URL +export BASE_ADD_USER +export BASE_USER +export BASE_USER_PASSWORD +export BASE_DISTRO +export BASE_IMAGE_RASPBIAN +export BASE_ROOT_PARTITION +export BASE_IMAGE_ENLARGEROOT +export BASE_IMAGE_RESIZEROOT +export BASE_RELEASE_COMPRESS +export MODULES diff --git a/config/orangepi/orangepi_zero2 b/config/orangepi/orangepi_zero2 new file mode 100644 index 000000000..1ad1c1d18 --- /dev/null +++ b/config/orangepi/orangepi_zero2 @@ -0,0 +1,14 @@ +#!/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}/orangepi-orangepi_zero2.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2.img.xz" + +# export Variables +export BASE_ARCH +export DOWNLOAD_URL_CHECKSUM +export DOWNLOAD_URL_IMAGE diff --git a/src/modules/armbian/config b/src/modules/armbian/config index c74f954ca..c36fa8a01 100644 --- a/src/modules/armbian/config +++ b/src/modules/armbian/config @@ -1,5 +1,18 @@ -#!/bin/bash +#!/usr/bin/env bash +# Shebang for better file detection +#### MainsailOS Specific Tweaks for armbian images +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + # shellcheck disable=all -[ -n "$ARMBIAN_DEPS" ] || ARMBIAN_DEPS="armbian-config avahi-daemon iptables \ +[[ -n "$ARMBIAN_DEPS" ]] || ARMBIAN_DEPS="armbian-config avahi-daemon iptables \ bash-completion" +[[ -n "$ARMBIAN_CONFIG_TXT_FILE" ]] || ARMBIAN_CONFIG_TXT_FILE="/boot/armbianEnv.txt" +[[ -n "$ARMBIAN_CONFIG_BAK_FILE" ]] || ARMBIAN_CONFIG_BAK_FILE="/boot/armbianEnv.txt.backup" +[[ -n "$ARMBIAN_MODULES_FILE" ]] || ARMBIAN_MODULES_FILE="/etc/modules" diff --git a/src/modules/armbian/end_chroot_script b/src/modules/armbian/end_chroot_script index 04d93f693..21a50cc6f 100644 --- a/src/modules/armbian/end_chroot_script +++ b/src/modules/armbian/end_chroot_script @@ -1,31 +1,49 @@ #!/usr/bin/env bash -# MainsailOS Specific Tweaks for armbian images -# written by Stephan Wendel aka KwadFan -# -# GPL V3 -######## +#### MainsailOS Specific Tweaks for armbian images +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### -## functions +# shellcheck enable=require-variable-braces +# Source error handling, leave this in place +set -Ee + +# Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + +## Helper functions gen_root_pw() { tr -dc "[:alnum:]" < /dev/urandom | head -c 50 } -# Clean up -# Remove autologin and lock root account -if [ -f "/etc/systemd/system/getty@.service.d/override.conf" ]; then +## Clean up +## Step 1: Remove autologin and lock root account +if [[ -f "/etc/systemd/system/getty@.service.d/override.conf" ]]; then rm -f /etc/systemd/system/getty@.service.d/override.conf fi +## END -# Disable autologin on serial console -if [ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]; then +## Step 2: Disable autologin on serial console +if [[ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]]; then sed -i 's/--autologin root //' /etc/systemd/system/serial-getty@.service.d/override.conf fi +## END -# Generate random root passwd -yes "$(gen_root_pw)" | passwd root +## Step 3: Delete root passwd +### Deleting root passwd doesn't let you unlock the account +sudo passwd -d root +## END -# lock root account -sudo -u "${BASE_USER}" passwd -l root +## Step 4: Lock root account +sudo passwd -l root +## END -# Remove passwdless sudo +## Step 5: Remove passwdless sudo sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers +## END diff --git a/src/modules/armbian/filesystem/root/etc/udev/rules.d/97-gpio.rules b/src/modules/armbian/filesystem/root/etc/udev/rules.d/97-gpio.rules new file mode 100644 index 000000000..a1adb0b51 --- /dev/null +++ b/src/modules/armbian/filesystem/root/etc/udev/rules.d/97-gpio.rules @@ -0,0 +1 @@ +SUBSYSTEM=="gpio", KERNEL=="gpiochip[0-4]", GROUP="gpio", MODE="0660" diff --git a/src/modules/armbian/filesystem/root/etc/update-motd.d/10-mainsailos b/src/modules/armbian/filesystem/root/etc/update-motd.d/10-mainsailos index 5c976f3c0..127314f74 100755 --- a/src/modules/armbian/filesystem/root/etc/update-motd.d/10-mainsailos +++ b/src/modules/armbian/filesystem/root/etc/update-motd.d/10-mainsailos @@ -23,7 +23,6 @@ if [[ -f /etc/armbian-distribution-status ]]; then [[ -f /etc/lsb-release ]] && DISTRIBUTION_CODENAME=$(grep CODENAME /etc/lsb-release | cut -d"=" -f2) [[ -z "${DISTRIBUTION_CODENAME}" && -f /etc/os-release ]] && DISTRIBUTION_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d"=" -f2) [[ -z "${DISTRIBUTION_CODENAME}" && -x /usr/bin/lsb_release ]] && DISTRIBUTION_CODENAME=$(/usr/bin/lsb_release -c | cut -d":" -f2 | tr -d "\t") - DISTRIBUTION_STATUS=$(grep "${DISTRIBUTION_CODENAME}" /etc/armbian-distribution-status | cut -d"=" -f2) fi [[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd @@ -44,23 +43,3 @@ echo -e "Version $(cut -d ' ' -f3 /etc/mainsailos-release), based on \ \e[34mArmbian ${VERSION} ${DISTRIBUTION_CODENAME^}\e[0m $([[ ${BRANCH} == edge ]])" echo -e "Running on \e[34m$(echo "${BOARD_NAME}" | sed 's/Orange Pi/OPi/' | \ sed 's/NanoPi/NPi/' | sed 's/Banana Pi/BPi/')\e[0m with \e[34mLinux ${KERNELID}\e[0m\n" - -# displaying status warnings - -if [[ "${IMAGE_TYPE}" != "stable" ]]; then - [[ "${IMAGE_TYPE}" == "user-built" ]] && UNSUPPORTED_TEXT="built from trunk" - [[ "${IMAGE_TYPE}" == "nightly" ]] && UNSUPPORTED_TEXT="untested automated build" -else - [[ "${BOARD_TYPE}" == "csc" || "${BOARD_TYPE}" == "tvb" ]] && UNSUPPORTED_TEXT="community creations" - [[ "${BOARD_TYPE}" == "wip" ]] && UNSUPPORTED_TEXT="work in progress" - [[ "${BOARD_TYPE}" == "eos" ]] && UNSUPPORTED_TEXT="end of life" -fi - -if [[ -n ${DISTRIBUTION_STATUS} && ${DISTRIBUTION_STATUS} != supported ]]; then - [[ -n ${UNSUPPORTED_TEXT} ]] && UNSUPPORTED_TEXT+=" & " - UNSUPPORTED_TEXT+="unsupported (${DISTRIBUTION_CODENAME}) userspace!" -fi - -if [[ -n ${UNSUPPORTED_TEXT} ]]; then - echo -e "\e[0;91mNo end-user support: \x1B[0m${UNSUPPORTED_TEXT}\n" -fi diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 0a2aa965b..fa4744f51 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -1,26 +1,32 @@ #!/usr/bin/env bash -# MainsailOS Specific Tweaks for armbian images -# written by Stephan Wendel aka KwadFan -# -# GPL V3 -######## +#### MainsailOS Specific Tweaks for armbian images +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### +# shellcheck enable=require-variable-braces # Source error handling, leave this in place -set -xe +set -Ee # Source CustomPIOS common.sh # shellcheck disable=SC1091 source /common.sh install_cleanup_trap -# Install armbian specific packages -apt update -# shellcheck disable=SC2086 -check_install_pkgs ${ARMBIAN_DEPS} - -# passwordless sudo during install -# Will be removed in cleanup -echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers +### Helper func +is_board_type() { + local board releasefile + board="" + releasefile="/etc/armbian-release-info.txt" + if [[ -f "${releasefile}" ]]; then + board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" + fi + echo "${board}" +} # Base User groups # Shameless "stolen" from @@ -33,26 +39,93 @@ if_group_exists_run() { fi } -# set groups +# passwordless sudo during install +# Will be removed in cleanup +echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers + +## Step 1: Install armbian specific packages +apt update +# shellcheck disable=SC2086 +check_install_pkgs ${ARMBIAN_DEPS} + + + +## Step 1: Manage groups +### Substep 1: Create group for gpio usage +sudo groupadd gpio +### END Substep 1 + +### Substep 2: Set default groups if_group_exists_run i2c usermod -aG i2c "${BASE_USER}" -usermod -aG video,audio,plugdev,games,netdev,sudo "${BASE_USER}" +usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal,gpio "${BASE_USER}" +### END Substep 2 -# Patch sshd_config +## Step 2: patch sshd_config sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config sed -i 's/^X11Forwarding/#X11Forwarding/' /etc/ssh/sshd_config sed -i 's/^#MaxAuthTries 6/MaxAuthTries 3/' /etc/ssh/sshd_config +## END -# Try patching first login in build stage -if [ -f "/root/.not_logged_in_yet" ]; then +## Step 4: Try patching first login in build stage +if [[ -f "/root/.not_logged_in_yet" ]]; then rm -f /root/.not_logged_in_yet fi +## END -# Move armbian-release to display mainsailos-release -mv /etc/armbian-release /etc/armbian-release-info.txt +## Step 5: Move armbian-release to display mainsailos-release +### Substep 1: Move armbian-release + if [[ -f "/etc/armbian-release" ]]; then + echo_green "Armbian release file found! moving to: 'armbian-release-info.txt'" + mv /etc/armbian-release /etc/armbian-release-info.txt + else + echo_red "Armbian release file not found! [SKIPPED]" + fi +### END Substep 1 +### Substep 2: patch Armbian scripts to new file location + echo_green "Patching armbian scripts (release file path) ..." + pushd "/usr/lib/armbian" &> /dev/null || exit 1 + files=() + while IFS='' read -r line; do + files+=("${line}") + done < <(grep -R "/etc/armbian-release" -- * | cut -d":" -f1) + for f in "${files[@]}"; do + sed -i "s|/etc/armbian-release|/etc/armbian-release-info.txt|g" "${f}" + done + popd &> /dev/null || exit 1 +## END -# update motd +## Step 6: Patch dynamic motd +echo_green "Patch dynamic motd ..." unpack /filesystem/root / chmod +x /etc/update-motd.d/* -if [ -f "/etc/default/armbian-motd" ]; then +if [[ -f "/etc/default/armbian-motd" ]]; then sed -i 's/MOTD_DISABLE=""/MOTD_DISABLE="header"/' /etc/default/armbian-motd fi +## END + +## Step 7: Enable SPI interface by default +echo_green "Enable SPI interface on Orange Pi SBC's ..." + +### Substep 1: Copy default config to backup file +cp "${ARMBIAN_CONFIG_TXT_FILE}" "${ARMBIAN_CONFIG_BAK_FILE}" +### END Substep 1 + +### Substep 2: Enable SPI in armbianEnv.txt depending on device +#### OrangePi 3 LTS +if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then + echo "overlays=spi-spidev1" >> "${ARMBIAN_CONFIG_TXT_FILE}" +fi + +#### OrangePi 4 LTS +if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then + echo "overlays=spi-spidev" >> "${ARMBIAN_CONFIG_TXT_FILE}" + echo "param_spidev_spi_bus=1" >> "${ARMBIAN_CONFIG_TXT_FILE}" +fi +### END Substep 2: + +### Substep 3: add spi-dev module to /etc/modules +echo "spi-dev" >> "${ARMBIAN_MODULES_FILE}" +### END Substep 3 + +echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" +## END diff --git a/src/modules/armbian_net/config b/src/modules/armbian_net/config index 6a0ab8317..d9a9ffa1e 100644 --- a/src/modules/armbian_net/config +++ b/src/modules/armbian_net/config @@ -1,6 +1,6 @@ #!/usr/bin/env bash -#Shebang for better file detection -#### mainsail module +# Shebang for better file detection +#### MainsailOS network configurator for armbian images #### #### Written by Stephan Wendel aka KwadFan #### Copyright 2023 - till today @@ -11,6 +11,6 @@ # shellcheck disable=all -[ -n "$ARMBIAN_NET_FIRSTRUN_FILE" ] || ARMBIAN_NET_FIRSTRUN_FILE="/boot/armbian_first_run.txt.template" -[ -n "$ARMBIAN_NET_FIRSTRUN_SCRIPT" ] || ARMBIAN_NET_FIRSTRUN_SCRIPT="/usr/lib/armbian/armbian-firstrun-config" -[ -n "$ARMBIAN_NET_NC_PATH" ] || ARMBIAN_NET_NC_PATH="/usr/local/bin/network-configurator" +[[ -n "$ARMBIAN_NET_FIRSTRUN_FILE" ]] || ARMBIAN_NET_FIRSTRUN_FILE="/boot/armbian_first_run.txt.template" +[[ -n "$ARMBIAN_NET_FIRSTRUN_SCRIPT" ]] || ARMBIAN_NET_FIRSTRUN_SCRIPT="/usr/lib/armbian/armbian-firstrun-config" +[[ -n "$ARMBIAN_NET_NC_PATH" ]] || ARMBIAN_NET_NC_PATH="/usr/local/bin/network-configurator" diff --git a/src/modules/armbian_net/start_chroot_script b/src/modules/armbian_net/start_chroot_script index 7797d17b7..997425bd5 100644 --- a/src/modules/armbian_net/start_chroot_script +++ b/src/modules/armbian_net/start_chroot_script @@ -1,9 +1,12 @@ #!/usr/bin/env bash -# MainsailOS network configurator for armbian images -# written by Stephan Wendel aka KwadFan -# -# GPL V3 -######## +#### MainsailOS network configurator for armbian images +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### # shellcheck enable=require-variable-braces @@ -23,19 +26,23 @@ install_cleanup_trap ## Step 1: Install files unpack filesystem/root / root +## END ## Step 2: remove original template if [[ -f "${ARMBIAN_NET_FIRSTRUN_FILE}" ]]; then sudo rm -rf "${ARMBIAN_NET_FIRSTRUN_FILE}" fi +## END ## Step 3: Disable first run service systemctl_if_exists disable armbian-firstrun-config.service +## END ## Step 4: Copy original script to /usr/local/bin/network-configurator if [[ -f "${ARMBIAN_NET_FIRSTRUN_SCRIPT}" ]]; then sudo cp -p "${ARMBIAN_NET_FIRSTRUN_SCRIPT}" "${ARMBIAN_NET_NC_PATH}" fi +## END ## Step 5: patch /usr/local/bin/network-configurator if [[ -f "${ARMBIAN_NET_NC_PATH}" ]]; then @@ -50,6 +57,8 @@ if [[ -f "${ARMBIAN_NET_NC_PATH}" ]]; then sed -i '10 i # Original located at /usr/lib/armbian/armbian-firstrun-config' "${ARMBIAN_NET_NC_PATH}" sed -i '11 i # Changes made by https:\/\/github.com/mainsail-crew' "${ARMBIAN_NET_NC_PATH}" fi +## END ## Step 6: Enable systemd service systemctl_if_exists enable network-configurator.service +## END diff --git a/src/modules/armbian_pkgupgrade/start_chroot_script b/src/modules/armbian_pkgupgrade/start_chroot_script new file mode 100644 index 000000000..7090d0e5d --- /dev/null +++ b/src/modules/armbian_pkgupgrade/start_chroot_script @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +#### MainsailOS Specific procedure for armbian images to replace 'pkgupgrade' module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +#### Description: +#### Due missing packages in our armbian builds and +#### and buggy behaviour of kernel upgrades we have to skip +#### upgrading the kernel package during build time. +#### Kernel upgrade is possible after first boot. + +# shellcheck enable=require-variable-braces +# Source error handling, leave this in place +set -Ee + +# Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + +### Helper func +is_board_type() { + local board releasefile + board="" + releasefile="/etc/armbian-release" + if [[ -f "${releasefile}" ]]; then + board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" + fi + echo "${board}" +} + + +## Install some basic packages that are needed during build +## Package net-tools fixes module 'armbian_net' +DEBIAN_FRONTEND=noninteractive +export DEBIAN_FRONTEND +apt-get update --allow-releaseinfo-change +apt-get install --yes --assume-yes sudo apt-utils wget net-tools + +## Set kernel package on hold +### Orange Pi 3 LTS +if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then + echo "armbian-firmware hold" | dpkg --set-selections + echo "linux-image-current-sunxi64 hold" | dpkg --set-selections + echo "linux-dtb-current-sunxi64 hold" | dpkg --set-selections +fi + +### Orange Pi 4 LTS +if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then + echo "armbian-firmware hold" | dpkg --set-selections + echo "linux-image-current-rockchip64 hold" | dpkg --set-selections + echo "linux-dtb-current-rockchip64 hold" | dpkg --set-selections +fi + +## Run full upgrade +apt-get upgrade --yes --assume-yes + +## Revert hold status +### Orange Pi 3 LTS +if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then + echo "armbian-firmware install" | dpkg --set-selections + echo "linux-image-current-sunxi64 install" | dpkg --set-selections + echo "linux-dtb-current-sunxi64 install" | dpkg --set-selections +fi + +### Orange Pi 4 LTS +if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then + echo "armbian-firmware install" | dpkg --set-selections + echo "linux-image-current-rockchip64 install" | dpkg --set-selections + echo "linux-dtb-current-rockchip64 install" | dpkg --set-selections +fi + +unset DEBIAN_FRONTEND diff --git a/src/modules/opiconfig/config b/src/modules/opiconfig/config deleted file mode 100644 index 9c564b3ed..000000000 --- a/src/modules/opiconfig/config +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -#### opiconfig - OrangePi Configuration Module -#### -#### Written by Stephan Wendel aka KwadFan -#### Copyright 2021 -#### https://github.com/mainsail-crew/MainsailOS -#### -#### This File is distributed under GPLv3 -#### - -# Shebang for better file detection -# shellcheck disable=all - -[ -n "$OPICONFIG_CONFIG_TXT_FILE" ] || OPICONFIG_CONFIG_TXT_FILE="/boot/armbianEnv.txt" -[ -n "$OPICONFIG_CONFIG_BAK_FILE" ] || OPICONFIG_CONFIG_BAK_FILE="/boot/armbianEnv.txt.backup" -[ -n "$OPICONFIG_MODULES_FILE" ] || OPICONFIG_MODULES_FILE="/etc/modules" diff --git a/src/modules/opiconfig/start_chroot_script b/src/modules/opiconfig/start_chroot_script deleted file mode 100644 index ae8bd0c56..000000000 --- a/src/modules/opiconfig/start_chroot_script +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash -#### opiconfig - OrangePi Configuration Module -#### -#### Written by Stephan Wendel aka KwadFan -#### Copyright 2021 -#### https://github.com/mainsail-crew/MainsailOS -#### -#### This File is distributed under GPLv3 -#### - -#### NOTE: This module has to be used after armbian module!!! - -# shellcheck enable=require-variable-braces - -## Source error handling, leave this in place -set -Ee - -# Set DEBIAN_FRONTEND to noninteractive -if [[ "${DEBIAN_FRONTEND}" != "noninteractive" ]]; then - export DEBIAN_FRONTEND=noninteractive -fi - -## Source CustomPIOS common.sh -# shellcheck disable=SC1091 -source /common.sh -install_cleanup_trap - -### Helper func -is_board_type() { - local board releasefile - board="" - releasefile="/etc/armbian-release-info.txt" - if [[ -f "${releasefile}" ]]; then - board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" - fi - echo "${board}" -} - - -echo_green "Enable SPI interface on Orange Pi SBC's ..." - -# Step 1: Copy default config to backup file -cp "${OPICONFIG_CONFIG_TXT_FILE}" "${OPICONFIG_CONFIG_BAK_FILE}" - -# Step 2: Enable SPI in armbianEnv.txt depending on device - -## OrangePi 3 LTS -if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then - echo "overlays=spi-spidev1" >> "${OPICONFIG_CONFIG_TXT_FILE}" -fi - -## OrangePi 4 LTS -if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then - echo "overlays=spi-spidev" >> "${OPICONFIG_CONFIG_TXT_FILE}" - echo "param_spidev_spi_bus=1" >> "${OPICONFIG_CONFIG_TXT_FILE}" -fi - -# Step 3: add spi-dev module to /etc/modules -echo "spi-dev" >> "${OPICONFIG_MODULES_FILE}" - -echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config new file mode 100644 index 000000000..6196ce5f7 --- /dev/null +++ b/src/modules/orangepi/config @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Shebang for better file detection +#### MainsailOS Specific Tweaks for orangepi images +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +# shellcheck disable=all + +## General module configuration +[[ -n "$ORANGEPI_DEPS" ]] || ORANGEPI_DEPS="avahi-daemon iptables unzip \ +bash-completion" +[[ -n "$ORANGEPI_CONFIG_TXT_FILE" ]] || ORANGEPI_CONFIG_TXT_FILE="/boot/orangepiEnv.txt" +[[ -n "$ORANGEPI_CONFIG_BAK_FILE" ]] || ORANGEPI_CONFIG_BAK_FILE="/boot/orangepiEnv.txt.backup" +[[ -n "$ORANGEPI_MODULES_FILE" ]] || ORANGEPI_MODULES_FILE="/etc/modules" + +## Orange Pi Zero 2 additional configuration +[[ -n "$ORANGEPI_ENABLE_OVERLAYS_OPIZ2" ]] || ORANGEPI_ENABLE_OVERLAYS_OPIZ2="true" +[[ -n "$ORANGEPI_ADD_OVERLAYS_OPIZ2" ]] || ORANGEPI_ADD_OVERLAYS_OPIZ2="i2c3 uart5 spi-spidev" +[[ -n "$ORANGEPI_ADD_OVERLAYS_OPIZ2_PARAMS" ]] || ORANGEPI_ADD_OVERLAYS_OPIZ2_PARAMS="param_spidev_spi_bus=1 param_spidev_spi_cs=1" + +### EXPERIMENTAL: Install orangepi-config from source git repo +[[ -n "$ORANGEPI_INSTALL_OPI_CONFIG" ]] || ORANGEPI_INSTALL_OPI_CONFIG="true" +[[ -n "$ORANGEPI_OPI_CONFIG_URL" ]] || ORANGEPI_OPI_CONFIG_URL="https://raw.githubusercontent.com/orangepi-xunlong/orangepi-build/next/external/cache/sources/orangepi-config/" +[[ -n "$ORANGEPI_OPI_CONFIG_FILES" ]] || ORANGEPI_OPI_CONFIG_FILES="debian-config debian-config-functions debian-config-functions-network debian-config-jobs debian-config-submenu" diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script new file mode 100644 index 000000000..1a872a189 --- /dev/null +++ b/src/modules/orangepi/end_chroot_script @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +#### MainsailOS Specific Tweaks for orangepi images +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +# shellcheck enable=require-variable-braces +# Source error handling, leave this in place +set -Ee + +# Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + +## Clean up +## Step 1: Remove autologin and lock root account +if [ -f "/etc/systemd/system/getty@.service.d/override.conf" ]; then + rm -f /etc/systemd/system/getty@.service.d/override.conf +fi +## END + +## Step 2: Disable autologin on serial console +if [ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]; then + sed -i 's/--autologin root //' /etc/systemd/system/serial-getty@.service.d/override.conf +fi +## END + +## Step 3: Delete root passwd +### Deleting root passwd doesn't let you unlock the account +sudo passwd -d root +## END + +## Step 4: Lock root account +sudo passwd -l root +## END + +## Step 5: Remove passwdless sudo +sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers +## END diff --git a/src/modules/orangepi/filesystem/root/etc/udev/rules.d/97-gpio.rules b/src/modules/orangepi/filesystem/root/etc/udev/rules.d/97-gpio.rules new file mode 100644 index 000000000..a1adb0b51 --- /dev/null +++ b/src/modules/orangepi/filesystem/root/etc/udev/rules.d/97-gpio.rules @@ -0,0 +1 @@ +SUBSYSTEM=="gpio", KERNEL=="gpiochip[0-4]", GROUP="gpio", MODE="0660" diff --git a/src/modules/orangepi/filesystem/root/etc/update-motd.d/10-mainsailos b/src/modules/orangepi/filesystem/root/etc/update-motd.d/10-mainsailos new file mode 100755 index 000000000..a5f22022c --- /dev/null +++ b/src/modules/orangepi/filesystem/root/etc/update-motd.d/10-mainsailos @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +# +# Based on: +# https://github.com/armbian/build/blob/master/packages/bsp/common/etc/update-motd.d/10-armbian-header + +# Copyright (c) Authors: https://www.armbian.com/authors +# +# This file is licensed under the terms of the GNU General Public +# License version 2. This program is licensed "as is" without any +# warranty of any kind, whether express or implied. + +# Modified by Stephan Wendel aka KwadFan +# All changes made are public at +# https://github.com/mainsail-crew/MainsailOS + +# shellcheck enable=require-variable-braces + +# shellcheck disable=SC1091 +[[ -f /etc/orangepi-release-info.txt ]] && . /etc/orangepi-release-info.txt + +if [[ -f /etc/orangepi-distribution-status ]]; then + . /etc/orangepi-distribution-status + [[ -f /etc/lsb-release ]] && DISTRIBUTION_CODENAME=$(grep CODENAME /etc/lsb-release | cut -d"=" -f2) + [[ -z "${DISTRIBUTION_CODENAME}" && -f /etc/os-release ]] && DISTRIBUTION_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d"=" -f2) + [[ -z "${DISTRIBUTION_CODENAME}" && -x /usr/bin/lsb_release ]] && DISTRIBUTION_CODENAME=$(/usr/bin/lsb_release -c | cut -d":" -f2 | tr -d "\t") + DISTRIBUTION_STATUS=$(grep "${DISTRIBUTION_CODENAME}" /etc/orangepi-distribution-status | cut -d"=" -f2) +fi +[[ -f /etc/default/orangepi-motd ]] && . /etc/default/orangepi-motd + +for f in ${MOTD_DISABLE}; do + [[ "${f}" == "${THIS_SCRIPT}" ]] && exit 0 +done + + +KERNELID=$(uname -r) + +# Odroid N2 exception +ODROID_EXCEPTION="$(tr -d '\000' < /proc/device-tree/model | grep ODROID | grep Plus)" +[[ -f /proc/device-tree/model ]] && [[ -n "${ODROID_EXCEPTION}" ]] && BOARD_NAME+="+" + + +echo -e "\e[31m$(toilet -f big MainsailOS)\e[0m" +echo -e "Version $(cut -d ' ' -f3 /etc/mainsailos-release), based on \ +\e[34mOrange Pi OS ${VERSION} ${DISTRIBUTION_CODENAME^}\e[0m $([[ ${BRANCH} == edge ]])" +echo -e "Running on \e[34m$(echo "${BOARD_NAME}" | sed 's/Orange Pi/OPi/' | \ +sed 's/NanoPi/NPi/' | sed 's/Banana Pi/BPi/')\e[0m with \e[34mLinux ${KERNELID}\e[0m\n" + +# displaying status warnings + +if [[ "${IMAGE_TYPE}" != "stable" ]]; then + [[ "${IMAGE_TYPE}" == "user-built" ]] && UNSUPPORTED_TEXT="built from trunk" + [[ "${IMAGE_TYPE}" == "nightly" ]] && UNSUPPORTED_TEXT="untested automated build" +else + [[ "${BOARD_TYPE}" == "csc" || "${BOARD_TYPE}" == "tvb" ]] && UNSUPPORTED_TEXT="community creations" + [[ "${BOARD_TYPE}" == "wip" ]] && UNSUPPORTED_TEXT="work in progress" + [[ "${BOARD_TYPE}" == "eos" ]] && UNSUPPORTED_TEXT="end of life" +fi + +if [[ -n ${DISTRIBUTION_STATUS} && ${DISTRIBUTION_STATUS} != supported ]]; then + [[ -n ${UNSUPPORTED_TEXT} ]] && UNSUPPORTED_TEXT+=" & " + UNSUPPORTED_TEXT+="unsupported (${DISTRIBUTION_CODENAME}) userspace!" +fi + +if [[ -n ${UNSUPPORTED_TEXT} ]]; then + echo -e "\e[0;91mNo end-user support: \x1B[0m${UNSUPPORTED_TEXT}\n" +fi diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script new file mode 100644 index 000000000..cb2596e55 --- /dev/null +++ b/src/modules/orangepi/start_chroot_script @@ -0,0 +1,194 @@ +#!/usr/bin/env bash +#### MainsailOS Specific Tweaks for orangepi images +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +#### NOTE: udev rules file is applied in Step 6! +#### This is based on https://github.com/Arksine/moonraker/issues/562 + + +# shellcheck enable=require-variable-braces +# Source error handling, leave this in place +set -Ee + +## Uncomment for deeper debugging +# set -x + +# Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + +# Helper func +is_board_type() { + local board releasefile + board="" + releasefile="/etc/orangepi-release-info.txt" + if [[ -f "${releasefile}" ]]; then + board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" + fi + echo "${board}" +} + +# Base User groups +# Shameless "stolen" from +# https://github.com/guysoft/CustomPiOS/blob/devel/src/variants/armbian/pre_chroot_script + +if_group_exists_run() { + group=$1 + if grep -q "${group}" /etc/group; then + "${@:2}" + fi +} + +# passwordless sudo during install +# Will be removed in cleanup +echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers + +## Step 1: Install armbian specific packages +apt update +# shellcheck disable=SC2086 +check_install_pkgs ${ORANGEPI_DEPS} +## END Step 1 + +## Step 2: Manage groups and default user + +### Substep 1: Create group for gpio usage +sudo groupadd gpio +### END Substep 1 + +### Substep 2: Set default groups +if_group_exists_run i2c usermod -aG i2c "${BASE_USER}" +usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal,gpio "${BASE_USER}" +### END Substep 2 + +### Substep 3: Remove user "orangepi" +sudo userdel orangepi +sudo rm -rf /home/orangepi +### END Substep 3 +## END Step 2 + +## Step 3: Patch sshd_config (Limit retrys, disable root login via ssh) +sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config +sed -i 's/^X11Forwarding/#X11Forwarding/' /etc/ssh/sshd_config +sed -i 's/^#MaxAuthTries 6/MaxAuthTries 3/' /etc/ssh/sshd_config +## END Step 3 + +## Step 4: Try patching first login in build stage +if [ -f "/root/.not_logged_in_yet" ]; then + rm -f /root/.not_logged_in_yet +fi +## END Step 4 + +## Step 5: Move armbian-release to display mainsailos-release +if [[ -f "/etc/orangepi-release" ]]; then + echo_green "OrangePi release file found! moving to: 'orangepi-release-info.txt'" + mv /etc/orangepi-release /etc/orangepi-release-info.txt +else + echo_red "OrangePi release file not found! [SKIPPED]" +fi +## END Step 5 + +## Step 6: Patch dynamic motd +echo_green "Patch dynamic motd ..." +unpack /filesystem/root / +chmod +x /etc/update-motd.d/* +if [ -f "/etc/default/orangepi-motd" ]; then + sed -i 's/^MOTD_DISABLE=""/MOTD_DISABLE="header tips"/' /etc/default/orangepi-motd +fi +## END Step 6 + +## Step 7: Enable SPI interface by default +echo_green "Enable interfaces on Orange Pi SBC's ..." + +### Substep 1: Copy default config to backup file +cp "${ORANGEPI_CONFIG_TXT_FILE}" "${ORANGEPI_CONFIG_BAK_FILE}" +### END Substep 1 + +### Substep 2: Enable SPI in armbianEnv.txt depending on device + +#### Orangepi Zero2 +if [[ "$(is_board_type)" == "orangepizero2" ]] && +[[ "${ORANGEPI_ENABLE_OVERLAYS_OPIZ2}" == "true" ]]; then + + if [[ -n "${ORANGEPI_ADD_OVERLAYS_OPIZ2}" ]]; then + echo_green "Adding overlays '${ORANGEPI_ADD_OVERLAYS_OPIZ2}' to ${ORANGEPI_CONFIG_TXT_FILE} ..." + echo "overlays=${ORANGEPI_ADD_OVERLAYS_OPIZ2}" >> "${ORANGEPI_CONFIG_TXT_FILE}" + fi + + if [[ -n "${ORANGEPI_ADD_OVERLAYS_OPIZ2_PARAMS}" ]]; then + for param in ${ORANGEPI_ADD_OVERLAYS_OPIZ2_PARAMS}; do + echo_green "Add ${param} to ${ORANGEPI_CONFIG_TXT_FILE} ..." + echo "${param}" >> "${ORANGEPI_CONFIG_TXT_FILE}" + done + fi +fi +#### END + +### END Substep 2 + +# Substep 3: add spi-dev module to /etc/modules +echo "spi-dev" >> "${ORANGEPI_MODULES_FILE}" + +echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" +## END Step 7 + +## Step 8: Install orangepi-config from git source repository +if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then + echo_green "Install orangepi-config from git sources ..." + + ### Substep 1: Create temporary dir 'src/workspace/opi-config-src' + ORANGEPI_OPI_CONFIG_TEMP="src/workspace/opi-config-src" + if [[ ! -d "${ORANGEPI_OPI_CONFIG_TEMP}" ]]; then + mkdir -p "${ORANGEPI_OPI_CONFIG_TEMP}" + fi + ### END Substep 1 + + ### Substep 2: Create array from ORANGEPI_OPI_CONFIG_FILES + for name in ${ORANGEPI_OPI_CONFIG_FILES}; do + ORANGEPI_OPI_CONFIG_FILES_ARR+=("${name}") + done + ### END Substep 2 + + ### Substep 3: curl sources from git repo to src/workspace/opi-config + for file in "${ORANGEPI_OPI_CONFIG_FILES_ARR[@]}"; do + curl -sL "${ORANGEPI_OPI_CONFIG_URL}"/"${file}" --output "${ORANGEPI_OPI_CONFIG_TEMP}"/"${file}" + done + ### END Substep 3 + + ### Substep 4: Create subdir 'orangepi-config' in /usr/lib/ + if [[ ! -d "/usr/lib/orangepi-config" ]]; then + mkdir -p "/usr/lib/orangepi-config" + fi + ### END Substep 4 + + ### Substep 5: Copy main script to /usr/sbin (orangepi-config) + cp -f "src/workspace/opi-config-src/${ORANGEPI_OPI_CONFIG_FILES_ARR[*]:0:1}" "/usr/sbin/orangepi-config" + ### END Substep 5 + + ### Substep 6: Add executable flag + if [[ ! -x "/usr/sbin/orangepi-config" ]]; then + chmod +x "/usr/sbin/orangepi-config" + fi + ### END Substep 6 + + ### Substep 7: Link main script to /usr/bin/orangepi-config + ln -sf "/usr/sbin/orangepi-config" "/usr/bin/orangepi-config" + ### END Substep 7 + + ### Substep 7: Install script librarys to /usr/lib/orangepi-config + for i in "${ORANGEPI_OPI_CONFIG_FILES_ARR[@]:1}"; do + stripped="${i##debian-config-}" + cp -f "${ORANGEPI_OPI_CONFIG_TEMP}/${i}" "/usr/lib/orangepi-config/${stripped}.sh" + done + ### END Substep 7 + +else + echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" +fi +## END Step 8 diff --git a/src/modules/orangepi_net/config b/src/modules/orangepi_net/config new file mode 100644 index 000000000..3bd31bb1f --- /dev/null +++ b/src/modules/orangepi_net/config @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Shebang for better file detection +#### MainsailOS network configurator for orange images +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +# shellcheck disable=all + +[[ -n "$ORANGEPI_NET_FIRSTRUN_FILE" ]] || ORANGEPI_NET_FIRSTRUN_FILE="/boot/orangepi_first_run.txt.template" +[[ -n "$ORANGEPI_NET_FIRSTRUN_SCRIPT" ]] || ORANGEPI_NET_FIRSTRUN_SCRIPT="/usr/lib/orangepi/orangepi-firstrun-config" +[[ -n "$ORANGEPI_NET_NC_PATH" ]] || ORANGEPI_NET_NC_PATH="/usr/local/bin/network-configurator" diff --git a/src/modules/orangepi_net/filesystem/root/boot/network_config.txt.template b/src/modules/orangepi_net/filesystem/root/boot/network_config.txt.template new file mode 100644 index 000000000..f3173c054 --- /dev/null +++ b/src/modules/orangepi_net/filesystem/root/boot/network_config.txt.template @@ -0,0 +1,49 @@ +#----------------------------------------------------------------- +# +# MainsailOS (orangepi edition) Network Configuration +# Set optional end user configuration +# - Rename this file from /boot/network_config.txt.template to /boot/network_config.txt +# - Settings below will be applied every time you reboot your machine. +# Be aware, old configurations will be deleted! +# +# This file is based on work of the armbian developer team +# https://github.com/armbian/build/blob/master/packages/bsp/armbian_first_run.txt.template +#----------------------------------------------------------------- + +#----------------------------------------------------------------- +# General: +# 1 = delete this file, after first run setup is completed. + +NC_general_delete_this_file_after_completion=1 + +#----------------------------------------------------------------- +#Networking: +# Change default network settings +# Set to 1 to apply any network related settings below + +NC_net_change_defaults=0 + +# Enable WiFi or Ethernet. +# NB: If both are enabled, WiFi will take priority and Ethernet will be disabled. + +NC_net_ethernet_enabled=1 +NC_net_wifi_enabled=0 + +#Enter your WiFi creds +# SECURITY WARN: Your wifi keys will be stored in plaintext, no encryption. + +NC_net_wifi_ssid='MySSID' +NC_net_wifi_key='MyWiFiKEY' + +# Country code to enable power ratings and channels for your country. eg: GB US DE | https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + +NC_net_wifi_countrycode='GB' + +# If you want to use a static ip, set it here + +NC_net_use_static=0 +NC_net_static_ip='192.168.0.100' +NC_net_static_mask='255.255.255.0' +NC_net_static_gateway='192.168.0.1' +NC_net_static_dns='8.8.8.8 8.8.4.4' # Two entries max, seperated by a space. +#----------------------------------------------------------------- diff --git a/src/modules/orangepi_net/filesystem/root/etc/systemd/system/network-configurator.service b/src/modules/orangepi_net/filesystem/root/etc/systemd/system/network-configurator.service new file mode 100644 index 000000000..6568ee6d4 --- /dev/null +++ b/src/modules/orangepi_net/filesystem/root/etc/systemd/system/network-configurator.service @@ -0,0 +1,20 @@ +# MainsailOS network-configurator +# This service will run in parallel with other services +# This is based on +# https://github.com/armbian/build/blob/master/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service + + +[Unit] +Description=MainsailOS network configurator +Wants=network-online.target +After=network.target network-online.target +ConditionPathExists=/boot/network_config.txt + +[Service] +Type=idle +RemainAfterExit=yes +ExecStart=/usr/local/bin/network-configurator +TimeoutStartSec=2min + +[Install] +WantedBy=multi-user.target diff --git a/src/modules/orangepi_net/start_chroot_script b/src/modules/orangepi_net/start_chroot_script new file mode 100644 index 000000000..792754a58 --- /dev/null +++ b/src/modules/orangepi_net/start_chroot_script @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +#### MainsailOS network configurator for orange images +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +# shellcheck enable=require-variable-braces + +# Description: +# This file installs a service based on armbians armbian_firstrun_config +# The original work is done by the armbian developer's team +# sources of files can be found here: https://github.com/armbian/build + +# Source error handling, leave this in place +set -Ee + +# Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + + +## Step 1: Install files +unpack filesystem/root / root +## END + +## Step 2: remove original template +if [[ -f "${ORANGEPI_NET_FIRSTRUN_FILE}" ]]; then + sudo rm -rf "${ORANGEPI_NET_FIRSTRUN_FILE}" +fi +## END + +## Step 3: Disable first run service +systemctl_if_exists disable orangepi-firstrun-config.service +## END + +## Step 4: Copy original script to /usr/local/bin/network-configurator +if [[ -f "${ORANGEPI_NET_FIRSTRUN_SCRIPT}" ]]; then + sudo cp -p "${ORANGEPI_NET_FIRSTRUN_SCRIPT}" "${ORANGEPI_NET_NC_PATH}" +fi +## END + +## Step 5: patch /usr/local/bin/network-configurator +if [[ -f "${ORANGEPI_NET_NC_PATH}" ]]; then + ### Substep 1: replace any orangepi_first_run.txt with network_config.txt + sed -i 's|orangepi_first_run.txt|network_config.txt|g' "${ORANGEPI_NET_NC_PATH}" + ### Substep 2: replace any FR* Variable name with NC* + sed -i 's|FR|NC|g' "${ORANGEPI_NET_NC_PATH}" + ### Supstep 3: Rename function + sed -i 's|do_firstrun_automated_user_configuration|do_network_configuration|g' "${ORANGEPI_NET_NC_PATH}" + ### Substep 4: Add a patch note + sed -i '8 i \\n\# This is a patched version of orangepi-firstrun-config for MainsailOS' "${ORANGEPI_NET_NC_PATH}" + sed -i '10 i # Original located at /usr/lib/orangepi/orangepi-firstrun-config' "${ORANGEPI_NET_NC_PATH}" + sed -i '11 i # Changes made by https:\/\/github.com/mainsail-crew' "${ORANGEPI_NET_NC_PATH}" +fi +## END + +## Step 6: Enable systemd service +systemctl_if_exists enable network-configurator.service +## END diff --git a/src/version b/src/version index 7dea76edb..1c6f7dee7 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.0.1 +1.1.0-alpha From 42312164336966b8fabf72618f60216b6a797f04 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sat, 18 Mar 2023 15:36:02 +0100 Subject: [PATCH 11/39] fix: remove enduser support msg from zero2 images (#209) --- .../root/etc/update-motd.d/10-mainsailos | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/src/modules/orangepi/filesystem/root/etc/update-motd.d/10-mainsailos b/src/modules/orangepi/filesystem/root/etc/update-motd.d/10-mainsailos index a5f22022c..6d062fcd0 100755 --- a/src/modules/orangepi/filesystem/root/etc/update-motd.d/10-mainsailos +++ b/src/modules/orangepi/filesystem/root/etc/update-motd.d/10-mainsailos @@ -23,7 +23,6 @@ if [[ -f /etc/orangepi-distribution-status ]]; then [[ -f /etc/lsb-release ]] && DISTRIBUTION_CODENAME=$(grep CODENAME /etc/lsb-release | cut -d"=" -f2) [[ -z "${DISTRIBUTION_CODENAME}" && -f /etc/os-release ]] && DISTRIBUTION_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d"=" -f2) [[ -z "${DISTRIBUTION_CODENAME}" && -x /usr/bin/lsb_release ]] && DISTRIBUTION_CODENAME=$(/usr/bin/lsb_release -c | cut -d":" -f2 | tr -d "\t") - DISTRIBUTION_STATUS=$(grep "${DISTRIBUTION_CODENAME}" /etc/orangepi-distribution-status | cut -d"=" -f2) fi [[ -f /etc/default/orangepi-motd ]] && . /etc/default/orangepi-motd @@ -44,23 +43,3 @@ echo -e "Version $(cut -d ' ' -f3 /etc/mainsailos-release), based on \ \e[34mOrange Pi OS ${VERSION} ${DISTRIBUTION_CODENAME^}\e[0m $([[ ${BRANCH} == edge ]])" echo -e "Running on \e[34m$(echo "${BOARD_NAME}" | sed 's/Orange Pi/OPi/' | \ sed 's/NanoPi/NPi/' | sed 's/Banana Pi/BPi/')\e[0m with \e[34mLinux ${KERNELID}\e[0m\n" - -# displaying status warnings - -if [[ "${IMAGE_TYPE}" != "stable" ]]; then - [[ "${IMAGE_TYPE}" == "user-built" ]] && UNSUPPORTED_TEXT="built from trunk" - [[ "${IMAGE_TYPE}" == "nightly" ]] && UNSUPPORTED_TEXT="untested automated build" -else - [[ "${BOARD_TYPE}" == "csc" || "${BOARD_TYPE}" == "tvb" ]] && UNSUPPORTED_TEXT="community creations" - [[ "${BOARD_TYPE}" == "wip" ]] && UNSUPPORTED_TEXT="work in progress" - [[ "${BOARD_TYPE}" == "eos" ]] && UNSUPPORTED_TEXT="end of life" -fi - -if [[ -n ${DISTRIBUTION_STATUS} && ${DISTRIBUTION_STATUS} != supported ]]; then - [[ -n ${UNSUPPORTED_TEXT} ]] && UNSUPPORTED_TEXT+=" & " - UNSUPPORTED_TEXT+="unsupported (${DISTRIBUTION_CODENAME}) userspace!" -fi - -if [[ -n ${UNSUPPORTED_TEXT} ]]; then - echo -e "\e[0;91mNo end-user support: \x1B[0m${UNSUPPORTED_TEXT}\n" -fi From d7833bb58bfbc3f93526a1ae200f6664f0a729c3 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 18 Mar 2023 14:40:12 +0000 Subject: [PATCH 12/39] chore: push version number to v1.1.0 --- src/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version b/src/version index 1c6f7dee7..9084fa2f7 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.1.0-alpha +1.1.0 From 1c59918d41808b0231962a56a4f2ff2d83494d17 Mon Sep 17 00:00:00 2001 From: meteyou Date: Sat, 18 Mar 2023 15:26:41 +0000 Subject: [PATCH 13/39] docs(changelog): update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26b7ea0b6..bee22dbc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,12 +19,16 @@ All notable changes to Mainsail will be documented in this file. - Add python3-serial CanBoot dependency (#129) | [1f59f0f](1f59f0f0db4ef653dafec0e04f18b3b08b639606) - Add postrename module (#128) | [942896c](942896c8c9899763f64f6e58c00570584ab528e0) - Add timelapse module (#130) | [7b99d1f](7b99d1f02fdab98a3a314cb090c1f3de6c02a203) +- Enable I2C by default (#196) | [9cebd0c](9cebd0c8545fa41a826112658dfe401b4306a2bd) +- Add Orange Pi 3 and 4 LTS (#186) | [2f556c3](2f556c3232b3d01ac48d30e08ae230cd5fda13fe) +- Add orange pi zero2 (#189) | [df2aa35](df2aa3528142f144b1c9928f90458c3a6d6c78c7) ### Bug Fixes and Improvements - **build**: Updated download paths (#65) | [0622a2f](0622a2f60a8e39237c1fd213d67932ae6c986e08) - **build**: Fixes error in Makefile (#76) | [0ff09b5](0ff09b5ac0503e8cee0c35a298a41a26344b57c8) - **build**: Updated torrent download url (#90) | [a16126c](a16126c08733f96f6db7b067e7fa12d12324569b) +- **build**: Fix mv of image file (#204) | [dc8c588](dc8c588df649fd3dff86602d13d3ae3fbea31b66) - **config.txt**: Fix configuration errors with attached screens (#119) | [81c335e](81c335eb6cb7d54de2b5433611f13dfefff2f5d7) - **crowsnest**: Fix install of crowsnest (#111) | [e8eee5f](e8eee5fc07df000cebf3ff7379454a3efce0042b) - **lint**: Should fix shellcheck warnings (#160) | [2569dd2](2569dd25db5c719c3e55d299062c5664c3c038b0) @@ -45,6 +49,9 @@ All notable changes to Mainsail will be documented in this file. - Fixes error setting link to macro (#175) | [d1ad3f8](d1ad3f8006ad7c9b84a9a34acc4798f15ab605e4) - Fix shellcheck errors (#185) | [efe1b68](efe1b68d0a8cd5ccf3238d280c83ae523c331688) - Fix syntax error in net module (#191) | [cb890af](cb890afafaa1ab6dc68fbfdc103ceca61432e064) +- Fix compress step (#205) | [fec2432](fec24320ea4bdcf51c9430e89443035b4ade70f1) +- Fix rpi-image.json workflow in Release.yml (#206) | [a03626a](a03626a54a21b1fa1175b458665ae14e9b755037) +- Remove enduser support msg from zero2 images (#209) | [4231216](42312164336966b8fabf72618f60216b6a797f04) ### Refactor @@ -55,6 +62,7 @@ All notable changes to Mainsail will be documented in this file. - Add `enable_auto_refresh: True` (#133) | [1b78efb](1b78efb963537a3a6dad5910ff201ba19cee2103) - Deactivate IPv6 in nginx per default (#157) | [40b3719](40b37192608e13b4f5e97b295840715a42974fb6) - Change behavior of piconfig module (#180) | [825af74](825af74061c48043c1ae8390c0825d2220bd623f) +- Use mv to move the image from the workspace to the root (#203) | [b7acb1e](b7acb1e49c02d2d9f50dfdc3541c10f4f2b2becc) ### Documentation From 799a919c2c4f2f8bf46971de88a79ab7d0bea137 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 19 Mar 2023 11:50:31 +0100 Subject: [PATCH 14/39] refactor: drop armbian_pkgupgrade (#210) Due usage of weekly build images pkgupgrade is useless Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- .../armbian_pkgupgrade/start_chroot_script | 78 ------------------- 2 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 src/modules/armbian_pkgupgrade/start_chroot_script diff --git a/config/armbian/default b/config/armbian/default index f8efce374..1a9e655d9 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,armbian_pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL diff --git a/src/modules/armbian_pkgupgrade/start_chroot_script b/src/modules/armbian_pkgupgrade/start_chroot_script deleted file mode 100644 index 7090d0e5d..000000000 --- a/src/modules/armbian_pkgupgrade/start_chroot_script +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash -#### MainsailOS Specific procedure for armbian images to replace 'pkgupgrade' module -#### -#### Written by Stephan Wendel aka KwadFan -#### Copyright 2023 - till today -#### https://github.com/mainsail-crew/MainsailOS -#### -#### This File is distributed under GPLv3 -#### - -#### Description: -#### Due missing packages in our armbian builds and -#### and buggy behaviour of kernel upgrades we have to skip -#### upgrading the kernel package during build time. -#### Kernel upgrade is possible after first boot. - -# shellcheck enable=require-variable-braces -# Source error handling, leave this in place -set -Ee - -# Source CustomPIOS common.sh -# shellcheck disable=SC1091 -source /common.sh -install_cleanup_trap - -### Helper func -is_board_type() { - local board releasefile - board="" - releasefile="/etc/armbian-release" - if [[ -f "${releasefile}" ]]; then - board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" - fi - echo "${board}" -} - - -## Install some basic packages that are needed during build -## Package net-tools fixes module 'armbian_net' -DEBIAN_FRONTEND=noninteractive -export DEBIAN_FRONTEND -apt-get update --allow-releaseinfo-change -apt-get install --yes --assume-yes sudo apt-utils wget net-tools - -## Set kernel package on hold -### Orange Pi 3 LTS -if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then - echo "armbian-firmware hold" | dpkg --set-selections - echo "linux-image-current-sunxi64 hold" | dpkg --set-selections - echo "linux-dtb-current-sunxi64 hold" | dpkg --set-selections -fi - -### Orange Pi 4 LTS -if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then - echo "armbian-firmware hold" | dpkg --set-selections - echo "linux-image-current-rockchip64 hold" | dpkg --set-selections - echo "linux-dtb-current-rockchip64 hold" | dpkg --set-selections -fi - -## Run full upgrade -apt-get upgrade --yes --assume-yes - -## Revert hold status -### Orange Pi 3 LTS -if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then - echo "armbian-firmware install" | dpkg --set-selections - echo "linux-image-current-sunxi64 install" | dpkg --set-selections - echo "linux-dtb-current-sunxi64 install" | dpkg --set-selections -fi - -### Orange Pi 4 LTS -if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then - echo "armbian-firmware install" | dpkg --set-selections - echo "linux-image-current-rockchip64 install" | dpkg --set-selections - echo "linux-dtb-current-rockchip64 install" | dpkg --set-selections -fi - -unset DEBIAN_FRONTEND From b82137c14ea09f784478687d32a042c825af8262 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Thu, 23 Mar 2023 18:54:38 +0100 Subject: [PATCH 15/39] fix: fix rpi-imager json value format for extract_size & image_download_size (#212) Signed-off-by: Stefan Dej --- .github/workflows/Release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index d32590abf..1504003f4 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -247,9 +247,9 @@ jobs: icon, init_format, release_date, - extract_size, + extract_size: parseInt(extract_size), extract_sha256, - image_download_size, + image_download_size: parseInt(image_download_size), image_download_sha256 }) From fae8b3fd1f9f2b2cf2ca53e737f3862eddd62a36 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 26 Mar 2023 13:44:53 +0200 Subject: [PATCH 16/39] fix: fix firstboot issue (#214) --- config/raspberry/default | 2 +- src/modules/mainsailos/start_chroot_script | 8 +- src/modules/rpi_firstb_fix/config | 13 + .../usr/lib/raspberrypi-sys-mods/firstboot | 264 ++++++++++++++++++ .../rpi_firstb_fix/start_chroot_script | 32 +++ src/version | 2 +- 6 files changed, 316 insertions(+), 5 deletions(-) create mode 100644 src/modules/rpi_firstb_fix/config create mode 100755 src/modules/rpi_firstb_fix/filesystem/root/usr/lib/raspberrypi-sys-mods/firstboot create mode 100644 src/modules/rpi_firstb_fix/start_chroot_script diff --git a/config/raspberry/default b/config/raspberry/default index 65d8dd99e..e43627344 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -9,7 +9,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,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename" +MODULES="base,pkgupgrade,rpi_firstb_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename" # export Variables export BASE_IMAGE_ENLARGEROOT diff --git a/src/modules/mainsailos/start_chroot_script b/src/modules/mainsailos/start_chroot_script index 4ef5114d1..1f9a192f5 100644 --- a/src/modules/mainsailos/start_chroot_script +++ b/src/modules/mainsailos/start_chroot_script @@ -22,7 +22,7 @@ fi source /common.sh install_cleanup_trap -# Create mainsailos release file +## Step 1: Create mainsailos release file if [ -f "/etc/mainsailos_version" ]; then sudo rm -f /etc/mainsailos_version fi @@ -31,8 +31,10 @@ function get_parent { } echo "${DIST_NAME} release ${DIST_VERSION} ($(get_parent))" > /etc/"${DIST_NAME,,}"-release +## END Step 1 -### Install CANBoot Dependency -apt update +## Step 2: Install CANBoot Dependency +apt-get update --allow-releaseinfo-change # shellcheck disable=SC2086 check_install_pkgs ${MAINSAILOS_DEPS} +## END Step 2 diff --git a/src/modules/rpi_firstb_fix/config b/src/modules/rpi_firstb_fix/config new file mode 100644 index 000000000..82afc5d89 --- /dev/null +++ b/src/modules/rpi_firstb_fix/config @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Shebang for better file detection +#### rpi_firstb_fix module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +# Intentionally left blank +# See start_chroot_script for information diff --git a/src/modules/rpi_firstb_fix/filesystem/root/usr/lib/raspberrypi-sys-mods/firstboot b/src/modules/rpi_firstb_fix/filesystem/root/usr/lib/raspberrypi-sys-mods/firstboot new file mode 100755 index 000000000..bd1a1f87e --- /dev/null +++ b/src/modules/rpi_firstb_fix/filesystem/root/usr/lib/raspberrypi-sys-mods/firstboot @@ -0,0 +1,264 @@ +#!/bin/bash +# shellcheck disable=all + + +reboot_pi () { + umount /boot + mount / -o remount,ro + sync + if [ "$NOOBS" = "1" ]; then + if [ "$NEW_KERNEL" = "1" ]; then + reboot -f "$BOOT_PART_NUM" + sleep 5 + else + echo "$BOOT_PART_NUM" > "/sys/module/${BCM_MODULE}/parameters/reboot_part" + fi + fi + reboot -f + sleep 5 + exit 0 +} + +check_noobs () { + if [ "$BOOT_PART_NUM" = "1" ]; then + NOOBS=0 + else + NOOBS=1 + fi +} + +get_variables () { + ROOT_PART_DEV=$(findmnt / -o source -n) + ROOT_PART_NAME=$(echo "$ROOT_PART_DEV" | cut -d "/" -f 3) + ROOT_DEV_NAME=$(echo /sys/block/*/"${ROOT_PART_NAME}" | cut -d "/" -f 4) + ROOT_DEV="/dev/${ROOT_DEV_NAME}" + ROOT_PART_NUM=$(cat "/sys/block/${ROOT_DEV_NAME}/${ROOT_PART_NAME}/partition") + + BOOT_PART_DEV=$(findmnt /boot -o source -n) + BOOT_PART_NAME=$(echo "$BOOT_PART_DEV" | cut -d "/" -f 3) + BOOT_DEV_NAME=$(echo /sys/block/*/"${BOOT_PART_NAME}" | cut -d "/" -f 4) + BOOT_PART_NUM=$(cat "/sys/block/${BOOT_DEV_NAME}/${BOOT_PART_NAME}/partition") + + OLD_DISKID=$(fdisk -l "$ROOT_DEV" | sed -n 's/Disk identifier: 0x\([^ ]*\)/\1/p') + + check_noobs + + ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size") + TARGET_END=$((ROOT_DEV_SIZE - 1)) + + PARTITION_TABLE=$(parted -m "$ROOT_DEV" unit s print | tr -d 's') + + LAST_PART_NUM=$(echo "$PARTITION_TABLE" | tail -n 1 | cut -d ":" -f 1) + + ROOT_PART_LINE=$(echo "$PARTITION_TABLE" | grep -e "^${ROOT_PART_NUM}:") + ROOT_PART_START=$(echo "$ROOT_PART_LINE" | cut -d ":" -f 2) + ROOT_PART_END=$(echo "$ROOT_PART_LINE" | cut -d ":" -f 3) + + if [ "$NOOBS" = "1" ]; then + EXT_PART_LINE=$(echo "$PARTITION_TABLE" | grep ":::;" | head -n 1) + EXT_PART_NUM=$(echo "$EXT_PART_LINE" | cut -d ":" -f 1) + EXT_PART_START=$(echo "$EXT_PART_LINE" | cut -d ":" -f 2) + EXT_PART_END=$(echo "$EXT_PART_LINE" | cut -d ":" -f 3) + fi +} + +fix_partuuid() { + mount -o remount,rw "$ROOT_PART_DEV" + mount -o remount,rw "$BOOT_PART_DEV" + MAJOR="$(uname -r | cut -f1 -d.)" + if [[ "$MAJOR" -eq "6" ]] && [[ -c /dev/hwrng ]]; then + dd if=/dev/hwrng of=/dev/urandom count=1 bs=256 status=none + fi + DISKID="$(tr -dc 'a-f0-9' < /dev/urandom | dd bs=1 count=8 2>/dev/null)" + fdisk "$ROOT_DEV" > /dev/null < /dev/null 2>&1 + RET="$?" + if [ "$RET" -ne 0 ]; then + FAIL_REASON="Root partition resize failed\n$FAIL_REASON" + fi + + mount -o remount,ro / + return "$RET" +} + +regenerate_ssh_host_keys () { + mount -o remount,rw / + /usr/lib/raspberrypi-sys-mods/regenerate_ssh_host_keys + RET="$?" + mount -o remount,ro / + return "$RET" +} + +apply_custom () { + CONFIG_FILE="$1" + mount -o remount,rw / + mount -o remount,rw /boot + if ! python3 -c "import toml" 2> /dev/null; then + FAIL_REASON="custom.toml provided, but python3-toml is not installed\n$FAIL_REASON" + else + set -o pipefail + /usr/lib/raspberrypi-sys-mods/init_config "$CONFIG_FILE" |& tee /run/firstboot.log | while read -r line; do + MSG="$MSG\n$line" + whiptail --infobox "$MSG" 20 60 + done + if [ "$?" -ne 0 ]; then + mv /run/firstboot.log /var/log/firstboot.log + FAIL_REASON="Failed to apply customisations from custom.toml\n\nLog file saved as /var/log/firstboot.log\n$FAIL_REASON" + fi + set +o pipefail + fi + rm -f "$CONFIG_FILE" + mount -o remount,ro /boot + mount -o remount,ro / +} + +main () { + get_variables + + if check_variables; then + do_resize + fi + + # Switch to dhcpcd here if Imager < v1.7.3 was used to generate firstrun.sh + fix_wpa > /dev/null 2>&1 + + whiptail --infobox "Generating SSH keys..." 20 60 + regenerate_ssh_host_keys + + if [ -f "/boot/custom.toml" ]; then + MSG="Applying customisations from custom.toml...\n" + whiptail --infobox "$MSG" 20 60 + apply_custom "/boot/custom.toml" + fi + + whiptail --infobox "Fix PARTUUID..." 20 60 + fix_partuuid + + return 0 +} + +mount -t proc proc /proc +mount -t sysfs sys /sys +mount -t tmpfs tmp /run +mkdir -p /run/systemd + +mount /boot +mount / -o remount,ro + +sed -i 's| init=/usr/lib/raspberrypi-sys-mods/firstboot||' /boot/cmdline.txt +sed -i 's| sdhci\.debug_quirks2=4||' /boot/cmdline.txt + +if ! grep -q splash /boot/cmdline.txt; then + sed -i "s/ quiet//g" /boot/cmdline.txt +fi +mount /boot -o remount,ro +sync + +main + +if [ -z "$FAIL_REASON" ]; then + whiptail --infobox "Rebooting in 5 seconds..." 20 60 + sleep 5 +else + whiptail --msgbox "Failed running firstboot:\n${FAIL_REASON}" 20 60 +fi + +reboot_pi diff --git a/src/modules/rpi_firstb_fix/start_chroot_script b/src/modules/rpi_firstb_fix/start_chroot_script new file mode 100644 index 000000000..281ba3a10 --- /dev/null +++ b/src/modules/rpi_firstb_fix/start_chroot_script @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +#### rpi_firstb_fix module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +#### Description: +#### This is intended to patch behaviour of raspberry's firstboot script. +#### Related to https://github.com/mainsail-crew/MainsailOS/issues/213 + +# shellcheck enable=require-variable-braces +## Source error handling, leave this in place +set -Ee + +# Set DEBIAN_FRONTEND to noninteractive +if [[ "${DEBIAN_FRONTEND}" != "noninteractive" ]]; then + export DEBIAN_FRONTEND=noninteractive +fi + +## Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + +## Step 1: Patch firstboot issue +echo_green "Patch firstboot issue..." +unpack filesystem/root / +## END Step 1 diff --git a/src/version b/src/version index 9084fa2f7..ddfed28e1 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.1.0 +1.1.1-RC1 From aa3a62e5941ec367cf2d210c1f19f38beb481d30 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 26 Mar 2023 11:52:30 +0000 Subject: [PATCH 17/39] chore: push version number to v1.1.1 --- src/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version b/src/version index ddfed28e1..524cb5524 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.1.1-RC1 +1.1.1 From 9db68982dc55aaa7088ca1cce4a41e40d0d4dc6a Mon Sep 17 00:00:00 2001 From: meteyou Date: Sun, 26 Mar 2023 12:46:42 +0000 Subject: [PATCH 18/39] docs(changelog): update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bee22dbc2..5fcc13fd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,8 @@ All notable changes to Mainsail will be documented in this file. - Fix compress step (#205) | [fec2432](fec24320ea4bdcf51c9430e89443035b4ade70f1) - Fix rpi-image.json workflow in Release.yml (#206) | [a03626a](a03626a54a21b1fa1175b458665ae14e9b755037) - Remove enduser support msg from zero2 images (#209) | [4231216](42312164336966b8fabf72618f60216b6a797f04) +- Fix rpi-imager json value format for extract_size & image_download_size (#212) | [b82137c](b82137c14ea09f784478687d32a042c825af8262) +- Fix firstboot issue (#214) | [fae8b3f](fae8b3fd1f9f2b2cf2ca53e737f3862eddd62a36) ### Refactor @@ -63,6 +65,7 @@ All notable changes to Mainsail will be documented in this file. - Deactivate IPv6 in nginx per default (#157) | [40b3719](40b37192608e13b4f5e97b295840715a42974fb6) - Change behavior of piconfig module (#180) | [825af74](825af74061c48043c1ae8390c0825d2220bd623f) - Use mv to move the image from the workspace to the root (#203) | [b7acb1e](b7acb1e49c02d2d9f50dfdc3541c10f4f2b2becc) +- Drop armbian_pkgupgrade (#210) | [799a919](799a919c2c4f2f8bf46971de88a79ab7d0bea137) ### Documentation From 9f093631d22b4cb00cc57601ed55bc51e23e40e0 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 2 Apr 2023 12:35:55 +0200 Subject: [PATCH 19/39] chore: remove unattended-upgrades service (#215) * chore: remove unattended-upgrades service This only applies if service exists and armbian devices. Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index fa4744f51..65b90ac90 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -47,10 +47,10 @@ echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers apt update # shellcheck disable=SC2086 check_install_pkgs ${ARMBIAN_DEPS} +## END Step 1 - -## Step 1: Manage groups +## Step 2: Manage groups ### Substep 1: Create group for gpio usage sudo groupadd gpio ### END Substep 1 @@ -59,18 +59,19 @@ sudo groupadd gpio if_group_exists_run i2c usermod -aG i2c "${BASE_USER}" usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal,gpio "${BASE_USER}" ### END Substep 2 +## END Step 2 -## Step 2: patch sshd_config +## Step 3: patch sshd_config sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config sed -i 's/^X11Forwarding/#X11Forwarding/' /etc/ssh/sshd_config sed -i 's/^#MaxAuthTries 6/MaxAuthTries 3/' /etc/ssh/sshd_config -## END +## END Step 3 ## Step 4: Try patching first login in build stage if [[ -f "/root/.not_logged_in_yet" ]]; then rm -f /root/.not_logged_in_yet fi -## END +## END Step 4 ## Step 5: Move armbian-release to display mainsailos-release ### Substep 1: Move armbian-release @@ -92,7 +93,7 @@ fi sed -i "s|/etc/armbian-release|/etc/armbian-release-info.txt|g" "${f}" done popd &> /dev/null || exit 1 -## END +## END Step 5 ## Step 6: Patch dynamic motd echo_green "Patch dynamic motd ..." @@ -101,7 +102,7 @@ chmod +x /etc/update-motd.d/* if [[ -f "/etc/default/armbian-motd" ]]; then sed -i 's/MOTD_DISABLE=""/MOTD_DISABLE="header"/' /etc/default/armbian-motd fi -## END +## END Step 6 ## Step 7: Enable SPI interface by default echo_green "Enable SPI interface on Orange Pi SBC's ..." @@ -128,4 +129,9 @@ echo "spi-dev" >> "${ARMBIAN_MODULES_FILE}" ### END Substep 3 echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" -## END +## END Step 7 + +## Step 8: Remove unattended-upgrades +echo_green "Remove 'unattended-upgrades' service ..." +sudo apt-get remove --purge --yes unattended-upgrades +## END Step 8 From 6846f82ff311299928824c8bceb606b1db13a444 Mon Sep 17 00:00:00 2001 From: Ash Date: Wed, 12 Apr 2023 17:35:30 +0200 Subject: [PATCH 20/39] fix: load `i2c-dev` modules (#217) This PR adds to #196 with the required bits to enable i2c by default. - enable `i2c-dev` module - install `i2c-tools` package Signed-off-by: ashthespy --- src/modules/piconfig/start_chroot_script | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/modules/piconfig/start_chroot_script b/src/modules/piconfig/start_chroot_script index 7283b474e..483f8adf8 100644 --- a/src/modules/piconfig/start_chroot_script +++ b/src/modules/piconfig/start_chroot_script @@ -32,7 +32,7 @@ cp "${PICONFIG_CONFIG_TXT_FILE}" /tmp mv "${PICONFIG_CONFIG_TXT_FILE}" "${PICONFIG_CONFIG_BAK_FILE}" # Step 4: Concatenate files to config -cat /tmp/config.txt /tmp/msos_config.txt > /tmp/config.new +cat /tmp/config.txt /tmp/msos_config.txt >/tmp/config.new # Step 5: Copy new config to "/boot/config.txt" cp /tmp/config.new "${PICONFIG_CONFIG_TXT_FILE}" @@ -47,13 +47,26 @@ cp "${PICONFIG_CMDLINE_TXT_FILE}" "${PICONFIG_CMDLINE_BAK_FILE}" echo_green "Disable Serial Linux console ..." sed -i 's/console=serial0,115200 //' "${PICONFIG_CMDLINE_TXT_FILE}" -# Step 9: Disable bluetooth and related services +# Step 9: Enable i2c modules +# Also needs corresponding bits in config.txt (see #196) +echo_green "Enabling i2c-dev" +# Enable i2c_bcm2708 is disabled +[[ -f /etc/modprobe.d/raspi-blacklist.conf ]] && sed /etc/modprobe.d/raspi-blacklist.conf -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/" +[[ -f /etc/modules ]] || touch /etc/modules +sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/" # Uncomment i2c_dev +if ! grep -q "^i2c[-_]dev" /etc/modules; then # Add if doesn't exist + printf "i2c-dev\n" >>/etc/modules +fi +# install common i2c helpers +check_install_pkgs i2c-tools + +# Step 10: Disable bluetooth and related services echo_green "Disabling Bluetooth related services..." systemctl_if_exists disable hciuart.service systemctl_if_exists disable bluetooth.service systemctl_if_exists disable bluealsa.service -# Step 10: Increase swapfile size +# Step 11: Increase swapfile size if [[ -f "${PICONFIG_SWAP_CONF_FILE}" ]]; then echo_green "Increasing swap file size to ${PICONFIG_SWAP_SIZE} Mb. Limit to ${PICONFIG_SWAP_MAX} Mb" sed -i 's/^CONF_SWAPSIZE.*/'CONF_SWAPSIZE="${PICONFIG_SWAP_SIZE}"'/' "${PICONFIG_SWAP_CONF_FILE}" From 02e01006c7d1d84efcaee6fb7a64045084ed8667 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sat, 15 Apr 2023 13:46:25 +0200 Subject: [PATCH 21/39] chore: revert firstboot fix (#219) This reverts changes made in #214 as described in #213. Fix is already merged in https://github.com/RPi-Distro/raspberrypi-sys-mods/pull/71 Raspberry hasn't released updated image yet, but should work as we upgrade during build ci. Signed-off-by: Stephan Wendel --- config/raspberry/default | 2 +- src/modules/rpi_firstb_fix/config | 13 - .../usr/lib/raspberrypi-sys-mods/firstboot | 264 ------------------ .../rpi_firstb_fix/start_chroot_script | 32 --- 4 files changed, 1 insertion(+), 310 deletions(-) delete mode 100644 src/modules/rpi_firstb_fix/config delete mode 100755 src/modules/rpi_firstb_fix/filesystem/root/usr/lib/raspberrypi-sys-mods/firstboot delete mode 100644 src/modules/rpi_firstb_fix/start_chroot_script diff --git a/config/raspberry/default b/config/raspberry/default index e43627344..65d8dd99e 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -9,7 +9,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,rpi_firstb_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename" +MODULES="base,pkgupgrade,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename" # export Variables export BASE_IMAGE_ENLARGEROOT diff --git a/src/modules/rpi_firstb_fix/config b/src/modules/rpi_firstb_fix/config deleted file mode 100644 index 82afc5d89..000000000 --- a/src/modules/rpi_firstb_fix/config +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -# Shebang for better file detection -#### rpi_firstb_fix module -#### -#### Written by Stephan Wendel aka KwadFan -#### Copyright 2023 - till today -#### https://github.com/mainsail-crew/MainsailOS -#### -#### This File is distributed under GPLv3 -#### - -# Intentionally left blank -# See start_chroot_script for information diff --git a/src/modules/rpi_firstb_fix/filesystem/root/usr/lib/raspberrypi-sys-mods/firstboot b/src/modules/rpi_firstb_fix/filesystem/root/usr/lib/raspberrypi-sys-mods/firstboot deleted file mode 100755 index bd1a1f87e..000000000 --- a/src/modules/rpi_firstb_fix/filesystem/root/usr/lib/raspberrypi-sys-mods/firstboot +++ /dev/null @@ -1,264 +0,0 @@ -#!/bin/bash -# shellcheck disable=all - - -reboot_pi () { - umount /boot - mount / -o remount,ro - sync - if [ "$NOOBS" = "1" ]; then - if [ "$NEW_KERNEL" = "1" ]; then - reboot -f "$BOOT_PART_NUM" - sleep 5 - else - echo "$BOOT_PART_NUM" > "/sys/module/${BCM_MODULE}/parameters/reboot_part" - fi - fi - reboot -f - sleep 5 - exit 0 -} - -check_noobs () { - if [ "$BOOT_PART_NUM" = "1" ]; then - NOOBS=0 - else - NOOBS=1 - fi -} - -get_variables () { - ROOT_PART_DEV=$(findmnt / -o source -n) - ROOT_PART_NAME=$(echo "$ROOT_PART_DEV" | cut -d "/" -f 3) - ROOT_DEV_NAME=$(echo /sys/block/*/"${ROOT_PART_NAME}" | cut -d "/" -f 4) - ROOT_DEV="/dev/${ROOT_DEV_NAME}" - ROOT_PART_NUM=$(cat "/sys/block/${ROOT_DEV_NAME}/${ROOT_PART_NAME}/partition") - - BOOT_PART_DEV=$(findmnt /boot -o source -n) - BOOT_PART_NAME=$(echo "$BOOT_PART_DEV" | cut -d "/" -f 3) - BOOT_DEV_NAME=$(echo /sys/block/*/"${BOOT_PART_NAME}" | cut -d "/" -f 4) - BOOT_PART_NUM=$(cat "/sys/block/${BOOT_DEV_NAME}/${BOOT_PART_NAME}/partition") - - OLD_DISKID=$(fdisk -l "$ROOT_DEV" | sed -n 's/Disk identifier: 0x\([^ ]*\)/\1/p') - - check_noobs - - ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size") - TARGET_END=$((ROOT_DEV_SIZE - 1)) - - PARTITION_TABLE=$(parted -m "$ROOT_DEV" unit s print | tr -d 's') - - LAST_PART_NUM=$(echo "$PARTITION_TABLE" | tail -n 1 | cut -d ":" -f 1) - - ROOT_PART_LINE=$(echo "$PARTITION_TABLE" | grep -e "^${ROOT_PART_NUM}:") - ROOT_PART_START=$(echo "$ROOT_PART_LINE" | cut -d ":" -f 2) - ROOT_PART_END=$(echo "$ROOT_PART_LINE" | cut -d ":" -f 3) - - if [ "$NOOBS" = "1" ]; then - EXT_PART_LINE=$(echo "$PARTITION_TABLE" | grep ":::;" | head -n 1) - EXT_PART_NUM=$(echo "$EXT_PART_LINE" | cut -d ":" -f 1) - EXT_PART_START=$(echo "$EXT_PART_LINE" | cut -d ":" -f 2) - EXT_PART_END=$(echo "$EXT_PART_LINE" | cut -d ":" -f 3) - fi -} - -fix_partuuid() { - mount -o remount,rw "$ROOT_PART_DEV" - mount -o remount,rw "$BOOT_PART_DEV" - MAJOR="$(uname -r | cut -f1 -d.)" - if [[ "$MAJOR" -eq "6" ]] && [[ -c /dev/hwrng ]]; then - dd if=/dev/hwrng of=/dev/urandom count=1 bs=256 status=none - fi - DISKID="$(tr -dc 'a-f0-9' < /dev/urandom | dd bs=1 count=8 2>/dev/null)" - fdisk "$ROOT_DEV" > /dev/null < /dev/null 2>&1 - RET="$?" - if [ "$RET" -ne 0 ]; then - FAIL_REASON="Root partition resize failed\n$FAIL_REASON" - fi - - mount -o remount,ro / - return "$RET" -} - -regenerate_ssh_host_keys () { - mount -o remount,rw / - /usr/lib/raspberrypi-sys-mods/regenerate_ssh_host_keys - RET="$?" - mount -o remount,ro / - return "$RET" -} - -apply_custom () { - CONFIG_FILE="$1" - mount -o remount,rw / - mount -o remount,rw /boot - if ! python3 -c "import toml" 2> /dev/null; then - FAIL_REASON="custom.toml provided, but python3-toml is not installed\n$FAIL_REASON" - else - set -o pipefail - /usr/lib/raspberrypi-sys-mods/init_config "$CONFIG_FILE" |& tee /run/firstboot.log | while read -r line; do - MSG="$MSG\n$line" - whiptail --infobox "$MSG" 20 60 - done - if [ "$?" -ne 0 ]; then - mv /run/firstboot.log /var/log/firstboot.log - FAIL_REASON="Failed to apply customisations from custom.toml\n\nLog file saved as /var/log/firstboot.log\n$FAIL_REASON" - fi - set +o pipefail - fi - rm -f "$CONFIG_FILE" - mount -o remount,ro /boot - mount -o remount,ro / -} - -main () { - get_variables - - if check_variables; then - do_resize - fi - - # Switch to dhcpcd here if Imager < v1.7.3 was used to generate firstrun.sh - fix_wpa > /dev/null 2>&1 - - whiptail --infobox "Generating SSH keys..." 20 60 - regenerate_ssh_host_keys - - if [ -f "/boot/custom.toml" ]; then - MSG="Applying customisations from custom.toml...\n" - whiptail --infobox "$MSG" 20 60 - apply_custom "/boot/custom.toml" - fi - - whiptail --infobox "Fix PARTUUID..." 20 60 - fix_partuuid - - return 0 -} - -mount -t proc proc /proc -mount -t sysfs sys /sys -mount -t tmpfs tmp /run -mkdir -p /run/systemd - -mount /boot -mount / -o remount,ro - -sed -i 's| init=/usr/lib/raspberrypi-sys-mods/firstboot||' /boot/cmdline.txt -sed -i 's| sdhci\.debug_quirks2=4||' /boot/cmdline.txt - -if ! grep -q splash /boot/cmdline.txt; then - sed -i "s/ quiet//g" /boot/cmdline.txt -fi -mount /boot -o remount,ro -sync - -main - -if [ -z "$FAIL_REASON" ]; then - whiptail --infobox "Rebooting in 5 seconds..." 20 60 - sleep 5 -else - whiptail --msgbox "Failed running firstboot:\n${FAIL_REASON}" 20 60 -fi - -reboot_pi diff --git a/src/modules/rpi_firstb_fix/start_chroot_script b/src/modules/rpi_firstb_fix/start_chroot_script deleted file mode 100644 index 281ba3a10..000000000 --- a/src/modules/rpi_firstb_fix/start_chroot_script +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -#### rpi_firstb_fix module -#### -#### Written by Stephan Wendel aka KwadFan -#### Copyright 2023 - till today -#### https://github.com/mainsail-crew/MainsailOS -#### -#### This File is distributed under GPLv3 -#### - -#### Description: -#### This is intended to patch behaviour of raspberry's firstboot script. -#### Related to https://github.com/mainsail-crew/MainsailOS/issues/213 - -# shellcheck enable=require-variable-braces -## Source error handling, leave this in place -set -Ee - -# Set DEBIAN_FRONTEND to noninteractive -if [[ "${DEBIAN_FRONTEND}" != "noninteractive" ]]; then - export DEBIAN_FRONTEND=noninteractive -fi - -## Source CustomPIOS common.sh -# shellcheck disable=SC1091 -source /common.sh -install_cleanup_trap - -## Step 1: Patch firstboot issue -echo_green "Patch firstboot issue..." -unpack filesystem/root / -## END Step 1 From b07d7a103a2aad81045c26dc7223c26369ee1322 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 21 May 2023 18:31:11 +0200 Subject: [PATCH 22/39] fix: fix broken udev package (#224) * fix: fix broken udev package Signed-off-by: Stephan Wendel * chore: add patch script Includes updated patches/README.md Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- config/orangepi/default | 2 +- config/raspberry/default | 2 +- patches/Readme.md | 40 ++++++++- patches/{patch.sh => patch101.sh} | 2 +- patches/udev-fix.sh | 104 +++++++++++++++++++++++ src/modules/udev_fix/config | 20 +++++ src/modules/udev_fix/start_chroot_script | 47 ++++++++++ 8 files changed, 214 insertions(+), 5 deletions(-) rename patches/{patch.sh => patch101.sh} (98%) create mode 100755 patches/udev-fix.sh create mode 100644 src/modules/udev_fix/config create mode 100644 src/modules/udev_fix/start_chroot_script diff --git a/config/armbian/default b/config/armbian/default index 1a9e655d9..f05c136fa 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,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,udev_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL diff --git a/config/orangepi/default b/config/orangepi/default index 96a23ebbb..8cfe3ad87 100644 --- a/config/orangepi/default +++ b/config/orangepi/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,orangepi(orangepi_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,pkgupgrade,udev_fix,orangepi(orangepi_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL diff --git a/config/raspberry/default b/config/raspberry/default index 65d8dd99e..8799084d3 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -9,7 +9,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,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" # export Variables export BASE_IMAGE_ENLARGEROOT diff --git a/patches/Readme.md b/patches/Readme.md index a7c2e15dd..e79ae216a 100644 --- a/patches/Readme.md +++ b/patches/Readme.md @@ -2,10 +2,48 @@ This Folder contains a script to patch MainsailOS to latest changes. -## Usage +## patch101.sh + +This is intended to patch MainsailOS version 1.0.0 to 1.0.1 +This fixes an error with WiFi powersave rules. +_**DO NOT RUN THIS ON LATER VERSIONS!!!**_ + +### Usage: `curl -sSL https://raw.githubusercontent.com/mainsail-crew/MainsailOS/develop/patches/patch.sh | bash` This will ask you for sudo password! In most cases a reboot is required! + +## udev-fix.sh + +This is intended to patch udev rules which has a Bug in udev package (version: 247.3-7+deb11u2). +Which does not create `/dev/serial/by-id` symlinks for your MCU.\ +For further details see: + +https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1035094 + +This is fixed by: +https://github.com/systemd/systemd/pull/25246 + +What we do: + +- Running `apt-get update` +- Running `apt-get upgrade --yes` +- `curl`ing the patched rule file from systemd repo +- Copying to desired location in `/etc/udev/rules.d/60-serial.rules` + +This overwrites behaviour in the default configuration. +Since this is the version of the master branch of systemd/udev there is no further +need to intervention even on updates. + +_**NOTE: DO NOT RUN THIS PATCH IF YOU ARE PRINTING!!!**_ + +### Usage: + +`curl -sSL https://raw.githubusercontent.com/mainsail-crew/MainsailOS/develop/patches/udev-fix.sh | bash` + +This will ask you for sudo password! + +A reboot is essential! diff --git a/patches/patch.sh b/patches/patch101.sh similarity index 98% rename from patches/patch.sh rename to patches/patch101.sh index 486c785ca..8c5c671d6 100755 --- a/patches/patch.sh +++ b/patches/patch101.sh @@ -5,7 +5,7 @@ #### #### Written by Stephan Wendel aka KwadFan #### Copyright 2021 -#### https://github.com/mainsail-crew/crowsnest +#### https://github.com/mainsail-crew/MainsailOS #### #### This File is distributed under GPLv3 #### diff --git a/patches/udev-fix.sh b/patches/udev-fix.sh new file mode 100755 index 000000000..462be9b15 --- /dev/null +++ b/patches/udev-fix.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash + +#### Patch Script +#### This will patch MainsailOS udev rule +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2021 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +#### This should fix error in udev not creating symlinks fpr serial devices. +#### For details see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1035094 +#### This is fixed by: https://github.com/systemd/systemd/pull/25246 +#### To fix this error in MainsailOS we implement that file as 'user rule'. + +# shellcheck disable=SC2034 + +# Error Handling +set -eo pipefail + +# Debug +# set -x + +### Variables +DEBIAN_FRONTEND="noninteractive" +TITLE="\e[31mMainsailOS Patcher\e[0m - udev rule fix" +UDEV_PKG_VERSION="$(dpkg-query -s udev | grep "Version" | sed 's/Version\: //')" +UDEV_FIX_RAW_RULE_FILE="https://raw.githubusercontent.com/systemd/systemd/main/rules.d/60-serial.rules" +UDEV_FIX_TMP_FILE="/tmp/60-serial.rules" +UDEV_FIX_OUTPUT_FILE="/etc/udev/rules.d/60-serial.rules" + +# Message Vars +MP_OK="\e[32mOK\e[0m" +MP_SK="\e[33mSKIPPED\e[0m" + +## Helper funcs + +## Message Funcs + +echo_green(){ + echo -e "\e[32m${1}\e[0m" +} + +echo_red(){ + echo -e "\e[31m${1}\e[0m" +} + +echo_blue(){ + echo -e "\e[34m${1}\e[0m" +} + +echo_yellow(){ + echo -e "\e[33m${1}\e[0m" +} + +print_header(){ + echo -e "${TITLE}\n" + echo_blue "Ahoi!" + echo -e "Please be patient, this might take a while ..." + echo_yellow "HINT: This should also work for any other Debian/Armbian based Distribution\n" + echo_red "\tYou'll be prompted for sudo password!\n" + # Dirty hack to grant root priviledges + sudo echo -e "\n" + echo -e "Trying to patch your system ..." +} + +print_footer(){ + echo -e "\nThank you for being patient ..." + echo_red "Reboot as soon as possible!\n" +} + +# Patch Funcs + +patch_udev(){ + if [[ -n "${UDEV_PKG_VERSION}" ]] && [[ "${UDEV_PKG_VERSION}" = "247.3-7+deb11u2" ]]; then + echo_red "'udev' version: ${UDEV_PKG_VERSION}, is affected by bug ..." + echo_green "Install patched udev rule from systemd git repository ..." + curl -sSL "${UDEV_FIX_RAW_RULE_FILE}" > "${UDEV_FIX_TMP_FILE}" + sudo cp "${UDEV_FIX_TMP_FILE}" "${UDEV_FIX_OUTPUT_FILE}" + rm -f "${UDEV_FIX_TMP_FILE}" + else + echo_green "'udev' version: ${UDEV_PKG_VERSION}, is NOT affected by bug ... [SKIPPED]" + fi +} + +### Main +# Step 1: Print Header +print_header + +# Step 2: Run apt-get update +sudo apt-get update + +# Step 3: Run apt-get upgrade +sudo apt-get upgrade --yes + +# Step 4: Apply patches +patch_udev + +# Step 5: Print footer +print_footer + +exit 0 diff --git a/src/modules/udev_fix/config b/src/modules/udev_fix/config new file mode 100644 index 000000000..1be59fb30 --- /dev/null +++ b/src/modules/udev_fix/config @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +#### MainsailOS udev_fix +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +#### This should fix error in udev not creating symlinks fpr serial devices. +#### For details see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1035094 +#### This is fixed by: https://github.com/systemd/systemd/pull/25246 +#### To fix this error in MainsailOS we implement that file as 'user rule'. + +#shellcheck disable=all + +[[ -n "${UDEV_FIX_RAW_RULE_FILE}" ]] || UDEV_FIX_RAW_RULE_FILE="https://raw.githubusercontent.com/systemd/systemd/main/rules.d/60-serial.rules" +[[ -n "${UDEV_FIX_OUTPUT_FILE}" ]] || UDEV_FIX_OUTPUT_FILE="/etc/udev/rules.d/60-serial.rules" +[[ -n "${UDEV_FIX_PKGS}" ]] || UDEV_FIX_PKGS="systemd udev" diff --git a/src/modules/udev_fix/start_chroot_script b/src/modules/udev_fix/start_chroot_script new file mode 100644 index 000000000..d1e141ef1 --- /dev/null +++ b/src/modules/udev_fix/start_chroot_script @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +#### MainsailOS MainsailOS udev_fix +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2023 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +#### This should fix error in udev not creating symlinks fpr serial devices. +#### For details see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1035094 +#### This is fixed by: https://github.com/systemd/systemd/pull/25246 +#### To fix this error in MainsailOS we implement that file as 'user rule'. + +# shellcheck enable=require-variable-braces +# Source error handling, leave this in place +set -Ee + +# Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + + +echo_green "Running 'udev' fix ..." + +# Step 1: Ensure systemd, udev are up to date (armbian workaround) +if [[ -f /etc/armbian.txt ]]; then + echo_green "Armbian base image detected ..." + echo_green "Updating ${UDEV_FIX_PKGS} first ..." + apt-get update + # Disable shellcheck here, because we need 'word splitting' + # shellcheck disable=SC2086 + apt-get --yes install --only-upgrade ${UDEV_FIX_PKGS} +fi + +# Step 2: Fix broken udev (remove after debian releases patch) +UDEV_PKG_VERSION="$(dpkg-query -s udev | grep "Version" | sed 's/Version\: //')" + +if [[ -n "${UDEV_PKG_VERSION}" ]] && [[ "${UDEV_PKG_VERSION}" = "247.3-7+deb11u2" ]]; then + echo_red "'udev' version: ${UDEV_PKG_VERSION}, is affected by bug ..." + echo_green "Install patched udev rule from systemd git repository ..." + curl -sSL "${UDEV_FIX_RAW_RULE_FILE}" > "${UDEV_FIX_OUTPUT_FILE}" +else + echo_green "'udev' version: ${UDEV_PKG_VERSION}, is NOT affected by bug ... [SKIPPED]" +fi From 726239ca7db82c3867af3c28785cae0ca7b2e3eb Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Tue, 23 May 2023 16:07:55 +0200 Subject: [PATCH 23/39] chore: update crowsnest module (#221) * chore: update crowsnest module According to changes in installer, update crowsnest module for camera-streamer version. Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel --- config/raspberry/default | 2 +- src/modules/crowsnest/config | 7 +++++-- src/modules/crowsnest/start_chroot_script | 21 ++++++++++++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/config/raspberry/default b/config/raspberry/default index 8799084d3..7ec32ad79 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=3000 +BASE_IMAGE_ENLARGEROOT=4500 BASE_IMAGE_RESIZEROOT=600 # Compress not needed due compression done in workflow BASE_RELEASE_COMPRESS=no diff --git a/src/modules/crowsnest/config b/src/modules/crowsnest/config index ba0afbf64..85b096a1e 100644 --- a/src/modules/crowsnest/config +++ b/src/modules/crowsnest/config @@ -2,7 +2,7 @@ #### crowsnest - A webcam Service for multiple Cams and Stream Services. #### #### Written by Stephan Wendel aka KwadFan -#### Copyright 2021 - 2022 +#### Copyright 2021 - till today #### https://github.com/mainsail-crew/crowsnest #### #### This File is distributed under GPLv3 @@ -18,7 +18,6 @@ [[ -n "$CROWSNEST_CONFIG_PATH" ]] || CROWSNEST_CONFIG_PATH="/home/${BASE_USER}/printer_data/config" [[ -n "$CROWSNEST_LOG_PATH" ]] || CROWSNEST_LOG_PATH="/home/${BASE_USER}/printer_data/logs" [[ -n "$CROWSNEST_ENV_PATH" ]] || CROWSNEST_ENV_PATH="/home/${BASE_USER}/printer_data/systemd" -[[ -n "$CROWSNEST_RASPICAMFIX" ]] || CROWSNEST_RASPICAMFIX="1" [[ -n "$CROWSNEST_ADD_CROWSNEST_MOONRAKER" ]] || CROWSNEST_ADD_CROWSNEST_MOONRAKER="1" [[ -n "$CROWSNEST_MOONRAKER_CONF_PATH" ]] || CROWSNEST_MOONRAKER_CONF_PATH="/home/${BASE_USER}/printer_data/config/moonraker.conf" @@ -27,6 +26,10 @@ [[ -n "$CROWSNEST_USTREAMER_REPO_SHIP" ]] || CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/pikvm/ustreamer.git" [[ -n "$CROWSNEST_USTREAMER_REPO_BRANCH" ]] || CROWSNEST_USTREAMER_REPO_BRANCH="master" +# camera-streamer +[[ -n "$CROWSNEST_CAMERA_STREAMER_REPO_SHIP" ]] || CROWSNEST_CAMERA_STREAMER_REPO_SHIP="https://github.com/ayufan/camera-streamer.git" +[[ -n "$CROWSNEST_CAMERA_STREAMER_REPO_BRANCH" ]] || CROWSNEST_CAMERA_STREAMER_REPO_BRANCH="master" + ########################################################################### ### DO NOT EDIT BELOW THIS LINE, UNLESS YOU KNOW EXACTLY WHAT HAPPENDS! ### ########################################################################### diff --git a/src/modules/crowsnest/start_chroot_script b/src/modules/crowsnest/start_chroot_script index 9631f7e81..7da29599c 100644 --- a/src/modules/crowsnest/start_chroot_script +++ b/src/modules/crowsnest/start_chroot_script @@ -20,7 +20,25 @@ install_cleanup_trap # Module only Variables CN_BUILD_PACKAGE_FILE="/tmp/cn_packages.lst" -CN_BUILD_INSTALL_SH="/home/${BASE_USER}/crowsnest/tools/install.sh" + +# Helper Func +is_raspbian() { + if [[ -f /boot/config.txt ]] && [[ -f /etc/rpi-issue ]]; then + echo "1" + else + echo "0" + fi +} + +get_pkglist() { + if [[ "$(is_raspbian)" = "1" ]]; then + CN_BUILD_INSTALL_SH="/home/${BASE_USER}/crowsnest/tools/libs/pkglist-rpi.sh" + fi + if [[ "$(is_raspbian)" = "0" ]]; then + CN_BUILD_INSTALL_SH="/home/${BASE_USER}/crowsnest/tools/libs/pkglist-generic.sh" + fi +} + echo_green "Installing crowsnest ..." @@ -38,6 +56,7 @@ gitclone CROWSNEST_REPO crowsnest ## Step 3: grep PKGLIST from install.sh for dependencies echo_green "Generating packages file ..." +get_pkglist grep "PKGLIST=" "${CN_BUILD_INSTALL_SH}" >> "${CN_BUILD_PACKAGE_FILE}" ## Step 4: Rename PKGLIST to Module usable Var From b0343d55ddb9db0126f4fb9759e050d5fbcbb10e Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Tue, 23 May 2023 20:11:27 +0200 Subject: [PATCH 24/39] fix: fix udev for version 'rp1+deb11u2' (#226) This is needed to also patch if version is from raspberry which is named '247.3-7+rpi1+deb11u2' Signed-off-by: Stephan Wendel --- patches/Readme.md | 4 ++-- patches/udev-fix.sh | 2 +- src/modules/udev_fix/start_chroot_script | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/Readme.md b/patches/Readme.md index e79ae216a..b50cda1d8 100644 --- a/patches/Readme.md +++ b/patches/Readme.md @@ -10,7 +10,7 @@ _**DO NOT RUN THIS ON LATER VERSIONS!!!**_ ### Usage: -`curl -sSL https://raw.githubusercontent.com/mainsail-crew/MainsailOS/develop/patches/patch.sh | bash` +`curl -sSL https://raw.githubusercontent.com/mainsail-crew/MainsailOS/develop/patches/patch101.sh | bash` This will ask you for sudo password! @@ -18,7 +18,7 @@ In most cases a reboot is required! ## udev-fix.sh -This is intended to patch udev rules which has a Bug in udev package (version: 247.3-7+deb11u2). +This is intended to patch udev rules which has a Bug in udev package (version: 247.3-7+deb11u2 or 247.3-7+rpi1+deb11u2). Which does not create `/dev/serial/by-id` symlinks for your MCU.\ For further details see: diff --git a/patches/udev-fix.sh b/patches/udev-fix.sh index 462be9b15..01c1cb56b 100755 --- a/patches/udev-fix.sh +++ b/patches/udev-fix.sh @@ -74,7 +74,7 @@ print_footer(){ # Patch Funcs patch_udev(){ - if [[ -n "${UDEV_PKG_VERSION}" ]] && [[ "${UDEV_PKG_VERSION}" = "247.3-7+deb11u2" ]]; then + if [[ -n "${UDEV_PKG_VERSION}" ]] && [[ "${UDEV_PKG_VERSION}" =~ "deb11u2" ]]; then echo_red "'udev' version: ${UDEV_PKG_VERSION}, is affected by bug ..." echo_green "Install patched udev rule from systemd git repository ..." curl -sSL "${UDEV_FIX_RAW_RULE_FILE}" > "${UDEV_FIX_TMP_FILE}" diff --git a/src/modules/udev_fix/start_chroot_script b/src/modules/udev_fix/start_chroot_script index d1e141ef1..83e762581 100644 --- a/src/modules/udev_fix/start_chroot_script +++ b/src/modules/udev_fix/start_chroot_script @@ -38,7 +38,7 @@ fi # Step 2: Fix broken udev (remove after debian releases patch) UDEV_PKG_VERSION="$(dpkg-query -s udev | grep "Version" | sed 's/Version\: //')" -if [[ -n "${UDEV_PKG_VERSION}" ]] && [[ "${UDEV_PKG_VERSION}" = "247.3-7+deb11u2" ]]; then +if [[ -n "${UDEV_PKG_VERSION}" ]] && [[ "${UDEV_PKG_VERSION}" =~ "deb11u2" ]]; then echo_red "'udev' version: ${UDEV_PKG_VERSION}, is affected by bug ..." echo_green "Install patched udev rule from systemd git repository ..." curl -sSL "${UDEV_FIX_RAW_RULE_FILE}" > "${UDEV_FIX_OUTPUT_FILE}" From 991cfcda5d6bb1257ba93faa6b29f1dc14ae870c Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 23 May 2023 18:24:31 +0000 Subject: [PATCH 25/39] chore: push version number to v1.2.0 --- src/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version b/src/version index 524cb5524..26aaba0e8 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.1.1 +1.2.0 From e8da3042daaa068c301fdb395ec165396c6ad990 Mon Sep 17 00:00:00 2001 From: meteyou Date: Tue, 23 May 2023 19:32:04 +0000 Subject: [PATCH 26/39] docs(changelog): update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fcc13fd3..fbbcd9a61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,9 @@ All notable changes to Mainsail will be documented in this file. - Remove enduser support msg from zero2 images (#209) | [4231216](42312164336966b8fabf72618f60216b6a797f04) - Fix rpi-imager json value format for extract_size & image_download_size (#212) | [b82137c](b82137c14ea09f784478687d32a042c825af8262) - Fix firstboot issue (#214) | [fae8b3f](fae8b3fd1f9f2b2cf2ca53e737f3862eddd62a36) +- Load `i2c-dev` modules (#217) | [6846f82](6846f82ff311299928824c8bceb606b1db13a444) +- Fix broken udev package (#224) | [b07d7a1](b07d7a103a2aad81045c26dc7223c26369ee1322) +- Fix udev for version 'rp1+deb11u2' (#226) | [b0343d5](b0343d55ddb9db0126f4fb9759e050d5fbcbb10e) ### Refactor @@ -115,4 +118,7 @@ All notable changes to Mainsail will be documented in this file. - Add "not-on-Github" bot for issues (#179) | [68520ce](68520ce40659e223d8c79820a7eda4923d9ae02d) - Fix changelog in release workflow (#182) | [32f9429](32f9429d49671e5657c7ed5143ca63e88046f364) - Removes fkms overlays (#183) | [999183b](999183bef6b290efcd8d4f2c8d708354152d411c) +- Remove unattended-upgrades service (#215) | [9f09363](9f093631d22b4cb00cc57601ed55bc51e23e40e0) +- Revert firstboot fix (#219) | [02e0100](02e01006c7d1d84efcaee6fb7a64045084ed8667) +- Update crowsnest module (#221) | [726239c](726239ca7db82c3867af3c28785cae0ca7b2e3eb) From 8c65ad7045bf2ada360b0f1307f599aea73d7d4f Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 26 May 2023 08:04:26 +0200 Subject: [PATCH 27/39] fix: remove legacy cam stack (#227) --- src/modules/piconfig/filesystem/tmp/msos_config.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/modules/piconfig/filesystem/tmp/msos_config.txt b/src/modules/piconfig/filesystem/tmp/msos_config.txt index e784214cc..f21e3e879 100644 --- a/src/modules/piconfig/filesystem/tmp/msos_config.txt +++ b/src/modules/piconfig/filesystem/tmp/msos_config.txt @@ -52,12 +52,6 @@ dtoverlay=disable-bt ## dtparam=i2c_arm=on,i2c_arm_baudrate=400000 dtparam=i2c_arm=on -## Disable libcamera (interferes with ustreamer, when using raspicams) -camera_auto_detect=0 - -## Enable VideoCore at boot, needed for Crowsnest (Raspicams and DSI devices). -start_x=1 - ### EXPERIMENTAL - Enable 64bit Kernel ### The 64-bit kernel will only work on: From 4bbc8e119466018c85bf40fb08f2693babb49fc5 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 26 May 2023 06:07:25 +0000 Subject: [PATCH 28/39] chore: push version number to v1.2.1 --- src/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version b/src/version index 26aaba0e8..6085e9465 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.2.0 +1.2.1 From 267db84837ff1ae9c78d2eab664393f1cc3ba185 Mon Sep 17 00:00:00 2001 From: meteyou Date: Fri, 26 May 2023 07:00:53 +0000 Subject: [PATCH 29/39] docs(changelog): update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbbcd9a61..3810531fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ All notable changes to Mainsail will be documented in this file. - Load `i2c-dev` modules (#217) | [6846f82](6846f82ff311299928824c8bceb606b1db13a444) - Fix broken udev package (#224) | [b07d7a1](b07d7a103a2aad81045c26dc7223c26369ee1322) - Fix udev for version 'rp1+deb11u2' (#226) | [b0343d5](b0343d55ddb9db0126f4fb9759e050d5fbcbb10e) +- Remove legacy cam stack (#227) | [8c65ad7](8c65ad7045bf2ada360b0f1307f599aea73d7d4f) ### Refactor From 332109ae2fa928d3728cb388ddea4e121f9977e4 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 26 May 2023 20:24:36 +0200 Subject: [PATCH 30/39] fix: fix error in udev-fix.sh (#228) --- patches/udev-fix.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/patches/udev-fix.sh b/patches/udev-fix.sh index 01c1cb56b..2084d9756 100755 --- a/patches/udev-fix.sh +++ b/patches/udev-fix.sh @@ -26,7 +26,6 @@ set -eo pipefail ### Variables DEBIAN_FRONTEND="noninteractive" TITLE="\e[31mMainsailOS Patcher\e[0m - udev rule fix" -UDEV_PKG_VERSION="$(dpkg-query -s udev | grep "Version" | sed 's/Version\: //')" UDEV_FIX_RAW_RULE_FILE="https://raw.githubusercontent.com/systemd/systemd/main/rules.d/60-serial.rules" UDEV_FIX_TMP_FILE="/tmp/60-serial.rules" UDEV_FIX_OUTPUT_FILE="/etc/udev/rules.d/60-serial.rules" @@ -74,14 +73,17 @@ print_footer(){ # Patch Funcs patch_udev(){ - if [[ -n "${UDEV_PKG_VERSION}" ]] && [[ "${UDEV_PKG_VERSION}" =~ "deb11u2" ]]; then - echo_red "'udev' version: ${UDEV_PKG_VERSION}, is affected by bug ..." + local udev_pkg_version + udev_pkg_version="$(dpkg-query -s udev | grep "Version" | sed 's/Version\: //')" + + if [[ -n "${udev_pkg_version}" ]] && [[ "${udev_pkg_version}" =~ "deb11u2" ]]; then + echo_red "'udev' version: ${udev_pkg_version}, is affected by bug ..." echo_green "Install patched udev rule from systemd git repository ..." curl -sSL "${UDEV_FIX_RAW_RULE_FILE}" > "${UDEV_FIX_TMP_FILE}" sudo cp "${UDEV_FIX_TMP_FILE}" "${UDEV_FIX_OUTPUT_FILE}" rm -f "${UDEV_FIX_TMP_FILE}" else - echo_green "'udev' version: ${UDEV_PKG_VERSION}, is NOT affected by bug ... [SKIPPED]" + echo_green "'udev' version: ${udev_pkg_version}, is NOT affected by bug ... [SKIPPED]" fi } From ba3d5824c6cf05e0c557c40348da75098015f16d Mon Sep 17 00:00:00 2001 From: Rogerio Goncalves Date: Thu, 1 Jun 2023 12:12:00 +0100 Subject: [PATCH 31/39] docs: fix broken README link to the docs (#231) --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1eccb7e80..cf070d152 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Learn more about: ## How to install MainsailOS ? -You can find detailed instructions in our [documentation](https://docs.mainsail.xyz/setup/mainsail-os). +You can find detailed instructions in our [documentation](https://docs-os.mainsail.xyz). -We recommend the installation via [Raspberry Pi Imager](https://docs.mainsail.xyz/setup/mainsailos/pi-imager). +We recommend the installation via [Raspberry Pi Imager](https://docs-os.mainsail.xyz/getting-started/raspberry-pi-os-based). ## How to get help? @@ -34,9 +34,9 @@ Also see the [FAQ](#faq) section. Here a list of included and preinstalled Software: -- [Klipper (3D Printer Firmware)](https://github.com/KevinOConnor/klipper) +- [Klipper (3D Printer Firmware)](https://github.com/Klipper3d/klipper) - [Moonraker (API Web Server for Klipper)](https://github.com/Arksine/moonraker) -- [Mainsail (Web interface for Klipper/Moonraker)](https://github.com/meteyou/mainsail) +- [Mainsail (Web interface for Klipper/Moonraker)](https://github.com/mainsail-crew/mainsail) - [Crowsnest (Webcam streaming)](https://github.com/mainsail-crew/crowsnest) - [Sonar (Keepalive daemon)](https://github.com/mainsail-crew/sonar) - [Nginx (Webserver & Proxy)](https://nginx.org/en/) From 417ed1f1d8ebd5950931dca2b5a04ef412e67035 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Mon, 7 Aug 2023 17:22:43 +0200 Subject: [PATCH 32/39] chore: update download urls for armbian & orangepi (#233) Signed-off-by: Stefan Dej --- config/armbian/orangepi3lts | 4 ++-- config/armbian/orangepi4lts | 4 ++-- config/orangepi/orangepi_zero2 | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/armbian/orangepi3lts b/config/armbian/orangepi3lts index 46ea21610..8fd06d0a1 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.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts.img.xz" +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" # export Variables export BASE_ARCH diff --git a/config/armbian/orangepi4lts b/config/armbian/orangepi4lts index f68c354df..5b0a312c8 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.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts.img.xz" +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 diff --git a/config/orangepi/orangepi_zero2 b/config/orangepi/orangepi_zero2 index 1ad1c1d18..c149d83f2 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.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2.img.xz" +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" # export Variables export BASE_ARCH From 7084fd807b4ccf40cef9335e0bed263f018d2e00 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Fri, 11 Aug 2023 18:27:06 +0200 Subject: [PATCH 33/39] fix: add crowsnest log path & pkglist link in postrename script (#235) * fix: add crowsnest log path to postrename script Signed-off-by: Stefan Dej * fix: fix crowsnest pkglist sym link in postrename Signed-off-by: Stefan Dej --------- Signed-off-by: Stefan Dej --- .../postrename/filesystem/root/postrename | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/modules/postrename/filesystem/root/postrename b/src/modules/postrename/filesystem/root/postrename index ea43dc156..4aa394ef8 100644 --- a/src/modules/postrename/filesystem/root/postrename +++ b/src/modules/postrename/filesystem/root/postrename @@ -64,7 +64,6 @@ change_www_root() { " } - ### change username in service files change_service_user() { ### Filter nginx service first! @@ -119,6 +118,13 @@ patch_polkit_rules() { fi } +patch_cn_logpath() { + bash -c " + sed -i 's|/home/pi/printer_data/logs/crowsnest.log|/home/${DEFAULT_USER}/printer_data/logs/crowsnest.log|g' \ + /home/${DEFAULT_USER}/printer_data/config/crowsnest.conf + " +} + patch_cn_logrotate() { if [[ -f "/etc/logrotate.d/crowsnest" ]]; then sed -i 's/pi/'"${DEFAULT_USER}"'/g' "/etc/logrotate.d/crowsnest" @@ -160,6 +166,13 @@ fix_mainsailcfg_links() { ln -sf "${src_dir}/mainsail.cfg" "${config_dir}/mainsail.cfg" } +fix_cn_links() { + local tools_dir + tools_dir="/home/${DEFAULT_USER}/crowsnest/tools/" + sudo -u "${DEFAULT_USER}" \ + ln -sf "${tools_dir}/libs/pkglist-rpi.sh" "${tools_dir}/pkglist.sh" +} + main() { local cmdltxt cmdltxt="/boot/cmdline.txt" @@ -205,6 +218,10 @@ echo -e "${WHITE}Trying to relocate venv's ...${NOC}[${GRE}OK${NOC}]" echo -e "${WHITE}Patching moonraker's polkit rules ...${NOC}" patch_polkit_rules echo -e "${WHITE}Patching moonraker's polkit rules ...${NOC}[${GRE}OK${NOC}]" +## patch crownsnest log path +echo -en "${WHITE}Patching crowsnest logpath ...${NOC}\r" +patch_cn_logpath +echo -e "${WHITE}Patching crowsnest logpath ...${NOC}[${GRE}OK${NOC}]" ## patch crowsnest logrotate echo -e "${WHITE}Patching crowsnest logrotate ...${NOC}" patch_cn_logrotate @@ -214,6 +231,7 @@ echo -en "${WHITE}Fix broken symlinks ...${NOC}\r" fix_broken_links fix_timelapse_links fix_mainsailcfg_links +fix_cn_links echo -e "${WHITE}Fix broken symlinks ...${NOC}[${GRE}OK${NOC}]" ## do a short break sleep 2 From f02179d75749a163d74ecc9bf20deefe3fdbb3d1 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 17 Sep 2023 11:20:33 +0200 Subject: [PATCH 34/39] fix: fix typo in tools_dir var, Line171 (#237) 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 4aa394ef8..76474dd41 100644 --- a/src/modules/postrename/filesystem/root/postrename +++ b/src/modules/postrename/filesystem/root/postrename @@ -168,7 +168,7 @@ fix_mainsailcfg_links() { fix_cn_links() { local tools_dir - tools_dir="/home/${DEFAULT_USER}/crowsnest/tools/" + tools_dir="/home/${DEFAULT_USER}/crowsnest/tools" sudo -u "${DEFAULT_USER}" \ ln -sf "${tools_dir}/libs/pkglist-rpi.sh" "${tools_dir}/pkglist.sh" } From 55b253e959572ac9722c21c5902b18e531089e2b Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 29 Sep 2023 19:31:29 +0200 Subject: [PATCH 35/39] fix: fix wifi connectivity (#240) * fix: reenable package upgrades Signed-off-by: Stephan Wendel * fix: fix missing packages for network_configurator Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- src/modules/armbian_net/config | 1 + src/modules/armbian_net/start_chroot_script | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/armbian/default b/config/armbian/default index f05c136fa..bd7d28436 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,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 DOWNLOAD_BASE_URL diff --git a/src/modules/armbian_net/config b/src/modules/armbian_net/config index d9a9ffa1e..d2b005768 100644 --- a/src/modules/armbian_net/config +++ b/src/modules/armbian_net/config @@ -14,3 +14,4 @@ [[ -n "$ARMBIAN_NET_FIRSTRUN_FILE" ]] || ARMBIAN_NET_FIRSTRUN_FILE="/boot/armbian_first_run.txt.template" [[ -n "$ARMBIAN_NET_FIRSTRUN_SCRIPT" ]] || ARMBIAN_NET_FIRSTRUN_SCRIPT="/usr/lib/armbian/armbian-firstrun-config" [[ -n "$ARMBIAN_NET_NC_PATH" ]] || ARMBIAN_NET_NC_PATH="/usr/local/bin/network-configurator" +[[ -n "$ARMBIAN_NET_DEPS" ]] || ARMBIAN_NET_DEPS="net-tools" diff --git a/src/modules/armbian_net/start_chroot_script b/src/modules/armbian_net/start_chroot_script index 997425bd5..7a3a152f0 100644 --- a/src/modules/armbian_net/start_chroot_script +++ b/src/modules/armbian_net/start_chroot_script @@ -28,6 +28,11 @@ install_cleanup_trap unpack filesystem/root / root ## END +## Step 1.1: Install Depedencies +### Needed to patch 'network_configurator' +# shellcheck disable=SC2086 +check_install_pkgs ${ARMBIAN_NET_DEPS} + ## Step 2: remove original template if [[ -f "${ARMBIAN_NET_FIRSTRUN_FILE}" ]]; then sudo rm -rf "${ARMBIAN_NET_FIRSTRUN_FILE}" From 485541641b11b8fdb4e6c7b7fceb67eac47e7e83 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:16:15 +0200 Subject: [PATCH 36/39] fix: fix armbian-release file error (#241) To get mainsail release shown in moonraker we need that 'hacky' solution --------- Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 34 ++++------------------ src/modules/mainsailos/start_chroot_script | 17 +++++++++-- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 65b90ac90..5ce9874b4 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -73,38 +73,16 @@ if [[ -f "/root/.not_logged_in_yet" ]]; then fi ## END Step 4 -## Step 5: Move armbian-release to display mainsailos-release -### Substep 1: Move armbian-release - if [[ -f "/etc/armbian-release" ]]; then - echo_green "Armbian release file found! moving to: 'armbian-release-info.txt'" - mv /etc/armbian-release /etc/armbian-release-info.txt - else - echo_red "Armbian release file not found! [SKIPPED]" - fi -### END Substep 1 -### Substep 2: patch Armbian scripts to new file location - echo_green "Patching armbian scripts (release file path) ..." - pushd "/usr/lib/armbian" &> /dev/null || exit 1 - files=() - while IFS='' read -r line; do - files+=("${line}") - done < <(grep -R "/etc/armbian-release" -- * | cut -d":" -f1) - for f in "${files[@]}"; do - sed -i "s|/etc/armbian-release|/etc/armbian-release-info.txt|g" "${f}" - done - popd &> /dev/null || exit 1 -## END Step 5 - -## Step 6: Patch dynamic motd +## Step 5: Patch dynamic motd echo_green "Patch dynamic motd ..." unpack /filesystem/root / chmod +x /etc/update-motd.d/* if [[ -f "/etc/default/armbian-motd" ]]; then sed -i 's/MOTD_DISABLE=""/MOTD_DISABLE="header"/' /etc/default/armbian-motd fi -## END Step 6 +## END Step 5 -## Step 7: Enable SPI interface by default +## Step 6: Enable SPI interface by default echo_green "Enable SPI interface on Orange Pi SBC's ..." ### Substep 1: Copy default config to backup file @@ -129,9 +107,9 @@ echo "spi-dev" >> "${ARMBIAN_MODULES_FILE}" ### END Substep 3 echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" -## END Step 7 +## END Step 6 -## Step 8: Remove unattended-upgrades +## Step 7: Remove unattended-upgrades echo_green "Remove 'unattended-upgrades' service ..." sudo apt-get remove --purge --yes unattended-upgrades -## END Step 8 +## END Step 7 diff --git a/src/modules/mainsailos/start_chroot_script b/src/modules/mainsailos/start_chroot_script index 1f9a192f5..89b426a17 100644 --- a/src/modules/mainsailos/start_chroot_script +++ b/src/modules/mainsailos/start_chroot_script @@ -33,8 +33,21 @@ function get_parent { echo "${DIST_NAME} release ${DIST_VERSION} ($(get_parent))" > /etc/"${DIST_NAME,,}"-release ## END Step 1 -## Step 2: Install CANBoot Dependency +## Step 2: Fake release file +### NOTE: Turns out that the 'distro' python package, +### which is used by moonraker, uses the first file after sorting. +### Therefore we need a hacky solution, because armbian relies, on upgrades +### on the original armbian-release file. +### To get around that, we simple symlink mainsailos-release to +### aaaa-release, which is directly read by moonraker. +if [[ -f "/etc/armbian-release" ]]; then + echo_green "Apply release file workaround ..." + ln -s /etc/"${DIST_NAME,,}"-release /etc/aaaa-release +fi +## END Step 2 + +## Step 3: Install CANBoot Dependency apt-get update --allow-releaseinfo-change # shellcheck disable=SC2086 check_install_pkgs ${MAINSAILOS_DEPS} -## END Step 2 +## END Step 3 From be13745d17780c85baa43d59a40dca565dd9f5b0 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:10:44 +0200 Subject: [PATCH 37/39] fix: fix error autologin on serial tty (#242) * fix: fix autologin on serial tty This fixes issue that after connection to a serial console it trys to autologin with user 'orangepi', which does not exist in our images Signed-off-by: Stephan Wendel * feat: add workaround for orangepi images Apply release file workaround for OrangePI based images. Signed-off-by: Stephan Wendel --- src/modules/mainsailos/start_chroot_script | 9 +++- src/modules/orangepi/config | 3 ++ src/modules/orangepi/end_chroot_script | 24 +++-------- src/modules/orangepi/start_chroot_script | 50 ++++++++++++++++------ 4 files changed, 53 insertions(+), 33 deletions(-) diff --git a/src/modules/mainsailos/start_chroot_script b/src/modules/mainsailos/start_chroot_script index 89b426a17..97e7d3494 100644 --- a/src/modules/mainsailos/start_chroot_script +++ b/src/modules/mainsailos/start_chroot_script @@ -40,8 +40,15 @@ echo "${DIST_NAME} release ${DIST_VERSION} ($(get_parent))" > /etc/"${DIST_NAME, ### on the original armbian-release file. ### To get around that, we simple symlink mainsailos-release to ### aaaa-release, which is directly read by moonraker. +### Substep 1: Do for armbian releases if [[ -f "/etc/armbian-release" ]]; then - echo_green "Apply release file workaround ..." + echo_green "Apply release file workaround (armbian based image) ..." + ln -s /etc/"${DIST_NAME,,}"-release /etc/aaaa-release +fi +### END Substep 1 +### Substep 2: Apply same for OrangePI bsed Images +if [[ -f "/etc/orangepi-release" ]]; then + echo_green "Apply release file workaround (orangepi based image) ..." ln -s /etc/"${DIST_NAME,,}"-release /etc/aaaa-release fi ## END Step 2 diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index 6196ce5f7..dab971308 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -23,6 +23,9 @@ bash-completion" [[ -n "$ORANGEPI_ADD_OVERLAYS_OPIZ2" ]] || ORANGEPI_ADD_OVERLAYS_OPIZ2="i2c3 uart5 spi-spidev" [[ -n "$ORANGEPI_ADD_OVERLAYS_OPIZ2_PARAMS" ]] || ORANGEPI_ADD_OVERLAYS_OPIZ2_PARAMS="param_spidev_spi_bus=1 param_spidev_spi_cs=1" +## Disable Autologin on gettys +[[ -n "$ORANGEPI_DISABLE_GETTY_AUTOLOGIN" ]] || ORANGEPI_DISABLE_GETTY_AUTOLOGIN="1" + ### EXPERIMENTAL: Install orangepi-config from source git repo [[ -n "$ORANGEPI_INSTALL_OPI_CONFIG" ]] || ORANGEPI_INSTALL_OPI_CONFIG="true" [[ -n "$ORANGEPI_OPI_CONFIG_URL" ]] || ORANGEPI_OPI_CONFIG_URL="https://raw.githubusercontent.com/orangepi-xunlong/orangepi-build/next/external/cache/sources/orangepi-config/" diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script index 1a872a189..8ae4e7609 100644 --- a/src/modules/orangepi/end_chroot_script +++ b/src/modules/orangepi/end_chroot_script @@ -18,27 +18,15 @@ source /common.sh install_cleanup_trap ## Clean up -## Step 1: Remove autologin and lock root account -if [ -f "/etc/systemd/system/getty@.service.d/override.conf" ]; then - rm -f /etc/systemd/system/getty@.service.d/override.conf -fi -## END - -## Step 2: Disable autologin on serial console -if [ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]; then - sed -i 's/--autologin root //' /etc/systemd/system/serial-getty@.service.d/override.conf -fi -## END - -## Step 3: Delete root passwd +## Step 1: Delete root passwd (disables root login) ### Deleting root passwd doesn't let you unlock the account sudo passwd -d root -## END +## END Step 1 -## Step 4: Lock root account +## Step 2: Lock root account (disables root login) sudo passwd -l root -## END +## END Step 2 -## Step 5: Remove passwdless sudo +## Step 3: Remove passwdless sudo sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers -## END +## END Step 3 diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index cb2596e55..32e18bf50 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -35,6 +35,10 @@ is_board_type() { echo "${board}" } +get_gettyconf_dirs() { + find "${1}" -type d -name "*getty@*" +} + # Base User groups # Shameless "stolen" from # https://github.com/guysoft/CustomPiOS/blob/devel/src/variants/armbian/pre_chroot_script @@ -85,25 +89,16 @@ if [ -f "/root/.not_logged_in_yet" ]; then fi ## END Step 4 -## Step 5: Move armbian-release to display mainsailos-release -if [[ -f "/etc/orangepi-release" ]]; then - echo_green "OrangePi release file found! moving to: 'orangepi-release-info.txt'" - mv /etc/orangepi-release /etc/orangepi-release-info.txt -else - echo_red "OrangePi release file not found! [SKIPPED]" -fi -## END Step 5 - -## Step 6: Patch dynamic motd +## Step 5: Patch dynamic motd echo_green "Patch dynamic motd ..." unpack /filesystem/root / chmod +x /etc/update-motd.d/* if [ -f "/etc/default/orangepi-motd" ]; then sed -i 's/^MOTD_DISABLE=""/MOTD_DISABLE="header tips"/' /etc/default/orangepi-motd fi -## END Step 6 +## END Step 5 -## Step 7: Enable SPI interface by default +## Step 6: Enable SPI interface by default echo_green "Enable interfaces on Orange Pi SBC's ..." ### Substep 1: Copy default config to backup file @@ -136,9 +131,9 @@ fi echo "spi-dev" >> "${ORANGEPI_MODULES_FILE}" echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" -## END Step 7 +## END Step 6 -## Step 8: Install orangepi-config from git source repository +## Step 7: Install orangepi-config from git source repository if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then echo_green "Install orangepi-config from git sources ..." @@ -191,4 +186,31 @@ if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then else echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" fi +## END Step 7 + +## Step 8: Fix tty and serial-tty autologin +### NOTE: Since OrangePI OS uses for its getty override.conf files +### the location of '/lib/systemd/system/[serial-]getty@.service.d' +### instead the appropriate location in etc, we have to fix that. +if [[ "${ORANGEPI_DISABLE_GETTY_AUTOLOGIN}" = "1" ]]; then + echo_green "Disable 'getty' autologin ..." + + ### Substep 1: copy '/lib/systemd/system/[serial-]getty@.service.d' + for dir in $(get_gettyconf_dirs /usr/lib/systemd/system); do + cp -R "${dir}" /etc/systemd/system + done + ### End Substep 1 + + ### Substep 2: Modify 'override.conf', delete autologin + for conf in $(get_gettyconf_dirs /etc/systemd/system); do + if [[ -f "${conf}/override.conf" ]]; then + echo_green "Found '${conf}/override.conf', trying to modify ..." + sed -i 's/--autologin orangepi //' "${conf}/override.conf" + else + echo_green "No '${conf}/override.conf' found, modifying skipped!" + fi + done + ### END Substep 2 + echo_green "Disable 'getty' autologin ... DONE!" +fi ## END Step 8 From c24e95b8d701b7a3a08d91d4666bcb9beb249758 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 20 Oct 2023 17:06:16 +0200 Subject: [PATCH 38/39] fix: fix 'is_board_type' function (#243) Since we applied PR #241 and #242, this function always doesnt give the right value, which leads to unwanted behaviour in enabling SPI during build. As we no longer rename the release file, we have to use its original location in '/etc/armbian-release' ( Or '/etc/orangepi-release' if Opi Image is used ) Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 2 +- src/modules/orangepi/start_chroot_script | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 5ce9874b4..8a8235846 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -21,7 +21,7 @@ install_cleanup_trap is_board_type() { local board releasefile board="" - releasefile="/etc/armbian-release-info.txt" + releasefile="/etc/armbian-release" if [[ -f "${releasefile}" ]]; then board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" fi diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index 32e18bf50..7e5d05544 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -28,7 +28,7 @@ install_cleanup_trap is_board_type() { local board releasefile board="" - releasefile="/etc/orangepi-release-info.txt" + releasefile="/etc/orangepi-release" if [[ -f "${releasefile}" ]]; then board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" fi From 660b0badb9d48fc7e3f16495e493500110bc3dba Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 20 Oct 2023 17:07:59 +0200 Subject: [PATCH 39/39] fix: fix Torrent and Checksum download URLs (#244) After Bullseye images moved to 'oldstable' branch, we need to alter the URLs to 'legacy' images and checksums Signed-off-by: Stephan Wendel --- config/raspberry/rpi32 | 9 +++++++-- config/raspberry/rpi64 | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config/raspberry/rpi32 b/config/raspberry/rpi32 index f01873e19..ab7d9f6d4 100644 --- a/config/raspberry/rpi32 +++ b/config/raspberry/rpi32 @@ -4,8 +4,13 @@ # Declare Variables before exporting. # See https://www.shellcheck.net/wiki/SC2155 -DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha256" -DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent" +# 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" export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE diff --git a/config/raspberry/rpi64 b/config/raspberry/rpi64 index e58c6a460..7cee4dd60 100644 --- a/config/raspberry/rpi64 +++ b/config/raspberry/rpi64 @@ -6,9 +6,13 @@ 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" +# 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" # export variables