From 760d3fc11abb2b4a0c4457bc77f6308023e4a81a Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 29 Dec 2022 11:32:44 +0100 Subject: [PATCH 01/73] feat: add orange pi zero2 Signed-off-by: Stephan Wendel --- config/armbian/orangepi_zero2 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 config/armbian/orangepi_zero2 diff --git a/config/armbian/orangepi_zero2 b/config/armbian/orangepi_zero2 new file mode 100644 index 000000000..0b3a7686a --- /dev/null +++ b/config/armbian/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}/orangepi3_lts.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi3_lts.img.xz" + +# export Variables +export BASE_ARCH +export DOWNLOAD_URL_CHECKSUM +export DOWNLOAD_URL_IMAGE From 3d49ca41e7a9237556f317c2bdbc2545e11ddc75 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 29 Dec 2022 12:04:22 +0100 Subject: [PATCH 02/73] fix: fix typo due unsaved file Signed-off-by: Stephan Wendel --- config/armbian/orangepi_zero2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/armbian/orangepi_zero2 b/config/armbian/orangepi_zero2 index 0b3a7686a..2402cd4e7 100644 --- a/config/armbian/orangepi_zero2 +++ b/config/armbian/orangepi_zero2 @@ -5,8 +5,8 @@ BASE_ARCH="arm64" # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/orangepi3_lts.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi3_lts.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/orangepi_zero2.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi_zero2.img.xz" # export Variables export BASE_ARCH From abac2d673259f7cf4955db26cce8b88c2c4d4a4a Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 19 Feb 2023 11:30:02 +0100 Subject: [PATCH 03/73] chore: switch to orangepi armbian image Signed-off-by: Stephan Wendel --- config/armbian/orangepi_zero2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/armbian/orangepi_zero2 b/config/armbian/orangepi_zero2 index 2402cd4e7..1ad1c1d18 100644 --- a/config/armbian/orangepi_zero2 +++ b/config/armbian/orangepi_zero2 @@ -5,8 +5,8 @@ BASE_ARCH="arm64" # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/orangepi_zero2.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi_zero2.img.xz" +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 From 18e0dadc9a339fbbfe5f160032ecdfe7658b3d8b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 20 Feb 2023 20:02:04 +0100 Subject: [PATCH 04/73] chore: move orangepi images to own config and module Signed-off-by: Stephan Wendel --- config/orangepi/default | 39 ++++++++++ config/{armbian => orangepi}/orangepi_zero2 | 0 src/modules/orangepi/config | 5 ++ src/modules/orangepi/end_chroot_script | 31 ++++++++ .../root/etc/update-motd.d/10-mainsailos | 66 +++++++++++++++++ src/modules/orangepi/start_chroot_script | 72 +++++++++++++++++++ 6 files changed, 213 insertions(+) create mode 100644 config/orangepi/default rename config/{armbian => orangepi}/orangepi_zero2 (100%) create mode 100644 src/modules/orangepi/config create mode 100644 src/modules/orangepi/end_chroot_script create mode 100755 src/modules/orangepi/filesystem/root/etc/update-motd.d/10-mainsailos create mode 100644 src/modules/orangepi/start_chroot_script diff --git a/config/orangepi/default b/config/orangepi/default new file mode 100644 index 000000000..1bbc90e03 --- /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(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/orangepi_zero2 b/config/orangepi/orangepi_zero2 similarity index 100% rename from config/armbian/orangepi_zero2 rename to config/orangepi/orangepi_zero2 diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config new file mode 100644 index 000000000..667ea247f --- /dev/null +++ b/src/modules/orangepi/config @@ -0,0 +1,5 @@ +#!/bin/bash +# shellcheck disable=all + +[ -n "$ORANGEPI_DEPS" ] || ORANGEPI_DEPS="avahi-daemon iptables \ +bash-completion" diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script new file mode 100644 index 000000000..7ce520ba1 --- /dev/null +++ b/src/modules/orangepi/end_chroot_script @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# MainsailOS Specific Tweaks for orangepi images +# written by Stephan Wendel aka KwadFan +# +# GPL V3 +######## + +## 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 + rm -f /etc/systemd/system/getty@.service.d/override.conf +fi + +# 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 + +# Generate random root passwd +yes "$(gen_root_pw)" | passwd root + +# lock root account +sudo -u "${BASE_USER}" passwd -l root + +# Remove passwdless sudo +sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers 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..5c976f3c0 --- /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/armbian-release-info.txt ]] && . /etc/armbian-release-info.txt + +if [[ -f /etc/armbian-distribution-status ]]; then + . /etc/armbian-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/armbian-distribution-status | cut -d"=" -f2) +fi +[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-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[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/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script new file mode 100644 index 000000000..ca990872a --- /dev/null +++ b/src/modules/orangepi/start_chroot_script @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# MainsailOS Specific Tweaks for orangepi images +# written by Stephan Wendel aka KwadFan +# +# GPL V3 +######## + +# Source error handling, leave this in place +set -xe + +# 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 ${ORANGEPI_DEPS} + +# passwordless sudo during install +# Will be removed in cleanup +echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers + +# 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 +} + +# set groups +if_group_exists_run i2c usermod -aG i2c "${BASE_USER}" +usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal "${BASE_USER}" + +# Remove user "orangepi" +sudo userdel orangepi +sudo rm -rf /home/orangepi + +# 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 + +# Try patching first login in build stage +if [ -f "/root/.not_logged_in_yet" ]; then + rm -f /root/.not_logged_in_yet +fi + +# 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 + +# Remove orangepi_first_run.txt +if [[ -f "/boot/orangepi_first_run.txt" ]]; then + sudo rm -rf /boot/orangepi_first_run.txt +fi + +# update 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 From b5a1faecc03bc2d71095d28553545a977e8961c8 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 20 Feb 2023 20:20:41 +0100 Subject: [PATCH 05/73] chore: remove opiconfig module Removed opiconfig module and put functionality to according armbian/orangepi modules Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- config/orangepi/default | 2 +- src/modules/armbian/config | 3 ++ src/modules/armbian/start_chroot_script | 35 +++++++++++++ src/modules/opiconfig/config | 16 ------ src/modules/opiconfig/start_chroot_script | 61 ----------------------- src/modules/orangepi/config | 3 ++ src/modules/orangepi/start_chroot_script | 51 ++++++++++++++++--- 8 files changed, 86 insertions(+), 87 deletions(-) delete mode 100644 src/modules/opiconfig/config delete mode 100644 src/modules/opiconfig/start_chroot_script diff --git a/config/armbian/default b/config/armbian/default index 80ea95e19..09216febc 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,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 index 1bbc90e03..8c835a9da 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(armbian_net,opiconfig,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,pkgupgrade,orangepi(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL diff --git a/src/modules/armbian/config b/src/modules/armbian/config index c74f954ca..e04f2849a 100644 --- a/src/modules/armbian/config +++ b/src/modules/armbian/config @@ -3,3 +3,6 @@ [ -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/start_chroot_script b/src/modules/armbian/start_chroot_script index 0a2aa965b..15e97e487 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -13,6 +13,17 @@ set -xe 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}" +} + # Install armbian specific packages apt update # shellcheck disable=SC2086 @@ -56,3 +67,27 @@ 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 + + +echo_green "Enable SPI interface on Orange Pi SBC's ..." + +# Step 1: Copy default config to backup file +cp "${ARMBIAN_CONFIG_TXT_FILE}" "${ARMBIAN_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" >> "${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 + +# Step 3: add spi-dev module to /etc/modules +echo "spi-dev" >> "${ARMBIAN_MODULES_FILE}" + +echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" 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 index 667ea247f..073c0aee7 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -3,3 +3,6 @@ [ -n "$ORANGEPI_DEPS" ] || ORANGEPI_DEPS="avahi-daemon iptables \ 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" diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index ca990872a..b9a2ed319 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -13,14 +13,16 @@ set -xe source /common.sh install_cleanup_trap -# Install armbian specific packages -apt update -# shellcheck disable=SC2086 -check_install_pkgs ${ORANGEPI_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,6 +35,16 @@ if_group_exists_run() { fi } + +# Install armbian specific packages +apt update +# shellcheck disable=SC2086 +check_install_pkgs ${ORANGEPI_DEPS} + +# passwordless sudo during install +# Will be removed in cleanup +echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers + # set groups if_group_exists_run i2c usermod -aG i2c "${BASE_USER}" usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal "${BASE_USER}" @@ -70,3 +82,26 @@ 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 + +echo_green "Enable SPI interface on Orange Pi SBC's ..." + +# Step 1: Copy default config to backup file +cp "${ORANGEPI_CONFIG_TXT_FILE}" "${ORANGEPI_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" >> "${ORANGEPI_CONFIG_TXT_FILE}" +fi + +## OrangePi 4 LTS +if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then + echo "overlays=spi-spidev" >> "${ORANGEPI_CONFIG_TXT_FILE}" + echo "param_spidev_spi_bus=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" +fi + +# Step 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!" From d0785df52e1b5b018c295e69a9e5e66c2d25b133 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 20 Feb 2023 20:43:30 +0100 Subject: [PATCH 06/73] fix: add missing package unzip Signed-off-by: Stephan Wendel --- src/modules/orangepi/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index 073c0aee7..8d4c92061 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -1,7 +1,7 @@ #!/bin/bash # shellcheck disable=all -[ -n "$ORANGEPI_DEPS" ] || ORANGEPI_DEPS="avahi-daemon iptables \ +[ -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" From 39ab3f4d26df91749e5861392dc9d60b25a67c4e Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:11:58 +0100 Subject: [PATCH 07/73] fix: fixes enabling SPI and patching motd Signed-off-by: Stephan Wendel --- src/modules/orangepi/start_chroot_script | 48 ++++++++++++++---------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index b9a2ed319..f563f3438 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -35,35 +35,35 @@ if_group_exists_run() { fi } +# passwordless sudo during install +# Will be removed in cleanup +echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers -# Install armbian specific packages + +## Step 1: Install armbian specific packages apt update # shellcheck disable=SC2086 check_install_pkgs ${ORANGEPI_DEPS} -# passwordless sudo during install -# Will be removed in cleanup -echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers - -# set groups +# Step 2: Set default groups if_group_exists_run i2c usermod -aG i2c "${BASE_USER}" usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal "${BASE_USER}" -# Remove user "orangepi" +# Substep 1: Remove user "orangepi" sudo userdel orangepi sudo rm -rf /home/orangepi -# Patch sshd_config +# 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 -# Try patching first login in build stage +# 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 -# Move armbian-release to display mainsailos-release +# 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 @@ -71,24 +71,33 @@ else echo_red "OrangePi release file not found! [SKIPPED]" fi -# Remove orangepi_first_run.txt -if [[ -f "/boot/orangepi_first_run.txt" ]]; then - sudo rm -rf /boot/orangepi_first_run.txt +# Step 6: Remove orangepi_first_run.txt.template +if [[ -f "/boot/orangepi_first_run.txt.template" ]]; then + sudo rm -rf /boot/orangepi_first_run.txt.template fi -# update motd +## Step 7: 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 +if [ -f "/etc/default/orangepi-motd" ]; then + sed -i 's/^MOTD_DISABLE=""/MOTD_DISABLE="header tips"/' /etc/default/orangepi-motd fi +## End +## Step 8: Enable SPI interface by default echo_green "Enable SPI interface on Orange Pi SBC's ..." -# Step 1: Copy default config to backup file +# Substep 1: Copy default config to backup file cp "${ORANGEPI_CONFIG_TXT_FILE}" "${ORANGEPI_CONFIG_BAK_FILE}" -# Step 2: Enable SPI in armbianEnv.txt depending on device +# Substep 2: Enable SPI in armbianEnv.txt depending on device + +## Orangepi Zero2 +if [[ "$(is_board_type)" == "orangepizero2" ]]; then + echo "overlays=spi-spidev" >> "${ORANGEPI_CONFIG_TXT_FILE}" + echo "param_spidev_spi_bus=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" +fi ## OrangePi 3 LTS if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then @@ -101,7 +110,8 @@ if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then echo "param_spidev_spi_bus=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi -# Step 3: add spi-dev module to /etc/modules +# 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 From 2911babe7a9c9e77b69108efba90129356fa86d8 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:15:35 +0100 Subject: [PATCH 08/73] chore: changed style of end_chroot_script in orangepi module Signed-off-by: Stephan Wendel --- src/modules/orangepi/end_chroot_script | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script index 7ce520ba1..f42db03f6 100644 --- a/src/modules/orangepi/end_chroot_script +++ b/src/modules/orangepi/end_chroot_script @@ -5,27 +5,27 @@ # GPL V3 ######## -## functions +## Helper functions gen_root_pw() { tr -dc "[:alnum:]" < /dev/urandom | head -c 50 } -# Clean up -# Remove autologin and lock root account +## 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 -# Disable autologin on serial console +## 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 -# Generate random root passwd +## Step 3: Generate random root passwd yes "$(gen_root_pw)" | passwd root -# lock root account +## Step 4: Lock root account sudo -u "${BASE_USER}" passwd -l root -# Remove passwdless sudo +## Step 5: Remove passwdless sudo sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers From 3a31d77658dc79344a858980013b8d993fc42a73 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:17:21 +0100 Subject: [PATCH 09/73] chore: changed style of end_chroot_script in armbian module Signed-off-by: Stephan Wendel --- src/modules/armbian/end_chroot_script | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/armbian/end_chroot_script b/src/modules/armbian/end_chroot_script index 04d93f693..99b993f4f 100644 --- a/src/modules/armbian/end_chroot_script +++ b/src/modules/armbian/end_chroot_script @@ -5,27 +5,27 @@ # GPL V3 ######## -## functions +## Helper functions gen_root_pw() { tr -dc "[:alnum:]" < /dev/urandom | head -c 50 } -# Clean up -# Remove autologin and lock root account +## 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 -# Disable autologin on serial console +## 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 -# Generate random root passwd +## Step 3: Generate random root passwd yes "$(gen_root_pw)" | passwd root -# lock root account +## Step 4: Lock root account sudo -u "${BASE_USER}" passwd -l root -# Remove passwdless sudo +## Step 5: Remove passwdless sudo sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers From c18dc2585d6164d266f2e0f2d106aee887d6060b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:28:33 +0100 Subject: [PATCH 10/73] chore: fix description, changes code style Signed-off-by: Stephan Wendel --- src/modules/armbian_net/config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/armbian_net/config b/src/modules/armbian_net/config index 6a0ab8317..49d90a114 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 +#### armbian_net module #### #### 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" From 0aeffe6ee68d5b216c1dfa07c71fa8c765d63266 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:34:03 +0100 Subject: [PATCH 11/73] chore: replace armbian_net module with orangepi_net module Signed-off-by: Stephan Wendel --- config/orangepi/default | 2 +- 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 | 58 +++++++++++++++++++ 5 files changed, 144 insertions(+), 1 deletion(-) 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/orangepi/default b/config/orangepi/default index 8c835a9da..96a23ebbb 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(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,pkgupgrade,orangepi(orangepi_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL diff --git a/src/modules/orangepi_net/config b/src/modules/orangepi_net/config new file mode 100644 index 000000000..19803bbd4 --- /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..1ee72d296 --- /dev/null +++ b/src/modules/orangepi_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/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..6a5253ecc --- /dev/null +++ b/src/modules/orangepi_net/start_chroot_script @@ -0,0 +1,58 @@ +#!/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 + +## Step 2: remove original template +if [[ -f "${ORANGEPI_NET_FIRSTRUN_FILE}" ]]; then + sudo rm -rf "${ORANGEPI_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 "${ORANGEPI_NET_FIRSTRUN_SCRIPT}" ]]; then + sudo cp -p "${ORANGEPI_NET_FIRSTRUN_SCRIPT}" "${ORANGEPI_NET_NC_PATH}" +fi + +## Step 5: patch /usr/local/bin/network-configurator +if [[ -f "${ORANGEPI_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' "${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 armbian-firstrun-config for MainsailOS' "${ORANGEPI_NET_NC_PATH}" + sed -i '10 i # Original located at /usr/lib/armbian/armbian-firstrun-config' "${ORANGEPI_NET_NC_PATH}" + sed -i '11 i # Changes made by https:\/\/github.com/mainsail-crew' "${ORANGEPI_NET_NC_PATH}" +fi + +## Step 6: Enable systemd service +systemctl_if_exists enable network-configurator.service From 142c577db3f2b0551f0e805d48bc8b97ac39d3f4 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:36:33 +0100 Subject: [PATCH 12/73] chore: change header style Signed-off-by: Stephan Wendel --- src/modules/armbian_net/config | 2 +- src/modules/armbian_net/start_chroot_script | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/modules/armbian_net/config b/src/modules/armbian_net/config index 49d90a114..6cbf7e036 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 -#### armbian_net module +#### MainsailOS network configurator for armbian images #### #### Written by Stephan Wendel aka KwadFan #### Copyright 2023 - till today diff --git a/src/modules/armbian_net/start_chroot_script b/src/modules/armbian_net/start_chroot_script index 7797d17b7..5fa7aa5a4 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 From 36b11aca55037e3a0e04cd20ed1e5c134c6fb8c2 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:40:18 +0100 Subject: [PATCH 13/73] fix: fix orangepi_net module Signed-off-by: Stephan Wendel --- src/modules/orangepi_net/start_chroot_script | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/orangepi_net/start_chroot_script b/src/modules/orangepi_net/start_chroot_script index 6a5253ecc..f3fb9b2e5 100644 --- a/src/modules/orangepi_net/start_chroot_script +++ b/src/modules/orangepi_net/start_chroot_script @@ -33,7 +33,7 @@ if [[ -f "${ORANGEPI_NET_FIRSTRUN_FILE}" ]]; then fi ## Step 3: Disable first run service -systemctl_if_exists disable armbian-firstrun-config.service +systemctl_if_exists disable orangepi-firstrun-config.service ## Step 4: Copy original script to /usr/local/bin/network-configurator if [[ -f "${ORANGEPI_NET_FIRSTRUN_SCRIPT}" ]]; then @@ -42,15 +42,15 @@ fi ## Step 5: patch /usr/local/bin/network-configurator if [[ -f "${ORANGEPI_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' "${ORANGEPI_NET_NC_PATH}" + ### 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 armbian-firstrun-config for MainsailOS' "${ORANGEPI_NET_NC_PATH}" - sed -i '10 i # Original located at /usr/lib/armbian/armbian-firstrun-config' "${ORANGEPI_NET_NC_PATH}" + 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 From 86e2b7df33d13aafad294113cf17cfcd07c92e2e Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:50:17 +0100 Subject: [PATCH 14/73] chore: removes unneeded step and refactor code style Signed-off-by: Stephan Wendel --- src/modules/orangepi/end_chroot_script | 22 ++++++++--- src/modules/orangepi/start_chroot_script | 47 +++++++++++++----------- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script index f42db03f6..6b693fab0 100644 --- a/src/modules/orangepi/end_chroot_script +++ b/src/modules/orangepi/end_chroot_script @@ -1,9 +1,21 @@ #!/usr/bin/env bash -# MainsailOS Specific Tweaks for orangepi images -# written by Stephan Wendel aka KwadFan -# -# GPL V3 -######## +#### 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 ## Helper functions gen_root_pw() { diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index f563f3438..b0eb6725b 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -1,12 +1,16 @@ #!/usr/bin/env bash -# MainsailOS Specific Tweaks for orangepi images -# written by Stephan Wendel aka KwadFan -# -# GPL V3 -######## - +#### 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 -xe +set -Ee # Source CustomPIOS common.sh # shellcheck disable=SC1091 @@ -17,7 +21,7 @@ install_cleanup_trap is_board_type() { local board releasefile board="" - releasefile="/etc/armbian-release-info.txt" + releasefile="/etc/orangepi-release-info.txt" if [[ -f "${releasefile}" ]]; then board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" fi @@ -44,48 +48,49 @@ echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers apt update # shellcheck disable=SC2086 check_install_pkgs ${ORANGEPI_DEPS} +## END -# Step 2: Set default groups +## Step 2: Set default groups if_group_exists_run i2c usermod -aG i2c "${BASE_USER}" usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal "${BASE_USER}" +## END -# Substep 1: Remove user "orangepi" +## Substep 1: Remove user "orangepi" sudo userdel orangepi sudo rm -rf /home/orangepi +## END -# Step 3: Patch sshd_config (Limit retrys, disable root login via ssh) +## 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 4: Try patching first login in build stage +## 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 5: Move armbian-release to display mainsailos-release +## 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 6: Remove orangepi_first_run.txt.template -if [[ -f "/boot/orangepi_first_run.txt.template" ]]; then - sudo rm -rf /boot/orangepi_first_run.txt.template -fi - -## Step 7: Patch dynamic motd +## 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 +## END -## Step 8: Enable SPI interface by default +## 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 From 20879f95ac5d41bf7dde668da6b23aaea2813e68 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:52:02 +0100 Subject: [PATCH 15/73] chore: refactor style of orangepi end_chroot_script Signed-off-by: Stephan Wendel --- src/modules/orangepi/end_chroot_script | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script index 6b693fab0..3dbc2e905 100644 --- a/src/modules/orangepi/end_chroot_script +++ b/src/modules/orangepi/end_chroot_script @@ -27,17 +27,22 @@ gen_root_pw() { 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: Generate random root passwd yes "$(gen_root_pw)" | passwd root +## END ## Step 4: Lock root account sudo -u "${BASE_USER}" passwd -l root +## END ## Step 5: Remove passwdless sudo sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers +## END From 93e40567dce8ab65cb43a3d003c4434799fd9128 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 12:54:27 +0100 Subject: [PATCH 16/73] chore: refactor style of armbian end_chroot_script Signed-off-by: Stephan Wendel --- src/modules/armbian/end_chroot_script | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/modules/armbian/end_chroot_script b/src/modules/armbian/end_chroot_script index 99b993f4f..1fc15edc1 100644 --- a/src/modules/armbian/end_chroot_script +++ b/src/modules/armbian/end_chroot_script @@ -1,9 +1,21 @@ #!/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 -Ee + +# Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap ## Helper functions gen_root_pw() { @@ -15,17 +27,22 @@ gen_root_pw() { 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: Generate random root passwd yes "$(gen_root_pw)" | passwd root +## END ## Step 4: Lock root account sudo -u "${BASE_USER}" passwd -l root +## END ## Step 5: Remove passwdless sudo sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers +## END From 916f8a3daf4f7adead19ebd804d413e44e44fe89 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:06:54 +0100 Subject: [PATCH 17/73] chore: refactor style of armbian start_chroot_script Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 70 ++++++++++++++++--------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 15e97e487..dbf894294 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -1,12 +1,16 @@ #!/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 @@ -24,15 +28,6 @@ is_board_type() { echo "${board}" } -# 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 - # Base User groups # Shameless "stolen" from # https://github.com/guysoft/CustomPiOS/blob/devel/src/variants/armbian/pre_chroot_script @@ -44,37 +39,59 @@ if_group_exists_run() { 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 ${ARMBIAN_DEPS} + + + # set groups if_group_exists_run i2c usermod -aG i2c "${BASE_USER}" usermod -aG video,audio,plugdev,games,netdev,sudo "${BASE_USER}" -# Patch sshd_config +## Step 2: Set default groups 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 +## 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 5: Move armbian-release to display mainsailos-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 -# Move armbian-release to display mainsailos-release -mv /etc/armbian-release /etc/armbian-release-info.txt - -# 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 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 ..." -# Step 1: Copy default config to backup file +# Substep 1: Copy default config to backup file cp "${ARMBIAN_CONFIG_TXT_FILE}" "${ARMBIAN_CONFIG_BAK_FILE}" -# Step 2: Enable SPI in armbianEnv.txt depending on device +# Substep: Enable SPI in armbianEnv.txt depending on device ## OrangePi 3 LTS if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then @@ -87,7 +104,8 @@ if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then echo "param_spidev_spi_bus=1" >> "${ARMBIAN_CONFIG_TXT_FILE}" fi -# Step 3: add spi-dev module to /etc/modules +# Substep 3: add spi-dev module to /etc/modules echo "spi-dev" >> "${ARMBIAN_MODULES_FILE}" echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" +## END From abd2a7e6a6451d20130b033783e29fc59751cf20 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:09:18 +0100 Subject: [PATCH 18/73] chore: refactor style of orangepi config Signed-off-by: Stephan Wendel --- src/modules/orangepi/config | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index 8d4c92061..d427c2147 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -1,8 +1,17 @@ #!/bin/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 disable=all -[ -n "$ORANGEPI_DEPS" ] || ORANGEPI_DEPS="avahi-daemon iptables unzip \ +[[ -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" +[[ -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" From 55d5dce8b11b312bbad81528ea86574bf4241530 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:10:37 +0100 Subject: [PATCH 19/73] chore: refactor style of armbian config Signed-off-by: Stephan Wendel --- src/modules/armbian/config | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/modules/armbian/config b/src/modules/armbian/config index e04f2849a..58139cde6 100644 --- a/src/modules/armbian/config +++ b/src/modules/armbian/config @@ -1,8 +1,17 @@ #!/bin/bash +#### 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" +[[ -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" From 8a89e0d99755d82b1af20d43ee85e37eeca0bde1 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:13:11 +0100 Subject: [PATCH 20/73] fix: fix mainsailos motd header file Signed-off-by: Stephan Wendel --- .../filesystem/root/etc/update-motd.d/10-mainsailos | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 5c976f3c0..db564e48c 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 @@ -16,16 +16,16 @@ # shellcheck enable=require-variable-braces # shellcheck disable=SC1091 -[[ -f /etc/armbian-release-info.txt ]] && . /etc/armbian-release-info.txt +[[ -f /etc/orangepi-release-info.txt ]] && . /etc/orangepi-release-info.txt -if [[ -f /etc/armbian-distribution-status ]]; then - . /etc/armbian-distribution-status +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/armbian-distribution-status | cut -d"=" -f2) + DISTRIBUTION_STATUS=$(grep "${DISTRIBUTION_CODENAME}" /etc/orangepi-distribution-status | cut -d"=" -f2) fi -[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd +[[ -f /etc/default/orangepi-motd ]] && . /etc/default/orangepi-motd for f in ${MOTD_DISABLE}; do [[ "${f}" == "${THIS_SCRIPT}" ]] && exit 0 From c769e0c44d7c62174feea6fbb63709b3f670fe52 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:14:40 +0100 Subject: [PATCH 21/73] fix: fix typo in network_config.txt.template Signed-off-by: Stephan Wendel --- .../filesystem/root/boot/network_config.txt.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 1ee72d296..f3173c054 100644 --- a/src/modules/orangepi_net/filesystem/root/boot/network_config.txt.template +++ b/src/modules/orangepi_net/filesystem/root/boot/network_config.txt.template @@ -1,6 +1,6 @@ #----------------------------------------------------------------- # -# MainsailOS (armbian edition) Network Configuration +# 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. From 5c14c7615ba2238fd962d961def2ed6de73dd65a Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:17:48 +0100 Subject: [PATCH 22/73] chore: changes subshell behavior in armbian end_chroot_script Signed-off-by: Stephan Wendel --- src/modules/armbian/end_chroot_script | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/armbian/end_chroot_script b/src/modules/armbian/end_chroot_script index 1fc15edc1..7edf126ac 100644 --- a/src/modules/armbian/end_chroot_script +++ b/src/modules/armbian/end_chroot_script @@ -24,13 +24,13 @@ gen_root_pw() { ## Clean up ## Step 1: Remove autologin and lock root account -if [ -f "/etc/systemd/system/getty@.service.d/override.conf" ]; then +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 +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 From b9888420547ce7d053101f3b16ea5b291dc85630 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:19:10 +0100 Subject: [PATCH 23/73] chore: changes subshell behavior in armbian start_chroot_script Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index dbf894294..48dd5226f 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -62,7 +62,7 @@ sed -i 's/^#MaxAuthTries 6/MaxAuthTries 3/' /etc/ssh/sshd_config ## END ## Step 4: Try patching first login in build stage -if [ -f "/root/.not_logged_in_yet" ]; then +if [[ -f "/root/.not_logged_in_yet" ]]; then rm -f /root/.not_logged_in_yet fi ## END @@ -80,7 +80,7 @@ fi 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 From 7d2b3fa8033ae6ae77e20151bcc303d8db1dfb11 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:20:32 +0100 Subject: [PATCH 24/73] chore: refactor style of armbian start_chroot_script Signed-off-by: Stephan Wendel --- src/modules/armbian_net/start_chroot_script | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/armbian_net/start_chroot_script b/src/modules/armbian_net/start_chroot_script index 5fa7aa5a4..997425bd5 100644 --- a/src/modules/armbian_net/start_chroot_script +++ b/src/modules/armbian_net/start_chroot_script @@ -26,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 @@ -53,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 From 87bf6b49c939d13b0308ce1ca082db7119ebb33c Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:22:53 +0100 Subject: [PATCH 25/73] chore: refactor style of header in config files Signed-off-by: Stephan Wendel --- src/modules/armbian/config | 3 ++- src/modules/armbian_net/config | 2 +- src/modules/orangepi/config | 3 ++- src/modules/orangepi_net/config | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/armbian/config b/src/modules/armbian/config index 58139cde6..c36fa8a01 100644 --- a/src/modules/armbian/config +++ b/src/modules/armbian/config @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +# Shebang for better file detection #### MainsailOS Specific Tweaks for armbian images #### #### Written by Stephan Wendel aka KwadFan diff --git a/src/modules/armbian_net/config b/src/modules/armbian_net/config index 6cbf7e036..d9a9ffa1e 100644 --- a/src/modules/armbian_net/config +++ b/src/modules/armbian_net/config @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#Shebang for better file detection +# Shebang for better file detection #### MainsailOS network configurator for armbian images #### #### Written by Stephan Wendel aka KwadFan diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index d427c2147..34a17b4b0 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +# Shebang for better file detection #### MainsailOS Specific Tweaks for orangepi images #### #### Written by Stephan Wendel aka KwadFan diff --git a/src/modules/orangepi_net/config b/src/modules/orangepi_net/config index 19803bbd4..3bd31bb1f 100644 --- a/src/modules/orangepi_net/config +++ b/src/modules/orangepi_net/config @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#Shebang for better file detection +# Shebang for better file detection #### MainsailOS network configurator for orange images #### #### Written by Stephan Wendel aka KwadFan From 78033e96c21e4361a8d943676c74ee9d86dad0d9 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 13:56:42 +0100 Subject: [PATCH 26/73] fix: fix build error during lock root acc Signed-off-by: Stephan Wendel --- src/modules/armbian/end_chroot_script | 2 +- src/modules/orangepi/end_chroot_script | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/armbian/end_chroot_script b/src/modules/armbian/end_chroot_script index 7edf126ac..f985f3713 100644 --- a/src/modules/armbian/end_chroot_script +++ b/src/modules/armbian/end_chroot_script @@ -40,7 +40,7 @@ yes "$(gen_root_pw)" | passwd root ## END ## Step 4: Lock root account -sudo -u "${BASE_USER}" passwd -l root +yes "${BASE_USER_PASSWORD}" | sudo -u "${BASE_USER}" passwd -l root ## END ## Step 5: Remove passwdless sudo diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script index 3dbc2e905..e038e585a 100644 --- a/src/modules/orangepi/end_chroot_script +++ b/src/modules/orangepi/end_chroot_script @@ -40,7 +40,7 @@ yes "$(gen_root_pw)" | passwd root ## END ## Step 4: Lock root account -sudo -u "${BASE_USER}" passwd -l root +yes "${BASE_USER_PASSWORD}" | sudo -u "${BASE_USER}" passwd -l root ## END ## Step 5: Remove passwdless sudo From a78f6790b46f2b468e79844286e31c9b7d44d2b1 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 14:26:15 +0100 Subject: [PATCH 27/73] fix: wip Signed-off-by: Stephan Wendel --- src/modules/orangepi/end_chroot_script | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script index e038e585a..dbb7ca255 100644 --- a/src/modules/orangepi/end_chroot_script +++ b/src/modules/orangepi/end_chroot_script @@ -17,10 +17,10 @@ set -Ee source /common.sh install_cleanup_trap -## Helper functions -gen_root_pw() { - tr -dc "[:alnum:]" < /dev/urandom | head -c 50 -} +# ## Helper functions +# gen_root_pw() { +# tr -dc "[:alnum:]" < /dev/urandom | head -c 50 +# } ## Clean up ## Step 1: Remove autologin and lock root account @@ -36,11 +36,12 @@ fi ## END ## Step 3: Generate random root passwd -yes "$(gen_root_pw)" | passwd root +# yes "$(gen_root_pw)" | passwd root +sudo passwd -d root ## END ## Step 4: Lock root account -yes "${BASE_USER_PASSWORD}" | sudo -u "${BASE_USER}" passwd -l root +sudo passwd -l root ## END ## Step 5: Remove passwdless sudo From 7204aed3364392111923d0acc7561dc0d55fa26c Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 21 Feb 2023 15:01:14 +0100 Subject: [PATCH 28/73] fix: fix build error due root account locking Signed-off-by: Stephan Wendel --- src/modules/armbian/end_chroot_script | 7 ++++--- src/modules/orangepi/end_chroot_script | 9 ++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/modules/armbian/end_chroot_script b/src/modules/armbian/end_chroot_script index f985f3713..21a50cc6f 100644 --- a/src/modules/armbian/end_chroot_script +++ b/src/modules/armbian/end_chroot_script @@ -35,12 +35,13 @@ if [[ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]]; then fi ## END -## Step 3: 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 ## Step 4: Lock root account -yes "${BASE_USER_PASSWORD}" | sudo -u "${BASE_USER}" passwd -l root +sudo passwd -l root ## END ## Step 5: Remove passwdless sudo diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script index dbb7ca255..1a872a189 100644 --- a/src/modules/orangepi/end_chroot_script +++ b/src/modules/orangepi/end_chroot_script @@ -17,11 +17,6 @@ set -Ee source /common.sh install_cleanup_trap -# ## Helper functions -# gen_root_pw() { -# tr -dc "[:alnum:]" < /dev/urandom | head -c 50 -# } - ## Clean up ## Step 1: Remove autologin and lock root account if [ -f "/etc/systemd/system/getty@.service.d/override.conf" ]; then @@ -35,8 +30,8 @@ if [ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]; then fi ## END -## Step 3: 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 From 8ef675c2d227406197bb4595b42045214fb7deff Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 24 Feb 2023 18:31:57 +0100 Subject: [PATCH 29/73] chore: add group and udev rule to use gpio This is based on https://github.com/Arksine/moonraker/issues/562 It allows users to use the GPIOs with moonraker and/or klipper Signed-off-by: Stephan Wendel --- .../filesystem/root/etc/udev/rules.d/97-gpio.rules | 1 + src/modules/orangepi/start_chroot_script | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/modules/orangepi/filesystem/root/etc/udev/rules.d/97-gpio.rules 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/start_chroot_script b/src/modules/orangepi/start_chroot_script index b0eb6725b..b16244586 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -8,6 +8,10 @@ #### 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 @@ -50,9 +54,14 @@ apt update check_install_pkgs ${ORANGEPI_DEPS} ## END -## Step 2: Set default groups +## Step 2: Manage groups + +# Substep 1: Create group for gpio usage +sudo groupadd gpio + +# 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 "${BASE_USER}" +usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal,gpio "${BASE_USER}" ## END ## Substep 1: Remove user "orangepi" From 7f1e546c1fe30ba588e2b3e5ffb05b1e384b529b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 10:13:41 +0100 Subject: [PATCH 30/73] feat: install orangepi-config from git sources This pulls the scripts from orangepiOS build repo and copies into place This feature is EXPERIMENTAL! May removed if does not work as intended Signed-off-by: Stephan Wendel --- src/modules/orangepi_net/config | 9 ++++ src/modules/orangepi_net/start_chroot_script | 45 ++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/modules/orangepi_net/config b/src/modules/orangepi_net/config index 3bd31bb1f..f1d1edba2 100644 --- a/src/modules/orangepi_net/config +++ b/src/modules/orangepi_net/config @@ -14,3 +14,12 @@ [[ -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" + + +#### EXPERIMENTAL: Install orangepi-config from source git repo +[[ -n "$ORANGEPI_INSTALL_ORANGEPI_CONFIG" ]] || ORANGEPI_INSTALL_ORANGEPI_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_net/start_chroot_script b/src/modules/orangepi_net/start_chroot_script index f3fb9b2e5..f6c92d89b 100644 --- a/src/modules/orangepi_net/start_chroot_script +++ b/src/modules/orangepi_net/start_chroot_script @@ -26,19 +26,23 @@ 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 @@ -53,6 +57,47 @@ if [[ -f "${ORANGEPI_NET_NC_PATH}" ]]; then 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 + +## Step 7: Install orangepi-config from git source repository +if [[ "${ORANGEPI_INSTALL_ORANGEPI_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 2: curl sources from git repo to src/workspace/opi-config + for file in "${ORANGEPI_OPI_CONFIG_FILES[@]}"; do + curl -sL "${ORANGEPI_OPI_CONFIG_URL}"/"${file}" --output "${ORANGEPI_OPI_CONFIG_TEMP}"/"${file}" + done + ### END + + ### Substep 3: Create subdir 'orangepi-config' in /usr/lib/ + if [[ ! -d "/usr/lib/orangepi-config" ]]; then + mkdir -p "/usr/lib/orangepi-config" + fi + ### END + + ### Substep 4: Copy main script to /usr/sbin (orangepi-config) + cp -f "src/workspace/opi-config-src"/"${FILES[*]:0:1}" "/usr/sbin/orangepi-config" + ### END + + ### Substep 5: Install script librarys to /usr/lib/orangepi-config + for i in "${ORANGEPI_OPI_CONFIG_FILES[@]:1}"; do + stripped="${i##debian-config-}" + cp -f "${ORANGEPI_OPI_CONFIG_TEMP}/${i}" "/usr/lib/orangepi-config/${stripped}.sh" + done + ### END + +else + echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" +fi +## END From de82d10abb87b3756cdd096f5796a6c15b979e08 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 11:10:53 +0100 Subject: [PATCH 31/73] fix: fix typo in step 7, substep 4 of orangepi Signed-off-by: Stephan Wendel --- src/modules/orangepi_net/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/orangepi_net/start_chroot_script b/src/modules/orangepi_net/start_chroot_script index f6c92d89b..8f5519725 100644 --- a/src/modules/orangepi_net/start_chroot_script +++ b/src/modules/orangepi_net/start_chroot_script @@ -87,7 +87,7 @@ if [[ "${ORANGEPI_INSTALL_ORANGEPI_CONFIG}" = "true" ]]; then ### END ### Substep 4: Copy main script to /usr/sbin (orangepi-config) - cp -f "src/workspace/opi-config-src"/"${FILES[*]:0:1}" "/usr/sbin/orangepi-config" + cp -f "src/workspace/opi-config-src"/"${ORANGEPI_OPI_CONFIG_FILES[*]:0:1}" "/usr/sbin/orangepi-config" ### END ### Substep 5: Install script librarys to /usr/lib/orangepi-config From dd73d8f0fead5759c8f91d8d3737693ca0d37c65 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 11:15:57 +0100 Subject: [PATCH 32/73] fix: add softlink to orangepi-config Signed-off-by: Stephan Wendel --- src/modules/orangepi_net/start_chroot_script | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/orangepi_net/start_chroot_script b/src/modules/orangepi_net/start_chroot_script index 8f5519725..b3806caba 100644 --- a/src/modules/orangepi_net/start_chroot_script +++ b/src/modules/orangepi_net/start_chroot_script @@ -90,7 +90,11 @@ if [[ "${ORANGEPI_INSTALL_ORANGEPI_CONFIG}" = "true" ]]; then cp -f "src/workspace/opi-config-src"/"${ORANGEPI_OPI_CONFIG_FILES[*]:0:1}" "/usr/sbin/orangepi-config" ### END - ### Substep 5: Install script librarys to /usr/lib/orangepi-config + ### Substep 5: Link main script to /usr/bin/orangepi-config + ln -sf "/usr/sbin/orangepi-config" "/usr/bin/orangepi-config" + ### END + + ### Substep 6: Install script librarys to /usr/lib/orangepi-config for i in "${ORANGEPI_OPI_CONFIG_FILES[@]:1}"; do stripped="${i##debian-config-}" cp -f "${ORANGEPI_OPI_CONFIG_TEMP}/${i}" "/usr/lib/orangepi-config/${stripped}.sh" From 429918690d4234932eb87391e0c009b25a2531cc Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 12:02:04 +0100 Subject: [PATCH 33/73] chore: moves orangepi-config install to orangepi Signed-off-by: Stephan Wendel --- src/modules/orangepi/config | 8 ++++ src/modules/orangepi/start_chroot_script | 43 ++++++++++++++++++++ src/modules/orangepi_net/config | 9 ---- src/modules/orangepi_net/start_chroot_script | 43 -------------------- 4 files changed, 51 insertions(+), 52 deletions(-) diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index 34a17b4b0..14951fd0b 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -16,3 +16,11 @@ 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" + +#### EXPERIMENTAL: Install orangepi-config from source git repo +[[ -n "$ORANGEPI_INSTALL_OPI_CONFIG" ]] || ORANGEPI_INSTALL_ORANGEPI_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/start_chroot_script b/src/modules/orangepi/start_chroot_script index b16244586..c50a046fb 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -129,3 +129,46 @@ echo "spi-dev" >> "${ORANGEPI_MODULES_FILE}" echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" ## END + +## Step 4: 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 2: curl sources from git repo to src/workspace/opi-config + for file in "${ORANGEPI_OPI_CONFIG_FILES[@]}"; do + curl -sL "${ORANGEPI_OPI_CONFIG_URL}"/"${file}" --output "${ORANGEPI_OPI_CONFIG_TEMP}"/"${file}" + done + ### END + + ### Substep 3: Create subdir 'orangepi-config' in /usr/lib/ + if [[ ! -d "/usr/lib/orangepi-config" ]]; then + mkdir -p "/usr/lib/orangepi-config" + fi + ### END + + ### Substep 4: Copy main script to /usr/sbin (orangepi-config) + cp -f "src/workspace/opi-config-src"/"${ORANGEPI_OPI_CONFIG_FILES[*]:0:1}" "/usr/sbin/orangepi-config" + ### END + + ### Substep 5: Link main script to /usr/bin/orangepi-config + ln -sf "/usr/sbin/orangepi-config" "/usr/bin/orangepi-config" + ### END + + ### Substep 6: Install script librarys to /usr/lib/orangepi-config + for i in "${ORANGEPI_OPI_CONFIG_FILES[@]:1}"; do + stripped="${i##debian-config-}" + cp -f "${ORANGEPI_OPI_CONFIG_TEMP}/${i}" "/usr/lib/orangepi-config/${stripped}.sh" + done + ### END + +else + echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" +fi +## END diff --git a/src/modules/orangepi_net/config b/src/modules/orangepi_net/config index f1d1edba2..3bd31bb1f 100644 --- a/src/modules/orangepi_net/config +++ b/src/modules/orangepi_net/config @@ -14,12 +14,3 @@ [[ -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" - - -#### EXPERIMENTAL: Install orangepi-config from source git repo -[[ -n "$ORANGEPI_INSTALL_ORANGEPI_CONFIG" ]] || ORANGEPI_INSTALL_ORANGEPI_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_net/start_chroot_script b/src/modules/orangepi_net/start_chroot_script index b3806caba..792754a58 100644 --- a/src/modules/orangepi_net/start_chroot_script +++ b/src/modules/orangepi_net/start_chroot_script @@ -62,46 +62,3 @@ fi ## Step 6: Enable systemd service systemctl_if_exists enable network-configurator.service ## END - -## Step 7: Install orangepi-config from git source repository -if [[ "${ORANGEPI_INSTALL_ORANGEPI_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 2: curl sources from git repo to src/workspace/opi-config - for file in "${ORANGEPI_OPI_CONFIG_FILES[@]}"; do - curl -sL "${ORANGEPI_OPI_CONFIG_URL}"/"${file}" --output "${ORANGEPI_OPI_CONFIG_TEMP}"/"${file}" - done - ### END - - ### Substep 3: Create subdir 'orangepi-config' in /usr/lib/ - if [[ ! -d "/usr/lib/orangepi-config" ]]; then - mkdir -p "/usr/lib/orangepi-config" - fi - ### END - - ### Substep 4: Copy main script to /usr/sbin (orangepi-config) - cp -f "src/workspace/opi-config-src"/"${ORANGEPI_OPI_CONFIG_FILES[*]:0:1}" "/usr/sbin/orangepi-config" - ### END - - ### Substep 5: Link main script to /usr/bin/orangepi-config - ln -sf "/usr/sbin/orangepi-config" "/usr/bin/orangepi-config" - ### END - - ### Substep 6: Install script librarys to /usr/lib/orangepi-config - for i in "${ORANGEPI_OPI_CONFIG_FILES[@]:1}"; do - stripped="${i##debian-config-}" - cp -f "${ORANGEPI_OPI_CONFIG_TEMP}/${i}" "/usr/lib/orangepi-config/${stripped}.sh" - done - ### END - -else - echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" -fi -## END From 0eae23ccaa7bef4bc78e7080399a7c9fbbb1bf75 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 12:08:20 +0100 Subject: [PATCH 34/73] fix: fix typo in orangepi config Signed-off-by: Stephan Wendel --- src/modules/orangepi/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index 14951fd0b..be6669194 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -18,7 +18,7 @@ bash-completion" [[ -n "$ORANGEPI_MODULES_FILE" ]] || ORANGEPI_MODULES_FILE="/etc/modules" #### EXPERIMENTAL: Install orangepi-config from source git repo -[[ -n "$ORANGEPI_INSTALL_OPI_CONFIG" ]] || ORANGEPI_INSTALL_ORANGEPI_CONFIG="true" +[[ -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 From f51638f7bad2bd1ae6d1fb31ca009063a4e49811 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 12:15:40 +0100 Subject: [PATCH 35/73] chore: wip Signed-off-by: Stephan Wendel --- src/modules/orangepi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index c50a046fb..5bc6fa3bb 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -14,7 +14,7 @@ # shellcheck enable=require-variable-braces # Source error handling, leave this in place -set -Ee +set -Eex # Source CustomPIOS common.sh # shellcheck disable=SC1091 From 23e796f31865332411d5b95ed31ba160aac32e86 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 12:22:40 +0100 Subject: [PATCH 36/73] fix: fix copy error of main script Signed-off-by: Stephan Wendel --- src/modules/orangepi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index 5bc6fa3bb..14df4a940 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -154,7 +154,7 @@ if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then ### END ### Substep 4: Copy main script to /usr/sbin (orangepi-config) - cp -f "src/workspace/opi-config-src"/"${ORANGEPI_OPI_CONFIG_FILES[*]:0:1}" "/usr/sbin/orangepi-config" + cp -f "src/workspace/opi-config-src/${ORANGEPI_OPI_CONFIG_FILES[*]:0:1}" "/usr/sbin/orangepi-config" ### END ### Substep 5: Link main script to /usr/bin/orangepi-config From 5168296c4cb682a9e0817f88484ae64ba7ce528b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 12:46:44 +0100 Subject: [PATCH 37/73] fix: turn list into array For some reason CustomPIOS can't handle arrays in config files Signed-off-by: Stephan Wendel --- src/modules/orangepi/config | 5 +---- src/modules/orangepi/start_chroot_script | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index be6669194..6caff8a77 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -20,7 +20,4 @@ bash-completion" #### 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 ) +[[ -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/start_chroot_script b/src/modules/orangepi/start_chroot_script index 14df4a940..e46071b34 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -141,28 +141,34 @@ if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then fi ### END - ### Substep 2: curl sources from git repo to src/workspace/opi-config - for file in "${ORANGEPI_OPI_CONFIG_FILES[@]}"; do + ### 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 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: Create subdir 'orangepi-config' in /usr/lib/ + ### 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: Copy main script to /usr/sbin (orangepi-config) - cp -f "src/workspace/opi-config-src/${ORANGEPI_OPI_CONFIG_FILES[*]:0:1}" "/usr/sbin/orangepi-config" + ### 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: Link main script to /usr/bin/orangepi-config + ### Substep 6: Link main script to /usr/bin/orangepi-config ln -sf "/usr/sbin/orangepi-config" "/usr/bin/orangepi-config" ### END - ### Substep 6: Install script librarys to /usr/lib/orangepi-config - for i in "${ORANGEPI_OPI_CONFIG_FILES[@]:1}"; do + ### 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 From 425388a034f4efdd916093409b0eb37128d92ed8 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 13:42:04 +0100 Subject: [PATCH 38/73] chore: finallize and cleanup Signed-off-by: Stephan Wendel --- src/modules/orangepi/start_chroot_script | 65 ++++++++++++++---------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index e46071b34..69d04ecbf 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -14,14 +14,17 @@ # shellcheck enable=require-variable-braces # Source error handling, leave this in place -set -Eex +set -Ee + +## Uncomment for deeper debugging +# set -x # Source CustomPIOS common.sh # shellcheck disable=SC1091 source /common.sh install_cleanup_trap -### Helper func +# Helper func is_board_type() { local board releasefile board="" @@ -47,39 +50,40 @@ if_group_exists_run() { # 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 +## END Step 1 -## Step 2: Manage groups +## Step 2: Manage groups and default user -# Substep 1: Create group for gpio usage +### Substep 1: Create group for gpio usage sudo groupadd gpio +### END Substep 1 -# Substep 2: Set default groups +### 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 +### END Substep 2 -## Substep 1: Remove user "orangepi" +### Substep 3: Remove user "orangepi" sudo userdel orangepi sudo rm -rf /home/orangepi -## END +### 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 +## 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 if [[ -f "/etc/orangepi-release" ]]; then @@ -88,7 +92,7 @@ if [[ -f "/etc/orangepi-release" ]]; then else echo_red "OrangePi release file not found! [SKIPPED]" fi -## END +## END Step 5 ## Step 6: Patch dynamic motd echo_green "Patch dynamic motd ..." @@ -97,32 +101,39 @@ 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 +## END Step 6 ## Step 7: Enable SPI interface by default echo_green "Enable SPI interface on Orange Pi SBC's ..." +## END Step 7 -# Substep 1: Copy default config to backup file +### 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 +### Substep 2: Enable SPI in armbianEnv.txt depending on device -## Orangepi Zero2 +#### Orangepi Zero2 if [[ "$(is_board_type)" == "orangepizero2" ]]; then echo "overlays=spi-spidev" >> "${ORANGEPI_CONFIG_TXT_FILE}" echo "param_spidev_spi_bus=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi +#### END -## OrangePi 3 LTS +#### OrangePi 3 LTS if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then echo "overlays=spi-spidev1" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi +#### END -## OrangePi 4 LTS +#### OrangePi 4 LTS if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then echo "overlays=spi-spidev" >> "${ORANGEPI_CONFIG_TXT_FILE}" echo "param_spidev_spi_bus=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi +#### END + +### END Substep 2 # Substep 3: add spi-dev module to /etc/modules echo "spi-dev" >> "${ORANGEPI_MODULES_FILE}" @@ -139,42 +150,42 @@ if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then if [[ ! -d "${ORANGEPI_OPI_CONFIG_TEMP}" ]]; then mkdir -p "${ORANGEPI_OPI_CONFIG_TEMP}" fi - ### END + ### 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 + ### 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 + ### 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 + ### 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 + ### END Substep 5 ### Substep 6: Link main script to /usr/bin/orangepi-config ln -sf "/usr/sbin/orangepi-config" "/usr/bin/orangepi-config" - ### END + ### END Substep 6 ### 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 + ### END Substep 7 else echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" fi -## END +## END Step 4 From 9f76d2f225375bc9562837c384aa484e17fb860c Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 14:03:42 +0100 Subject: [PATCH 39/73] fix: fix execute permission on main script Signed-off-by: Stephan Wendel --- src/modules/orangepi/start_chroot_script | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index 69d04ecbf..fd404e2f7 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -174,10 +174,16 @@ if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then cp -f "src/workspace/opi-config-src/${ORANGEPI_OPI_CONFIG_FILES_ARR[*]:0:1}" "/usr/sbin/orangepi-config" ### END Substep 5 - ### Substep 6: Link main script to /usr/bin/orangepi-config - ln -sf "/usr/sbin/orangepi-config" "/usr/bin/orangepi-config" + ### 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-}" From 47d471e8400b74b6909b5a32ae457e1f2c52d5fa Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 18:02:47 +0100 Subject: [PATCH 40/73] feat: enable uart and i2c by default This is based on https://github.com/nhchiu/Klipper-on-Orange-Pi-Zero-2#connect-to-mcu-through-uart-pins Signed-off-by: Stephan Wendel --- src/modules/orangepi/start_chroot_script | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index fd404e2f7..5cb9658a3 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -117,6 +117,7 @@ cp "${ORANGEPI_CONFIG_TXT_FILE}" "${ORANGEPI_CONFIG_BAK_FILE}" if [[ "$(is_board_type)" == "orangepizero2" ]]; then echo "overlays=spi-spidev" >> "${ORANGEPI_CONFIG_TXT_FILE}" echo "param_spidev_spi_bus=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" + echo "param_spidev_spi_cs=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi #### END @@ -195,3 +196,17 @@ else echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" fi ## END Step 4 + +## Step 5: Enable uart connection on ttyS5 Orangepi Zero2 +## Based on: https://github.com/nhchiu/Klipper-on-Orange-Pi-Zero-2#connect-to-mcu-through-uart-pins +if [[ "$(is_board_type)" == "orangepizero2" ]]; then + echo "overlays=uart5" >> "${ORANGEPI_CONFIG_TXT_FILE}" +fi +## END Step 5 + +## Step 6: Enable I2C on gpio pins +## Based on: https://github.com/nhchiu/Klipper-on-Orange-Pi-Zero-2#connect-to-mcu-through-uart-pins +if [[ "$(is_board_type)" == "orangepizero2" ]]; then + echo "overlays=i2c3" >> "${ORANGEPI_CONFIG_TXT_FILE}" +fi +## END Step 6 From 9a66ed73c800453536f7f13dcd25a265d31b68eb Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 18:12:40 +0100 Subject: [PATCH 41/73] chore: add message to Steps 5 and 6 Signed-off-by: Stephan Wendel --- src/modules/orangepi/start_chroot_script | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index 5cb9658a3..d1b1e45f6 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -199,6 +199,7 @@ fi ## Step 5: Enable uart connection on ttyS5 Orangepi Zero2 ## Based on: https://github.com/nhchiu/Klipper-on-Orange-Pi-Zero-2#connect-to-mcu-through-uart-pins +echo_green "Enable UART 5 (/dev/ttyS5) interface on Orange Pi SBC's ..." if [[ "$(is_board_type)" == "orangepizero2" ]]; then echo "overlays=uart5" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi @@ -206,6 +207,7 @@ fi ## Step 6: Enable I2C on gpio pins ## Based on: https://github.com/nhchiu/Klipper-on-Orange-Pi-Zero-2#connect-to-mcu-through-uart-pins +echo_green "Enable I2C interface on Orange Pi SBC's ..." if [[ "$(is_board_type)" == "orangepizero2" ]]; then echo "overlays=i2c3" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi From d601bfb6c99ff8c171ecd0422e903ccb6914e783 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 18:20:54 +0100 Subject: [PATCH 42/73] fix: fix step count and SC2129 error Signed-off-by: Stephan Wendel --- src/modules/orangepi/start_chroot_script | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index d1b1e45f6..c8f56c3e3 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -105,7 +105,6 @@ fi ## Step 7: Enable SPI interface by default echo_green "Enable SPI interface on Orange Pi SBC's ..." -## END Step 7 ### Substep 1: Copy default config to backup file cp "${ORANGEPI_CONFIG_TXT_FILE}" "${ORANGEPI_CONFIG_BAK_FILE}" @@ -115,9 +114,11 @@ cp "${ORANGEPI_CONFIG_TXT_FILE}" "${ORANGEPI_CONFIG_BAK_FILE}" #### Orangepi Zero2 if [[ "$(is_board_type)" == "orangepizero2" ]]; then - echo "overlays=spi-spidev" >> "${ORANGEPI_CONFIG_TXT_FILE}" - echo "param_spidev_spi_bus=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" - echo "param_spidev_spi_cs=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" + { + echo "overlays=spi-spidev" + echo "param_spidev_spi_bus=1" + echo "param_spidev_spi_cs=1" + } >> "${ORANGEPI_CONFIG_TXT_FILE}" fi #### END @@ -140,9 +141,9 @@ fi echo "spi-dev" >> "${ORANGEPI_MODULES_FILE}" echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" -## END +## END Step 7 -## Step 4: Install orangepi-config from git source repository +## Step 8: Install orangepi-config from git source repository if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then echo_green "Install orangepi-config from git sources ..." @@ -195,20 +196,20 @@ if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then else echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" fi -## END Step 4 +## END Step 8 -## Step 5: Enable uart connection on ttyS5 Orangepi Zero2 +## Step 9: Enable uart connection on ttyS5 Orangepi Zero2 ## Based on: https://github.com/nhchiu/Klipper-on-Orange-Pi-Zero-2#connect-to-mcu-through-uart-pins echo_green "Enable UART 5 (/dev/ttyS5) interface on Orange Pi SBC's ..." if [[ "$(is_board_type)" == "orangepizero2" ]]; then echo "overlays=uart5" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi -## END Step 5 +## END Step 9 -## Step 6: Enable I2C on gpio pins +## Step 10: Enable I2C on gpio pins ## Based on: https://github.com/nhchiu/Klipper-on-Orange-Pi-Zero-2#connect-to-mcu-through-uart-pins echo_green "Enable I2C interface on Orange Pi SBC's ..." if [[ "$(is_board_type)" == "orangepizero2" ]]; then echo "overlays=i2c3" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi -## END Step 6 +## END Step 10 From df4bb0f29b351ab65e56fe70d2d3073e514e9dca Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 18:45:02 +0100 Subject: [PATCH 43/73] chore: replace Armbian with Orange Pi OS in motd Signed-off-by: Stephan Wendel --- .../orangepi/filesystem/root/etc/update-motd.d/10-mainsailos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 db564e48c..a5f22022c 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 @@ -41,7 +41,7 @@ ODROID_EXCEPTION="$(tr -d '\000' < /proc/device-tree/model | grep ODROID | grep echo -e "\e[31m$(toilet -f big MainsailOS)\e[0m" echo -e "Version $(cut -d ' ' -f3 /etc/mainsailos-release), based on \ -\e[34mArmbian ${VERSION} ${DISTRIBUTION_CODENAME^}\e[0m $([[ ${BRANCH} == edge ]])" +\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" From fecf9b3ed1d179e52e492e135887b97bfe1c6139 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 18:59:31 +0100 Subject: [PATCH 44/73] chore: bump version to 1.1.0-alpha Signed-off-by: Stephan Wendel --- src/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 35b43cf03e7bb4860cafa8c3dc552bbc6f71402c Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 20:43:17 +0100 Subject: [PATCH 45/73] fix: fix overlay handling in orangepi module Signed-off-by: Stephan Wendel --- src/modules/orangepi/config | 8 +++- src/modules/orangepi/start_chroot_script | 47 +++++++----------------- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index 6caff8a77..62e0d0b34 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -11,13 +11,19 @@ # 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" -#### EXPERIMENTAL: Install orangepi-config from source git repo +## 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 overlays=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/start_chroot_script b/src/modules/orangepi/start_chroot_script index c8f56c3e3..2e05c8d4c 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -104,7 +104,7 @@ fi ## END Step 6 ## Step 7: Enable SPI interface by default -echo_green "Enable SPI interface on Orange Pi SBC's ..." +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}" @@ -113,25 +113,20 @@ cp "${ORANGEPI_CONFIG_TXT_FILE}" "${ORANGEPI_CONFIG_BAK_FILE}" ### Substep 2: Enable SPI in armbianEnv.txt depending on device #### Orangepi Zero2 -if [[ "$(is_board_type)" == "orangepizero2" ]]; then - { - echo "overlays=spi-spidev" - echo "param_spidev_spi_bus=1" - echo "param_spidev_spi_cs=1" - } >> "${ORANGEPI_CONFIG_TXT_FILE}" -fi -#### END +if [[ "$(is_board_type)" == "orangepizero2" ]] && +[[ "${ORANGEPI_ENABLE_OVERLAYS_OPIZ2}" == "true" ]]; then -#### OrangePi 3 LTS -if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then - echo "overlays=spi-spidev1" >> "${ORANGEPI_CONFIG_TXT_FILE}" -fi -#### END + if [[ -n "${ORANGEPI_ADD_OVERLAYS_OPIZ2}" ]]; then + echo_green "Adding overlays '${ORANGEPI_ADD_OVERLAYS_OPIZ2}' to ${ORANGEPI_CONFIG_TXT_FILE} ..." + echo "${ORANGEPI_ADD_OVERLAYS_OPIZ2}" >> "${ORANGEPI_CONFIG_TXT_FILE}" + fi -#### OrangePi 4 LTS -if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then - echo "overlays=spi-spidev" >> "${ORANGEPI_CONFIG_TXT_FILE}" - echo "param_spidev_spi_bus=1" >> "${ORANGEPI_CONFIG_TXT_FILE}" + 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 @@ -197,19 +192,3 @@ else echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" fi ## END Step 8 - -## Step 9: Enable uart connection on ttyS5 Orangepi Zero2 -## Based on: https://github.com/nhchiu/Klipper-on-Orange-Pi-Zero-2#connect-to-mcu-through-uart-pins -echo_green "Enable UART 5 (/dev/ttyS5) interface on Orange Pi SBC's ..." -if [[ "$(is_board_type)" == "orangepizero2" ]]; then - echo "overlays=uart5" >> "${ORANGEPI_CONFIG_TXT_FILE}" -fi -## END Step 9 - -## Step 10: Enable I2C on gpio pins -## Based on: https://github.com/nhchiu/Klipper-on-Orange-Pi-Zero-2#connect-to-mcu-through-uart-pins -echo_green "Enable I2C interface on Orange Pi SBC's ..." -if [[ "$(is_board_type)" == "orangepizero2" ]]; then - echo "overlays=i2c3" >> "${ORANGEPI_CONFIG_TXT_FILE}" -fi -## END Step 10 From 2deb65e53c7512f7ff9e8b060b9856274f71d0d7 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 20:44:35 +0100 Subject: [PATCH 46/73] fix: fix typo in overlay handling Signed-off-by: Stephan Wendel --- src/modules/orangepi/config | 2 +- src/modules/orangepi/start_chroot_script | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index 62e0d0b34..6196ce5f7 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -20,7 +20,7 @@ bash-completion" ## 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 overlays=spi-spidev" +[[ -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 diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index 2e05c8d4c..cb2596e55 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -118,7 +118,7 @@ if [[ "$(is_board_type)" == "orangepizero2" ]] && if [[ -n "${ORANGEPI_ADD_OVERLAYS_OPIZ2}" ]]; then echo_green "Adding overlays '${ORANGEPI_ADD_OVERLAYS_OPIZ2}' to ${ORANGEPI_CONFIG_TXT_FILE} ..." - echo "${ORANGEPI_ADD_OVERLAYS_OPIZ2}" >> "${ORANGEPI_CONFIG_TXT_FILE}" + echo "overlays=${ORANGEPI_ADD_OVERLAYS_OPIZ2}" >> "${ORANGEPI_CONFIG_TXT_FILE}" fi if [[ -n "${ORANGEPI_ADD_OVERLAYS_OPIZ2_PARAMS}" ]]; then From acb83bff5bb47f6cbc4446f20dac573740088be5 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 25 Feb 2023 22:03:08 +0100 Subject: [PATCH 47/73] chore: update readme Signed-off-by: Stephan Wendel --- README.md | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1eccb7e80..2718008cb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,13 @@ # MainsailOS -A [Raspberry Pi OS](https://www.raspberrypi.org/software/) based distribution for 3D Printers. \ +A Linux Distribution based on + +- [Raspberry Pi OS](https://www.raspberrypi.org/software/) for Raspberry SBC's +- [Armbian](https://www.armbian.com/) for several SBC's +- [Orange Pi OS](http://www.orangepi.org/html/softWare/orangePiOS/index.html) for Orange Pi Zero 2 + +to run your 3D Printers with [mainsail](https://github.com/mainsail-crew/mainsail). \ It includes everything to get started with Klipper Firmware and Mainsail. Learn more about: @@ -15,12 +21,30 @@ Learn more about: - [Klipper Firmware](https://www.klipper3d.org/) - [Moonraker](https://moonraker.readthedocs.io/en/latest/) - [Mainsail](https://docs.mainsail.xyz/) +- [Crowsnest](https://github.com/mainsail-crew/crowsnest) +- [Sonar](https://github.com/mainsail-crew/sonar) ## How to install MainsailOS ? You can find detailed instructions in our [documentation](https://docs.mainsail.xyz/setup/mainsail-os). -We recommend the installation via [Raspberry Pi Imager](https://docs.mainsail.xyz/setup/mainsailos/pi-imager). +We recommend the installation for Raspberry images via [Raspberry Pi Imager](https://docs.mainsail.xyz/setup/mainsailos/pi-imager). + +For other images, we recommend [balena-etcher](https://www.balena.io/etcher). + +## Currently supported Single Board Computer's (SBC) + +| Single Board Computer | OS based on | 32/64bit | +| :-------------------: | :--------------------------------------------------------------------------------: | :--------: | +| Raspberry Pi | [Raspberry Pi OS lite](https://www.raspberrypi.org/software/) | 32/64bit | +| Orange Pi Zero 2 | [Orange Pi OS server](http://www.orangepi.org/html/softWare/orangePiOS/index.html) | 64bit only | +| Orange Pi 3 LTS | [Armbian cli minimal](https://www.armbian.com/) | 64bit only | +| Orange Pi 4 LTS | [Armbian cli minimal](https://www.armbian.com/) | 64bit only | + +_NOTE: Raspberry Pi Models Zero, 2 and 1 are not recommended, even they might run with_ + +Hopefully, we can improve existing images and add more SBC's.\ +Hardware donations for testing and developing are welcome :wink: ## How to get help? @@ -44,7 +68,9 @@ Here a list of included and preinstalled Software: ## also includes - Enabled Serial Connection by default. \ - Using Hardware UART (PL011) for Boards like BTT SKR Mini E3 V3 + Using Hardware UART (PL011) for Boards like BTT SKR Mini E3 V3 on Raspberry Pi's + Using UART5 on Orange Pi Zero2 (/dev/ttyS5) +- Enabled i2c and SPI for Raspberry and Orange Pi Zero 2 - Preinstalled Dependencies for Klipper's Input Shaper. \ You only need to build the [klipper_mcu](https://www.klipper3d.org/RPi_microcontroller.html) and installing the service. \ See [Klipper documentation](https://www.klipper3d.org/Measuring_Resonances.html) for more information. From fcf460430a8eb36b62740d0273e08947ebfc7c44 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Mon, 27 Feb 2023 16:59:10 +0100 Subject: [PATCH 48/73] chore: revert update of readme Signed-off-by: Stephan Wendel --- README.md | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 2718008cb..1eccb7e80 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,7 @@ # MainsailOS -A Linux Distribution based on - -- [Raspberry Pi OS](https://www.raspberrypi.org/software/) for Raspberry SBC's -- [Armbian](https://www.armbian.com/) for several SBC's -- [Orange Pi OS](http://www.orangepi.org/html/softWare/orangePiOS/index.html) for Orange Pi Zero 2 - -to run your 3D Printers with [mainsail](https://github.com/mainsail-crew/mainsail). \ +A [Raspberry Pi OS](https://www.raspberrypi.org/software/) based distribution for 3D Printers. \ It includes everything to get started with Klipper Firmware and Mainsail. Learn more about: @@ -21,30 +15,12 @@ Learn more about: - [Klipper Firmware](https://www.klipper3d.org/) - [Moonraker](https://moonraker.readthedocs.io/en/latest/) - [Mainsail](https://docs.mainsail.xyz/) -- [Crowsnest](https://github.com/mainsail-crew/crowsnest) -- [Sonar](https://github.com/mainsail-crew/sonar) ## How to install MainsailOS ? You can find detailed instructions in our [documentation](https://docs.mainsail.xyz/setup/mainsail-os). -We recommend the installation for Raspberry images via [Raspberry Pi Imager](https://docs.mainsail.xyz/setup/mainsailos/pi-imager). - -For other images, we recommend [balena-etcher](https://www.balena.io/etcher). - -## Currently supported Single Board Computer's (SBC) - -| Single Board Computer | OS based on | 32/64bit | -| :-------------------: | :--------------------------------------------------------------------------------: | :--------: | -| Raspberry Pi | [Raspberry Pi OS lite](https://www.raspberrypi.org/software/) | 32/64bit | -| Orange Pi Zero 2 | [Orange Pi OS server](http://www.orangepi.org/html/softWare/orangePiOS/index.html) | 64bit only | -| Orange Pi 3 LTS | [Armbian cli minimal](https://www.armbian.com/) | 64bit only | -| Orange Pi 4 LTS | [Armbian cli minimal](https://www.armbian.com/) | 64bit only | - -_NOTE: Raspberry Pi Models Zero, 2 and 1 are not recommended, even they might run with_ - -Hopefully, we can improve existing images and add more SBC's.\ -Hardware donations for testing and developing are welcome :wink: +We recommend the installation via [Raspberry Pi Imager](https://docs.mainsail.xyz/setup/mainsailos/pi-imager). ## How to get help? @@ -68,9 +44,7 @@ Here a list of included and preinstalled Software: ## also includes - Enabled Serial Connection by default. \ - Using Hardware UART (PL011) for Boards like BTT SKR Mini E3 V3 on Raspberry Pi's - Using UART5 on Orange Pi Zero2 (/dev/ttyS5) -- Enabled i2c and SPI for Raspberry and Orange Pi Zero 2 + Using Hardware UART (PL011) for Boards like BTT SKR Mini E3 V3 - Preinstalled Dependencies for Klipper's Input Shaper. \ You only need to build the [klipper_mcu](https://www.klipper3d.org/RPi_microcontroller.html) and installing the service. \ See [Klipper documentation](https://www.klipper3d.org/Measuring_Resonances.html) for more information. From 196c66c075adc288b7dceda9428dd88073dec117 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 3 Mar 2023 23:00:38 +0100 Subject: [PATCH 49/73] test: test permissions on /boot Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 48dd5226f..7c0a0c6b9 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -43,6 +43,8 @@ if_group_exists_run() { # Will be removed in cleanup echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers +## Test: fake dpkg +alias dpkg="sudo dpkg" ## Step 1: Install armbian specific packages apt update From c1b0ac9eaa243ce7c0f5257c2161128c8d651617 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 3 Mar 2023 23:09:43 +0100 Subject: [PATCH 50/73] test: test permissions on /boot Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 7c0a0c6b9..03aa42424 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -45,6 +45,7 @@ echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers ## Test: fake dpkg alias dpkg="sudo dpkg" +alias ln="sudo ln" ## Step 1: Install armbian specific packages apt update From 4ed7f3908748d2c906535b2950e213bab7f9abda Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 3 Mar 2023 23:18:32 +0100 Subject: [PATCH 51/73] revert: revert test Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 03aa42424..914054cd5 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -43,10 +43,6 @@ if_group_exists_run() { # Will be removed in cleanup echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers -## Test: fake dpkg -alias dpkg="sudo dpkg" -alias ln="sudo ln" - ## Step 1: Install armbian specific packages apt update # shellcheck disable=SC2086 From 99d5a115c5796c73b1f9019c5d10a1e8608119ea Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 3 Mar 2023 23:29:51 +0100 Subject: [PATCH 52/73] chore: wip Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- src/modules/armbian/config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/armbian/default b/config/armbian/default index 09216febc..13d423bec 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,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,armbian,pkgupgrade(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL diff --git a/src/modules/armbian/config b/src/modules/armbian/config index c36fa8a01..28284932b 100644 --- a/src/modules/armbian/config +++ b/src/modules/armbian/config @@ -12,7 +12,7 @@ # shellcheck disable=all [[ -n "$ARMBIAN_DEPS" ]] || ARMBIAN_DEPS="armbian-config avahi-daemon iptables \ -bash-completion" +bash-completion apt-utils" [[ -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" From 05f2ec111d9bf289756a3a194fc10fdeddf1a473 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 3 Mar 2023 23:45:31 +0100 Subject: [PATCH 53/73] Revert "chore: wip" This reverts commit 99d5a115c5796c73b1f9019c5d10a1e8608119ea. --- config/armbian/default | 2 +- src/modules/armbian/config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/armbian/default b/config/armbian/default index 13d423bec..09216febc 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_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,pkgupgrade,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/config b/src/modules/armbian/config index 28284932b..c36fa8a01 100644 --- a/src/modules/armbian/config +++ b/src/modules/armbian/config @@ -12,7 +12,7 @@ # shellcheck disable=all [[ -n "$ARMBIAN_DEPS" ]] || ARMBIAN_DEPS="armbian-config avahi-daemon iptables \ -bash-completion apt-utils" +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" From 04e683cae154cf43690e96150f65400b886dea4a Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 11:18:37 +0100 Subject: [PATCH 54/73] test: build test with sudo as dependency Signed-off-by: Stephan Wendel --- config/armbian/default | 4 +++- src/modules/armbian/config | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/armbian/default b/config/armbian/default index 09216febc..0c2faf43d 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -23,7 +23,9 @@ BASE_IMAGE_RESIZEROOT=600 # Compress not needed due compression done in workflow BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images -MODULES="base,pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +#MODULES="base,pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,armbian,pkgupgrade(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" + # export Variables export DOWNLOAD_BASE_URL diff --git a/src/modules/armbian/config b/src/modules/armbian/config index c36fa8a01..40de72b2f 100644 --- a/src/modules/armbian/config +++ b/src/modules/armbian/config @@ -11,7 +11,7 @@ # shellcheck disable=all -[[ -n "$ARMBIAN_DEPS" ]] || ARMBIAN_DEPS="armbian-config avahi-daemon iptables \ +[[ -n "$ARMBIAN_DEPS" ]] || ARMBIAN_DEPS="sudo 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" From 87f460501822247fbecc4b0040321d4b4ef95480 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 11:31:56 +0100 Subject: [PATCH 55/73] Revert "test: build test with sudo as dependency" This reverts commit 04e683cae154cf43690e96150f65400b886dea4a. --- config/armbian/default | 4 +--- src/modules/armbian/config | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/config/armbian/default b/config/armbian/default index 0c2faf43d..09216febc 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -23,9 +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,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" -MODULES="base,armbian,pkgupgrade(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" - +MODULES="base,pkgupgrade,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/config b/src/modules/armbian/config index 40de72b2f..c36fa8a01 100644 --- a/src/modules/armbian/config +++ b/src/modules/armbian/config @@ -11,7 +11,7 @@ # shellcheck disable=all -[[ -n "$ARMBIAN_DEPS" ]] || ARMBIAN_DEPS="sudo 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" From 1cab7901c0663286696e73b1c48e76e3d1acaead Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 11:39:09 +0100 Subject: [PATCH 56/73] test: install sudo in pre_chroot_script Signed-off-by: Stephan Wendel --- src/modules/armbian/pre_chroot_script | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/modules/armbian/pre_chroot_script diff --git a/src/modules/armbian/pre_chroot_script b/src/modules/armbian/pre_chroot_script new file mode 100644 index 000000000..c982a48e7 --- /dev/null +++ b/src/modules/armbian/pre_chroot_script @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +#### 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 -Ee + +# Source CustomPIOS common.sh +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + +## Install sudo before chrooting +DEBIAN_FRONTEND=noninteractive +export DEBIAN_FRONTEND +apt-get update --allow-releaseinfo-change +apt-get install --yes --assume-yes + +unset DEBIAN_FRONTEND From 893e201a216e7cec5a4a922ac5be605c4eed858b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 11:39:55 +0100 Subject: [PATCH 57/73] fix: fix typo in test Signed-off-by: Stephan Wendel --- src/modules/armbian/pre_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/armbian/pre_chroot_script b/src/modules/armbian/pre_chroot_script index c982a48e7..39ee5949d 100644 --- a/src/modules/armbian/pre_chroot_script +++ b/src/modules/armbian/pre_chroot_script @@ -21,6 +21,6 @@ install_cleanup_trap DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND apt-get update --allow-releaseinfo-change -apt-get install --yes --assume-yes +apt-get install --yes --assume-yes sudo unset DEBIAN_FRONTEND From a1688066984fcccb532dd92d3e20d28c64116f76 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 11:57:55 +0100 Subject: [PATCH 58/73] test: change module order Signed-off-by: Stephan Wendel --- config/armbian/default | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/armbian/default b/config/armbian/default index 09216febc..9e94bc9db 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -23,7 +23,8 @@ 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,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +# MODULES="base,pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,armbian(pkgupgrade,armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL From 2d92c4ecef2687767b573c79a364fcbd2a043f2f Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 12:11:01 +0100 Subject: [PATCH 59/73] chore: wip Signed-off-by: Stephan Wendel --- config/armbian/default | 3 +-- .../pre_chroot_script => armbian_fix/start_chroot_script} | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) rename src/modules/{armbian/pre_chroot_script => armbian_fix/start_chroot_script} (92%) diff --git a/config/armbian/default b/config/armbian/default index 9e94bc9db..10ecdbaa6 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -24,8 +24,7 @@ BASE_IMAGE_RESIZEROOT=600 BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images # MODULES="base,pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" -MODULES="base,armbian(pkgupgrade,armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" - +MODULES="base,armbian_fix,pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL export BASE_ADD_USER diff --git a/src/modules/armbian/pre_chroot_script b/src/modules/armbian_fix/start_chroot_script similarity index 92% rename from src/modules/armbian/pre_chroot_script rename to src/modules/armbian_fix/start_chroot_script index 39ee5949d..ce36a1605 100644 --- a/src/modules/armbian/pre_chroot_script +++ b/src/modules/armbian_fix/start_chroot_script @@ -21,6 +21,6 @@ install_cleanup_trap DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND apt-get update --allow-releaseinfo-change -apt-get install --yes --assume-yes sudo +apt-get install --yes --assume-yes sudo apt-util unset DEBIAN_FRONTEND From c919c336dde2f1e7c4bdfb587a6eb23abcfe7cce Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 12:19:33 +0100 Subject: [PATCH 60/73] fix: fix package name Signed-off-by: Stephan Wendel --- src/modules/armbian_fix/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/armbian_fix/start_chroot_script b/src/modules/armbian_fix/start_chroot_script index ce36a1605..b0a1cadd5 100644 --- a/src/modules/armbian_fix/start_chroot_script +++ b/src/modules/armbian_fix/start_chroot_script @@ -21,6 +21,6 @@ install_cleanup_trap DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND apt-get update --allow-releaseinfo-change -apt-get install --yes --assume-yes sudo apt-util +apt-get install --yes --assume-yes sudo apt-utils unset DEBIAN_FRONTEND From 3311114f8b8a1131470a6240036340027ff01d08 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 12:34:45 +0100 Subject: [PATCH 61/73] test: remove links and kernel package content Signed-off-by: Stephan Wendel --- src/modules/armbian_fix/start_chroot_script | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/armbian_fix/start_chroot_script b/src/modules/armbian_fix/start_chroot_script index b0a1cadd5..3c2d74062 100644 --- a/src/modules/armbian_fix/start_chroot_script +++ b/src/modules/armbian_fix/start_chroot_script @@ -24,3 +24,8 @@ apt-get update --allow-releaseinfo-change apt-get install --yes --assume-yes sudo apt-utils unset DEBIAN_FRONTEND + + +rm -rf /boot/Image +rm -rf /boot/vmlinuz* +rm -rf /boot/System.map* From 78bb7f7e74ada7a3bdaa9e195b43e37ed797396e Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 16:26:36 +0100 Subject: [PATCH 62/73] chore: wip Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- src/modules/armbian_fix/start_chroot_script | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/armbian/default b/config/armbian/default index 10ecdbaa6..436abf5de 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -24,7 +24,7 @@ BASE_IMAGE_RESIZEROOT=600 BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images # MODULES="base,pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" -MODULES="base,armbian_fix,pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,armbian_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL export BASE_ADD_USER diff --git a/src/modules/armbian_fix/start_chroot_script b/src/modules/armbian_fix/start_chroot_script index 3c2d74062..48511cd66 100644 --- a/src/modules/armbian_fix/start_chroot_script +++ b/src/modules/armbian_fix/start_chroot_script @@ -23,9 +23,11 @@ export DEBIAN_FRONTEND apt-get update --allow-releaseinfo-change apt-get install --yes --assume-yes sudo apt-utils -unset DEBIAN_FRONTEND +## Set kernel package on hold +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 +apt-get upgrade --yes --assume-yes -rm -rf /boot/Image -rm -rf /boot/vmlinuz* -rm -rf /boot/System.map* +unset DEBIAN_FRONTEND From 0c6fd60e002f13443ad059607d22737bf46c7d1e Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 16:27:45 +0100 Subject: [PATCH 63/73] chore: wip Signed-off-by: Stephan Wendel --- src/modules/armbian_fix/start_chroot_script | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/armbian_fix/start_chroot_script b/src/modules/armbian_fix/start_chroot_script index 48511cd66..e2cc02092 100644 --- a/src/modules/armbian_fix/start_chroot_script +++ b/src/modules/armbian_fix/start_chroot_script @@ -28,6 +28,12 @@ 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 +## Run full upgrade apt-get upgrade --yes --assume-yes +## Revert hold status +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 + unset DEBIAN_FRONTEND From 3dd5c9c83189d9678b9333ac436ed3399fdbc58f Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 5 Mar 2023 16:53:37 +0100 Subject: [PATCH 64/73] chore: wip Signed-off-by: Stephan Wendel --- src/modules/armbian_fix/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/armbian_fix/start_chroot_script b/src/modules/armbian_fix/start_chroot_script index e2cc02092..64b18ce58 100644 --- a/src/modules/armbian_fix/start_chroot_script +++ b/src/modules/armbian_fix/start_chroot_script @@ -21,7 +21,7 @@ install_cleanup_trap DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND apt-get update --allow-releaseinfo-change -apt-get install --yes --assume-yes sudo apt-utils +apt-get install --yes --assume-yes sudo apt-utils wget ## Set kernel package on hold echo "armbian-firmware hold" | dpkg --set-selections From 1f758a15c0fabde4b4768bdc360bea79625b53ce Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 9 Mar 2023 19:55:14 +0100 Subject: [PATCH 65/73] fix: fix network_config service Signed-off-by: Stephan Wendel --- src/modules/armbian_fix/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/armbian_fix/start_chroot_script b/src/modules/armbian_fix/start_chroot_script index 64b18ce58..13d810b0f 100644 --- a/src/modules/armbian_fix/start_chroot_script +++ b/src/modules/armbian_fix/start_chroot_script @@ -21,7 +21,7 @@ install_cleanup_trap DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND apt-get update --allow-releaseinfo-change -apt-get install --yes --assume-yes sudo apt-utils wget +apt-get install --yes --assume-yes sudo apt-utils wget net-tools ## Set kernel package on hold echo "armbian-firmware hold" | dpkg --set-selections From 7f39dac11262da96b05f177132a36d741075f13b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 9 Mar 2023 20:40:24 +0100 Subject: [PATCH 66/73] fix: fixes failed build due kernel update See start_chroot_script for detailed description Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- .../start_chroot_script | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) rename src/modules/{armbian_fix => armbian_pkgupgrade}/start_chroot_script (71%) diff --git a/config/armbian/default b/config/armbian/default index 436abf5de..08b2eea37 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -24,7 +24,7 @@ BASE_IMAGE_RESIZEROOT=600 BASE_RELEASE_COMPRESS=no # Modules are valid for 32bit and 64bit images # MODULES="base,pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" -MODULES="base,armbian_fix,armbian(armbian_net,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 export BASE_ADD_USER diff --git a/src/modules/armbian_fix/start_chroot_script b/src/modules/armbian_pkgupgrade/start_chroot_script similarity index 71% rename from src/modules/armbian_fix/start_chroot_script rename to src/modules/armbian_pkgupgrade/start_chroot_script index 13d810b0f..a8d57ebe3 100644 --- a/src/modules/armbian_fix/start_chroot_script +++ b/src/modules/armbian_pkgupgrade/start_chroot_script @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### MainsailOS Specific Tweaks for armbian images +#### MainsailOS Specific procedure for armbian images to replace 'pkgupgrade' module #### #### Written by Stephan Wendel aka KwadFan #### Copyright 2023 - till today @@ -8,6 +8,12 @@ #### 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 @@ -17,7 +23,8 @@ set -Ee source /common.sh install_cleanup_trap -## Install sudo before chrooting +## 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 From ad7320863c916be67e7c919da8d74d679a230a08 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Mar 2023 17:39:00 +0100 Subject: [PATCH 67/73] chore: test with v23.02 images --- config/armbian/default | 3 ++- config/orangepi/default | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/armbian/default b/config/armbian/default index 08b2eea37..b64ddd950 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -5,7 +5,8 @@ # See https://www.shellcheck.net/wiki/SC2155 # Download Base Url -DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" +#DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" +DOWNLOAD_BASE_URL="http://images.mainsail.xyz/v23.02" # Base User BASE_ADD_USER="yes" diff --git a/config/orangepi/default b/config/orangepi/default index 96a23ebbb..63eac5efc 100644 --- a/config/orangepi/default +++ b/config/orangepi/default @@ -5,7 +5,8 @@ # See https://www.shellcheck.net/wiki/SC2155 # Download Base Url -DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" +#DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" +DOWNLOAD_BASE_URL="http://images.mainsail.xyz/v23.02" # Base User BASE_ADD_USER="yes" From 527cab0b64b630ed78dc9b45f032d90c916321d9 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 11 Mar 2023 18:06:00 +0100 Subject: [PATCH 68/73] fix: set hold packages depending on board type Signed-off-by: Stephan Wendel --- .../armbian_pkgupgrade/start_chroot_script | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/modules/armbian_pkgupgrade/start_chroot_script b/src/modules/armbian_pkgupgrade/start_chroot_script index a8d57ebe3..7090d0e5d 100644 --- a/src/modules/armbian_pkgupgrade/start_chroot_script +++ b/src/modules/armbian_pkgupgrade/start_chroot_script @@ -23,6 +23,18 @@ set -Ee 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 @@ -31,16 +43,36 @@ apt-get update --allow-releaseinfo-change apt-get install --yes --assume-yes sudo apt-utils wget net-tools ## Set kernel package on hold -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 +### 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 -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 +### 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 60af3dd1e70b8d17505f6b82a26294fe64914100 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 12 Mar 2023 11:05:01 +0100 Subject: [PATCH 69/73] fix: patch release file location Patching armbian scripts for new release file location needed due some services relie on that file Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 39 +++++++++++++++++-------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 914054cd5..2379cae60 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -67,12 +67,25 @@ fi ## END ## Step 5: Move armbian-release to display mainsailos-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 +### 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 6: Patch dynamic motd @@ -87,24 +100,26 @@ fi ## 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 +### Substep 1: Copy default config to backup file cp "${ARMBIAN_CONFIG_TXT_FILE}" "${ARMBIAN_CONFIG_BAK_FILE}" +### END Substep 1 -# Substep: Enable SPI in armbianEnv.txt depending on device - -## OrangePi 3 LTS +### 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 +#### 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 +### 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 From 332c95ab89bb76b9161b5fd12b43cf7c78209e23 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 12 Mar 2023 11:38:59 +0100 Subject: [PATCH 70/73] fix: fix gpio permissions Also add to some basic groups Signed-off-by: Stephan Wendel --- .../filesystem/root/etc/udev/rules.d/97-gpio.rules | 1 + src/modules/armbian/start_chroot_script | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 src/modules/armbian/filesystem/root/etc/udev/rules.d/97-gpio.rules 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/start_chroot_script b/src/modules/armbian/start_chroot_script index 2379cae60..fa4744f51 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -50,11 +50,17 @@ check_install_pkgs ${ARMBIAN_DEPS} -# set groups +## 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 -## Step 2: Set default groups +## 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 From 1e294e1ac71a348445a78ce203a0310b01bfb66f Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 12 Mar 2023 16:07:23 +0100 Subject: [PATCH 71/73] chore: change base_url back to mainsail-crew/armbian-builds --- config/armbian/default | 3 +-- config/orangepi/default | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/config/armbian/default b/config/armbian/default index b64ddd950..08b2eea37 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -5,8 +5,7 @@ # See https://www.shellcheck.net/wiki/SC2155 # Download Base Url -#DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" -DOWNLOAD_BASE_URL="http://images.mainsail.xyz/v23.02" +DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" # Base User BASE_ADD_USER="yes" diff --git a/config/orangepi/default b/config/orangepi/default index 63eac5efc..96a23ebbb 100644 --- a/config/orangepi/default +++ b/config/orangepi/default @@ -5,8 +5,7 @@ # See https://www.shellcheck.net/wiki/SC2155 # Download Base Url -#DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" -DOWNLOAD_BASE_URL="http://images.mainsail.xyz/v23.02" +DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download" # Base User BASE_ADD_USER="yes" From 46f8878a5ffd7408c48eabe7c37960accd0df790 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 12 Mar 2023 18:23:57 +0100 Subject: [PATCH 72/73] chore: remove enduser support message Signed-off-by: Stephan Wendel --- .../root/etc/update-motd.d/10-mainsailos | 21 ------------------- 1 file changed, 21 deletions(-) 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 From e074b0cafa229902c2ab7332e42ab51c0144cd9a Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 15 Mar 2023 16:47:19 +0100 Subject: [PATCH 73/73] chore: remove unneeded comment in default config Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/armbian/default b/config/armbian/default index 08b2eea37..f8efce374 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -23,8 +23,8 @@ 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,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 export BASE_ADD_USER