Skip to content

Commit

Permalink
chore: update modules according to path changes (#166)
Browse files Browse the repository at this point in the history
Update several modules to match new file paths introduced due moonraker changes.

For Details see Arksine/moonraker#516

Signed-off-by: Stephan Wendel <[email protected]>
  • Loading branch information
KwadFan authored Nov 21, 2022
1 parent cb0bf60 commit e5943af
Show file tree
Hide file tree
Showing 27 changed files with 528 additions and 374 deletions.
2 changes: 1 addition & 1 deletion config/raspberry/default
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Declare Variables before exporting.
# See https://www.shellcheck.net/wiki/SC2155

BASE_IMAGE_ENLARGEROOT=2500
BASE_IMAGE_ENLARGEROOT=3000
BASE_IMAGE_RESIZEROOT=600
# Compress not needed due compression done in workflow
BASE_RELEASE_COMPRESS=no
Expand Down
36 changes: 21 additions & 15 deletions src/modules/crowsnest/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@
#### crowsnest - A webcam Service for multiple Cams and Stream Services.
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021
#### Copyright 2021 - 2022
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
####
# shellcheck disable=all

# crowsnest
[ -n "$CROWSNEST_CROWSNEST_REPO_SHIP" ] || CROWSNEST_CROWSNEST_REPO_SHIP=https://github.com/mainsail-crew/crowsnest.git
[ -n "$CROWSNEST_CROWSNEST_REPO_BRANCH" ] || CROWSNEST_CROWSNEST_REPO_BRANCH=master
[ -n "$CROWSNEST_CROWSNEST_DEPS" ] || CROWSNEST_CROWSNEST_DEPS="git crudini bsdutils findutils v4l-utils ffmpeg"
[ -n "$CROWSNEST_DEFAULT_CONF" ] || CROWSNEST_DEFAULT_CONF="mainsail_default.conf"
[ -n "$CROWSNEST_DEFAULT_CONF_DIR" ] || CROWSNEST_DEFAULT_CONF_DIR="/home/${BASE_USER}/klipper_config"
# Force Raspicam fix bool (1:yes / 0:no)
[ -n "$CROWSNEST_FORCE_RASPICAMFIX" ] || CROWSNEST_FORCE_RASPICAMFIX=1
# Add Crowsnest to moonraker.conf (update manager) bool (1:yes / 0:no)
[ -n "$CROWSNEST_ADD_CROWSNEST_MOONRAKER" ] || CROWSNEST_ADD_CROWSNEST_MOONRAKER=1
# crowsnest repo
[[ -n "$CROWSNEST_REPO_SHIP" ]] || CROWSNEST_REPO_SHIP="https://github.com/mainsail-crew/crowsnest.git"
[[ -n "$CROWSNEST_REPO_BRANCH" ]] || CROWSNEST_REPO_BRANCH="master"

# crowsnest setup
[[ -n "$CROWSNEST_DEFAULT_CONF" ]] || CROWSNEST_DEFAULT_CONF="resources/crowsnest.conf"
[[ -n "$CROWSNEST_CONFIG_PATH" ]] || CROWSNEST_CONFIG_PATH="/home/${BASE_USER}/printer_data/config"
[[ -n "$CROWSNEST_LOG_PATH" ]] || CROWSNEST_LOG_PATH="/home/${BASE_USER}/printer_data/logs"
[[ -n "$CROWSNEST_ENV_PATH" ]] || CROWSNEST_ENV_PATH="/home/${BASE_USER}/printer_data/systemd"
[[ -n "$CROWSNEST_RASPICAMFIX" ]] || CROWSNEST_RASPICAMFIX="1"
[[ -n "$CROWSNEST_ADD_CROWSNEST_MOONRAKER" ]] || CROWSNEST_ADD_CROWSNEST_MOONRAKER="1"
[[ -n "$CROWSNEST_MOONRAKER_CONF_PATH" ]] || CROWSNEST_MOONRAKER_CONF_PATH="/home/${BASE_USER}/printer_data/config/moonraker.conf"


# ustreamer
[ -n "$CROWSNEST_USTREAMER_DEPS" ] || CROWSNEST_USTREAMER_DEPS="git build-essential libevent-dev libjpeg-dev \
libbsd-dev libraspberrypi-dev libgpiod-dev"
[ -n "$CROWSNEST_USTREAMER_WITH_OMX" ] || CROWSNEST_USTREAMER_WITH_OMX="y"
[ -n "$CROWSNEST_USTREAMER_WITH_GPIO" ] || CROWSNEST_USTREAMER_WITH_GPIO="n"
[[ -n "$CROWSNEST_USTREAMER_REPO_SHIP" ]] || CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/pikvm/ustreamer.git"
[[ -n "$CROWSNEST_USTREAMER_REPO_BRANCH" ]] || CROWSNEST_USTREAMER_REPO_BRANCH="master"

###########################################################################
### DO NOT EDIT BELOW THIS LINE, UNLESS YOU KNOW EXACTLY WHAT HAPPENDS! ###
###########################################################################

CROWSNEST_UNATTENDED="1"
89 changes: 60 additions & 29 deletions src/modules/crowsnest/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,72 @@
#### This File is distributed under GPLv3
####

# shellcheck disable=all
# shellcheck enable=requires-variable-braces

# Error handling
set -Ee

# shellcheck disable=SC1091
source /common.sh
install_cleanup_trap

echo_green "Installing crowsnest and enable webcam Service ..."
# install dependencies
# force apt update
apt update
# It could use inbuilt dependencie check, but should speed up if preinstalled.
# shellcheck disable=SC2086
check_install_pkgs ${CROWSNEST_CROWSNEST_DEPS} ${CROWSNEST_USTREAMER_DEPS}
# Move to $HOME dir
# Module only Variables
CN_BUILD_PACKAGE_FILE="/tmp/cn_packages.lst"
CN_BUILD_INSTALL_SH="/home/${BASE_USER}/crowsnest/tools/install.sh"

echo_green "Installing crowsnest ..."

## 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
# make sure config folder exist
if [ ! -d "${CROWSNEST_DEFAULT_CONF_DIR}" ]; then
sudo -u "${BASE_USER}" mkdir -p "${CROWSNEST_DEFAULT_CONF_DIR}"
fi
# clone Repo
echo_green "Clone crowsnest repository ..."
gitclone CROWSNEST_CROWSNEST_REPO crowsnest
# install crowsnest - use crowsnest's make unattended
pushd "/home/${BASE_USER}/crowsnest" &> /dev/null || exit 1
echo_green "Launch crowsnest install routine ..."
pushd "/home/${BASE_USER}/crowsnest" &> /dev/null || exit 1
sudo -u "${BASE_USER}" make unattended
# Apply Raspicam fix if enabled.
if [ "${CROWSNEST_FORCE_RASPICAMFIX}" == "1" ]; then
echo -en "Applying Raspicam Fix ... \r"
sudo sh -c 'echo "bcm2835-v4l2" >> /etc/modules'
sudo cp file_templates/bcm2835-v4l2.conf /etc/modprobe.d/
echo -e "Applying Raspicam Fix ... [OK]"
fi
popd &> /dev/null || exit 1

## Step 2: clone crowsnest repo
echo_green "Clone crowsnest repository ..."
gitclone CROWSNEST_REPO crowsnest

## Step 3: grep PKGLIST from install.sh for dependencies
echo_green "Generating packages file ..."
grep "PKGLIST=" "${CN_BUILD_INSTALL_SH}" >> "${CN_BUILD_PACKAGE_FILE}"

## Step 4: Rename PKGLIST to Module usable Var
echo_green "Rename variable PKGLIST to CROWSNEST_DEPS ..."
sed -i 's/PKGLIST/CROWSNEST_DEPS/g' "${CN_BUILD_PACKAGE_FILE}"

## Step 5: Source cn_package.lst file
# shellcheck disable=SC1090
# Shellcheck has to be disabled here,
# because it is an dynamic generated file and not checkable
. "${CN_BUILD_PACKAGE_FILE}"

## Step 6: Install packages
echo_green "Install crowsnest dependencies ..."
# shellcheck disable=SC2086
# disabled because we need 'wordsplitting'
check_install_pkgs ${CROWSNEST_DEPS}

## Step 7: Move to crowsnest as working directory
pushd "/home/${BASE_USER}/crowsnest" &> /dev/null || exit 1

## Step 8: Run crowsnest install routine
echo_green "Launch crowsnest install routine ..."
make install

## Step 9: Leave crowsnest
popd &> /dev/null || exit 1

## Step 10: clean packages.lst file
rm -f "${CN_BUILD_PACKAGE_FILE}"

## Step 11: leave home dir
popd &> /dev/null || exit 1

## Step 12:
echo_green "Enable crowsnest.service ..."
systemctl_if_exists enable crowsnest.service

## Finish
echo_green "Installing crowsnest ... DONE!"
4 changes: 2 additions & 2 deletions src/modules/is_req_preinstall/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# shellcheck disable=all
[ -n "$IS_REQ_PREINSTALL_VENV_DIR" ] || IS_REQ_PREINSTALL_VENV_DIR=/home/${BASE_USER}/klippy-env
[ -n "$IS_REQ_PREINSTALL_DEPS" ] || IS_REQ_PREINSTALL_DEPS="python3-numpy python3-matplotlib \
libatlas3-base libatlas-base-dev"
[ -n "$IS_REQ_PREINSTALL_PIP" ] || IS_REQ_PREINSTALL_PIP="numpy<=1.21.4"
libatlas3-base libatlas-base-dev libgfortran5"
[ -n "$IS_REQ_PREINSTALL_PIP" ] || IS_REQ_PREINSTALL_PIP="numpy<=1.23.4"
[ -n "$IS_REQ_PREINSTALL_CFG_FILE" ] || IS_REQ_PREINSTALL_CFG_FILE="/boot/config.txt"
4 changes: 2 additions & 2 deletions src/modules/is_req_preinstall/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -Eex
export LC_ALL=C

# Set DEBIAN_FRONTEND to noninteractive
if [ "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
if [[ "${DEBIAN_FRONTEND}" != "noninteractive" ]]; then
export DEBIAN_FRONTEND=noninteractive
fi

Expand All @@ -41,7 +41,7 @@ check_install_pkgs ${IS_REQ_PREINSTALL_DEPS}

### Check for Klipper Venv installed.
pushd "/home/${BASE_USER}" &> /dev/null || exit 1
if [ -d "${IS_REQ_PREINSTALL_VENV_DIR}" ] && [ -x "${IS_REQ_PREINSTALL_VENV_DIR}/bin/pip" ]; then
if [[ -d "${IS_REQ_PREINSTALL_VENV_DIR}" ]] && [[ -x "${IS_REQ_PREINSTALL_VENV_DIR}/bin/pip" ]]; then
echo_green "Installing numpy..."
sudo -u "${BASE_USER}" "${IS_REQ_PREINSTALL_VENV_DIR}"/bin/pip install -v "${IS_REQ_PREINSTALL_PIP}"
else
Expand Down
44 changes: 29 additions & 15 deletions src/modules/klipper/config
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=all
[ -n "$KLIPPER_SRC_DIR" ] || KLIPPER_SRC_DIR=/home/${BASE_USER}/klipper
[ -n "$KLIPPER_PYTHON_DIR" ] || KLIPPER_PYTHON_DIR=/home/${BASE_USER}/klippy-env
#### klipper module
####
#### Based on work of:
#### Raymond Himle and meteyou (Stefan Dej)
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021 - 2022
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####
#### Credits: Thanks to KevinOConnor for this great Firmware :)

[ -n "$KLIPPER_REPO_SHIP" ] || KLIPPER_REPO_SHIP=https://github.com/Klipper3d/klipper.git
[ -n "$KLIPPER_REPO_BRANCH" ] || KLIPPER_REPO_BRANCH=master
[ -n "$KLIPPER_DEPS" ] || KLIPPER_DEPS="wget git gpiod \
virtualenv python3-dev python3-matplotlib \
libffi-dev build-essential \
libncurses-dev libusb-dev \
avrdude gcc-avr binutils-avr avr-libc \
stm32flash dfu-util libnewlib-arm-none-eabi \
gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0-0"
[ -n "$KLIPPER_USER_GROUPS" ] || KLIPPER_USER_GROUPS=tty,dialout
[ -n "$KLIPPER_USER_DIRS" ] || KLIPPER_USER_DIRS="klipper_config klipper_logs gcode_files"
[ -n "$KLIPPER_PYENV_REQ" ] || KLIPPER_PYENV_REQ=scripts/klippy-requirements.txt
[ -n "$KLIPPER_SRC_DIR" ] || KLIPPER_SRC_DIR="/home/${BASE_USER}/klipper"
[ -n "$KLIPPER_PYTHON_DIR" ] || KLIPPER_PYTHON_DIR="/home/${BASE_USER}/klippy-env"

[ -n "$KLIPPER_REPO_SHIP" ] || KLIPPER_REPO_SHIP="https://github.com/Klipper3d/klipper.git"
[ -n "$KLIPPER_REPO_BRANCH" ] || KLIPPER_REPO_BRANCH="master"
[ -n "$KLIPPER_DEPS" ] || KLIPPER_DEPS="git virtualenv python3-dev \
python3-matplotlib libffi-dev build-essential libncurses-dev libusb-dev \
avrdude gcc-avr binutils-avr avr-libc stm32flash dfu-util libnewlib-arm-none-eabi \
gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0-0 libusb-1.0-0-dev"

[ -n "$KLIPPER_USER_GROUPS" ] || KLIPPER_USER_GROUPS="tty,dialout"

[ -n "$KLIPPER_USER_DIRS" ] || KLIPPER_USER_DIRS="printer_data printer_data/config \
printer_data/comms printer_data/logs"

[ -n "$KLIPPER_PYENV_REQ" ] || KLIPPER_PYENV_REQ="scripts/klippy-requirements.txt"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KLIPPER_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/printer_data/config/printer.cfg -l /home/pi/printer_data/logs/klippy.log -I /home/pi/printer_data/comms/klippy.serial -a /home/pi/printer_data/comms/klippy.sock"
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#Systemd Klipper Service

[Unit]
Description=Starts Klipper and provides klippy Unix Domain Socket API
Description=Klipper 3D Printer Firmware SV1
Documentation=https://www.klipper3d.org/
After=network-online.target
Before=moonraker.service
Expand All @@ -11,14 +9,12 @@ Wants=udev.target
Alias=klippy
WantedBy=multi-user.target


[Service]
Environment=KLIPPER_CONFIG=/home/pi/klipper_config/printer.cfg
Environment=KLIPPER_LOG=/home/pi/klipper_logs/klippy.log
Environment=KLIPPER_SOCKET=/tmp/klippy_uds
Type=simple
User=pi
RemainAfterExit=yes
ExecStart= /home/pi/klippy-env/bin/python /home/pi/klipper/klippy/klippy.py ${KLIPPER_CONFIG} -l ${KLIPPER_LOG} -a ${KLIPPER_SOCKET}
WorkingDirectory=/home/pi/klipper
EnvironmentFile=/home/pi/printer_data/systemd/klipper.env
ExecStart=/home/pi/klippy-env/bin/python $KLIPPER_ARGS
Restart=always
RestartSec=10
12 changes: 7 additions & 5 deletions src/modules/klipper/start_chroot_script
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env bash
#### MainsailOS Build Chain
####
#### Klipper Install Module
####
#### Based on work done by Raymond Himle and Stefan Dej
Expand All @@ -23,7 +21,7 @@ set -Eex
export LC_ALL=C

# Set DEBIAN_FRONTEND to noninteractive
if [ "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
if [[ "${DEBIAN_FRONTEND}" != "noninteractive" ]]; then
export DEBIAN_FRONTEND=noninteractive
fi

Expand Down Expand Up @@ -58,7 +56,7 @@ gitclone KLIPPER_REPO klipper

## Create needed dirs
for dir in ${KLIPPER_USER_DIRS}; do
if [ -d "/home/${BASE_USER}/$dir" ]; then
if [[ -d "/home/${BASE_USER}/${dir}" ]]; then
echo_green "${dir} already exists!"
else
echo_green "Creating ${dir}"
Expand All @@ -67,6 +65,10 @@ for dir in ${KLIPPER_USER_DIRS}; do
done
popd &> /dev/null || exit 1

# Copy printer_data for klipper/klippy
echo_green "Copy files to 'printer_data' ..."
unpack /filesystem/home/"${BASE_USER}" /home/"${BASE_USER}" "${BASE_USER}"

## create python virtualenv and install klipper requirements
pushd "/home/${BASE_USER}" &> /dev/null || exit 1
echo_green "Creating Virtualenv for Klipper (klippy-env) ..."
Expand All @@ -80,4 +82,4 @@ popd &> /dev/null || exit 1
systemctl_if_exists enable klipper.service

## Done message
echo_green "Installing Klipper and enable klippy Service ... done!"
echo_green "Installing Klipper and enable klippy Service ..."
25 changes: 23 additions & 2 deletions src/modules/mainsail/config
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
[ -n "$MAINSAIL_DEPS" ] || MAINSAIL_DEPS="nginx"
[ -n "$MAINSAIL_URL" ] || MAINSAIL_URL=https://github.com/mainsail-crew/mainsail/releases/latest/download/mainsail.zip
#!/usr/bin/env bash
# Shebang for better file detection
#### mainsail module config
####
#### Based on work of:
#### Raymond Himle and meteyou
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021 - 2022
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####

[[ -n "$MAINSAIL_DEPS" ]] || MAINSAIL_DEPS="nginx"
[[ -n "$MAINSAIL_URL" ]] || MAINSAIL_URL=https://github.com/mainsail-crew/mainsail/releases/latest/download/mainsail.zip

# mainsail.cfg repo
[[ -n "$MAINSAIL_CONFIG_REPO_SHIP" ]] || MAINSAIL_CONFIG_REPO_SHIP="https://github.com/mainsail-crew/mainsail-config.git"
[[ -n "$MAINSAIL_CONFIG_REPO_BRANCH" ]] || MAINSAIL_CONFIG_REPO_BRANCH="master"
# mainsail.cfg setup
[[ -n "$MAINSAIL_CONFIG_SRC_PATH" ]] || MAINSAIL_CONFIG_SRC_PATH="/home/${BASE_USER}/mainsail-config/mainsail.cfg"
[[ -n "$MAINSAIL_CONFIG_DEST_PATH" ]] || MAINSAIL_CONFIG_DEST_PATH="/home/${BASE_USER}/printer_data/config/mainsail.cfg"
Loading

0 comments on commit e5943af

Please sign in to comment.