-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add timelapse module This adds moonraker-timelapse plugin to image. Signed-off-by: Stephan Wendel <me@stephanwe.de>
- Loading branch information
Showing
5 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# moonraker-timelapse custompios module | ||
# https://github.com/mainsail-crew/moonraker-timelapse | ||
# written by Stephan Wendel aka KwadFan | ||
# <me@stephanwe.de> | ||
# GPL V3 | ||
######## | ||
# shellcheck disable=all | ||
[ -n "$TIMELAPSE_SRC_DIR" ] || TIMELAPSE_SRC_DIR="/home/${BASE_USER}/moonraker-timelapse" | ||
[ -n "$TIMELAPSE_PYTHON_DIR" ] || TIMELAPSE_TARGET_DIR="/home/${BASE_USER}/moonraker/moonraker/components" | ||
[ -n "$TIMELAPSE_CONFIG_DIR" ] || TIMELAPSE_CONFIG_DIR="/home/${BASE_USER}/klipper_config" | ||
[ -n "$TIMELAPSE_TEMPLATE" ] || TIMELAPSE_TEMPLATE="/home/${BASE_USER}/klipper_config/timelapse_template.txt" | ||
|
||
[ -n "$TIMELAPSE_REPO_SHIP" ] || TIMELAPSE_REPO_SHIP=https://github.com/mainsail-crew/moonraker-timelapse.git | ||
[ -n "$TIMELAPSE_REPO_BRANCH" ] || TIMELAPSE_REPO_BRANCH=main | ||
[ -n "$TIMELAPSE_DEPS" ] || TIMELAPSE_DEPS="ffmpeg" |
13 changes: 13 additions & 0 deletions
13
src/modules/timelapse/filesystem/home/pi/klipper_config/timelapse_template.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
### moonraker-timelapse | ||
### Don't forget to include timelapse.cfg to your printer.cfg | ||
### Uncomment to enable moonraker-timelapse | ||
|
||
#[timelapse] | ||
|
||
#[update_manager timelapse] | ||
#type: git_repo | ||
#primary_branch: main | ||
#path: ~/moonraker-timelapse | ||
#origin: https://github.com/mainsail-crew/moonraker-timelapse.git | ||
#managed_services: klipper moonraker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/usr/bin/env bash | ||
#### MainsailOS Build Chain | ||
#### | ||
#### moonraker-timelapse install module | ||
#### #!/bin/bash | ||
#### https://github.com/mainsail-crew/moonraker-timelapse | ||
#### | ||
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> | ||
#### Copyright 2022 | ||
#### https://github.com/mainsail-crew/MainsailOS | ||
#### | ||
#### This File is distributed under GPLv3 | ||
#### | ||
|
||
###### THIS MODULE HAS TO BE PLACED RIGHT AFTER "moonraker" MODULE!!! | ||
|
||
# shellcheck enable=require-variable-braces | ||
|
||
## Source error handling, leave this in place | ||
set -Eex | ||
|
||
## Set LC_ALL to prevent errors | ||
export LC_ALL=C | ||
|
||
# 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 moonraker update_manager | ||
function add_timelapse_entry { | ||
if [ -f "${TIMELAPSE_CONFIG_DIR}/moonraker.conf" ]; then | ||
if [ -f "/tmp/moonraker.conf" ]; then | ||
rm -rf /tmp/moonraker.conf | ||
fi | ||
sudo -u "${BASE_USER}" \ | ||
cat "${TIMELAPSE_CONFIG_DIR}/moonraker.conf" "${TIMELAPSE_TEMPLATE}" | \ | ||
tee /tmp/moonraker.conf > /dev/null && | ||
cp -rf /tmp/moonraker.conf "${TIMELAPSE_CONFIG_DIR}/moonraker.conf" | ||
fi | ||
## Cleanup template | ||
if [ -f "${TIMELAPSE_TEMPLATE}" ]; then | ||
rm -f "${TIMELAPSE_TEMPLATE}" | ||
fi | ||
} | ||
|
||
echo_green "Installing moonraker-timelapse plugin ..." | ||
|
||
### Install template file | ||
unpack /filesystem/home/${BASE_USER} /home/${BASE_USER} ${BASE_USER} | ||
|
||
## Install all deps at once for time consumption reasons. | ||
## APT: Update Repo Database and install Dependencies | ||
# Force apt update | ||
apt update | ||
echo_green "Installing moonraker-timelapse Dependencies ..." | ||
## Disabling shellcheck SC2086, because we want "wordsplitting" | ||
# shellcheck disable=SC2086 | ||
check_install_pkgs ${TIMELAPSE_DEPS} | ||
|
||
|
||
## Clone klipper repo | ||
pushd "/home/${BASE_USER}" &> /dev/null || exit 1 | ||
gitclone TIMELAPSE_REPO moonraker-timelapse | ||
|
||
## Link component | ||
if [ -d "${TIMELAPSE_TARGET_DIR}" ]; then | ||
echo "Linking extension to moonraker ..." | ||
sudo -u "${BASE_USER}" \ | ||
ln -sf "${TIMELAPSE_SRC_DIR}/component/timelapse.py" "${TIMELAPSE_TARGET_DIR}/timelapse.py" | ||
fi | ||
|
||
## Link timelapse.cfg | ||
if [ -d "/home/${BASE_USER}/klipper_config" ]; then | ||
echo "Linking macro file ..." | ||
sudo -u "${BASE_USER}" \ | ||
ln -sf "${TIMELAPSE_SRC_DIR}/klipper_macro/timelapse.cfg" "${TIMELAPSE_CONFIG_DIR}/timelapse.cfg" | ||
fi | ||
|
||
## Extend moonraker.conf | ||
echo "Modifying moonraker.conf ..." | ||
add_timelapse_entry | ||
|
||
|
||
popd || exit 1 | ||
|
||
|
||
## Done message | ||
echo_green "Installing moonraker-timelapse plugin ... done!" |