diff --git a/.github/workflow_config.yml b/.github/workflow_config.yml index 292eafac3..3c4b4c1e9 100644 --- a/.github/workflow_config.yml +++ b/.github/workflow_config.yml @@ -24,6 +24,8 @@ buildtest: # Raspberry Pi OS based images - raspberry/rpi32 - raspberry/rpi64 + # rpi 64 with KS + - raspberry/rpi64-ks # This is used to setup release build chain. # Each entry will be used in setup matrix for releases diff --git a/config/raspberry/rpi64-ks b/config/raspberry/rpi64-ks new file mode 100644 index 000000000..40db48dc6 --- /dev/null +++ b/config/raspberry/rpi64-ks @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Shebang for better file detection + +# Declare Variables before exporting. +# See https://www.shellcheck.net/wiki/SC2155 + +BASE_ARCH="arm64" + +# Keep for Bookworm template +# DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" +# DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" + +# New locations after Bullseye turned into 'oldstable' +DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-10-10/2023-05-03-raspios-bullseye-arm64-lite.img.xz.sha256" +DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-10-10/2023-05-03-raspios-bullseye-arm64-lite.img.xz.torrent" + + +# Changed modules +# shellcheck disable=SC2034 +MODULES="base,pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,klipperscreen,crowsnest,sonar,password-for-sudo),postrename" + + +# export variables +export BASE_ARCH +export DOWNLOAD_URL_CHECKSUM +export DOWNLOAD_URL_IMAGE + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_SUPPORTED_SBC="pi3-64bit pi4-64bit" diff --git a/src/modules/klipperscreen/config b/src/modules/klipperscreen/config new file mode 100644 index 000000000..0c5244fd4 --- /dev/null +++ b/src/modules/klipperscreen/config @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +#Shebang for better file detection +#### KlipperScreen install module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2024 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +[ -n "$KLIPPERSCREEN_REPO_SHIP" ] || KLIPPERSCREEN_REPO_SHIP=https://github.com/KlipperScreen/KlipperScreen.git +[ -n "$KLIPPERSCREEN_REPO_BRANCH" ] || KLIPPERSCREEN_REPO_BRANCH=master diff --git a/src/modules/klipperscreen/filesystem/tmp/ks_update_entry.txt b/src/modules/klipperscreen/filesystem/tmp/ks_update_entry.txt new file mode 100644 index 000000000..83e3daab8 --- /dev/null +++ b/src/modules/klipperscreen/filesystem/tmp/ks_update_entry.txt @@ -0,0 +1,9 @@ + +[update_manager KlipperScreen] +type: git_repo +path: ~/KlipperScreen +origin: https://github.com/KlipperScreen/KlipperScreen.git +virtualenv: ~/.KlipperScreen-env +requirements: scripts/KlipperScreen-requirements.txt +system_dependencies: scripts/system-dependencies.json +managed_services: KlipperScreen diff --git a/src/modules/klipperscreen/start_chroot_script b/src/modules/klipperscreen/start_chroot_script new file mode 100644 index 000000000..5ee17d649 --- /dev/null +++ b/src/modules/klipperscreen/start_chroot_script @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +#### KlipperScreen install module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2024 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### +# shellcheck 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 + +# Module only Variables +KS_BUILD_INSTALL_SH="/home/${BASE_USER}/KlipperScreen/scripts/KlipperScreen-install.sh" +KS_MOONRAKER_CONF_PATH="/home/${BASE_USER}/printer_data/config/moonraker.conf" + +echo_green "Installing KlipperScreen and enable KlipperScreen Service ..." + +## Force apt update +apt-get update +## Make sure 'git' is installed! +check_install_pkgs git + +## Step 1: Move to Home Dir as WorkingDirectoy +pushd "/home/${BASE_USER}" &> /dev/null || exit 1 + +## Step 2: clone KlipperScreen repo +gitclone KLIPPERSCREEN_REPO KlipperScreen + +## Step 3: Move to KlipperScreen as working directory +pushd "/home/${BASE_USER}/KlipperScreen" &> /dev/null || exit 1 + +## Step 4: Run KlipperScreen install routine +echo_green "Launch KlipperScreen install routine ..." +sudo -u "${BASE_USER}" "${KS_BUILD_INSTALL_SH}" + +## Step 5: Update moonraker.conf +if [[ -f "${KS_MOONRAKER_CONF_PATH}" ]]; then + echo_green "Copying temporary file ..." + unpack /filesystem/tmp /tmp root + cat /tmp/ks_update_entry.txt >> "${KS_MOONRAKER_CONF_PATH}" +else + echo_red "File moonraker.conf not found ... [SKIPPED]" +fi + +## Step 6: Leave KlipperScreen +popd &> /dev/null || exit 1 + +## Step 7: leave home dir +popd &> /dev/null || exit 1 + +## Step 8: Enable service +echo_green "Enable KlipperScreen.service ..." +systemctl_if_exists enable KlipperScreen.service + +## Finish +echo_green "Installing KlipperScreen and enable KlipperScreen Service ... DONE!" diff --git a/src/modules/postrename/filesystem/root/postrename b/src/modules/postrename/filesystem/root/postrename index 0cef0f1f9..afd2f994f 100644 --- a/src/modules/postrename/filesystem/root/postrename +++ b/src/modules/postrename/filesystem/root/postrename @@ -31,6 +31,11 @@ SERVICES=(moonraker klipper nginx sonar crowsnest) SYSTEMD_DIR="/etc/systemd/system" DEFAULT_USER="$(grep "1000" /etc/passwd | awk -F ':' '{print $1}')" +### KlipperScreen workaround +KS_INSTALLED="$(find /home/"${DEFAULT_USER}" -name "KlipperScreen" | wc -l)" +if [[ "${KS_INSTALLED}" = "1" ]]; then + SERVICES+=(KlipperScreen) +fi ## Helper funcs ### Mangle services @@ -90,6 +95,11 @@ relocate_venv() { local -a venvs venvs=(klippy-env moonraker-env) + ### KlipperScreen workaround + if [[ "${KS_INSTALLED}" = "1" ]]; then + venvs+=(.KlipperScreen-env) + fi + for venv in "${venvs[@]}"; do # Move venv # delete pycache (*.pyc files) @@ -116,6 +126,15 @@ patch_polkit_rules() { if [[ -f "${polkit_legacy_dir}/10-moonraker.pkla" ]]; then sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_legacy_dir}/10-moonraker.pkla" fi + if [[ -f "${polkit_dir}/KlipperScreen.rules" ]]; then + sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_dir}/KlipperScreen.rules" + fi + if [[ -f "${polkit_usr_dir}/KlipperScreen.rules" ]]; then + sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_usr_dir}/KlipperScreen.rules" + fi + if [[ -f "${polkit_legacy_dir}/20-klipperscreen.pkla" ]]; then + sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_legacy_dir}/20-klipperscreen.pkla" + fi } patch_cn_logpath() { @@ -174,7 +193,6 @@ fix_kiauh_links() { ln -sf "${src_dir}/kiauh.sh" "${target_dir}/kiauh" } - fix_cn_links() { local tools_dir tools_dir="/home/${DEFAULT_USER}/crowsnest/tools"