From d3a12f7db795778c11f115a74f8e13f862b43d27 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Wed, 18 Nov 2020 17:37:54 +0100 Subject: [PATCH 1/3] fix: add a patch due to recent changes to fluidd --- scripts/install_klipper_webui.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/install_klipper_webui.sh b/scripts/install_klipper_webui.sh index e57e08e..b9b5275 100755 --- a/scripts/install_klipper_webui.sh +++ b/scripts/install_klipper_webui.sh @@ -239,8 +239,34 @@ fluidd_setup(){ #write fluidd version to file for update check reasons status_msg "Writing Fluidd version to file ..." get_fluidd_ver && echo $FLUIDD_VERSION > $FLUIDD_DIR/version && ok_msg "Done!" + #patch moonraker.conf to apply cors domains if needed + backup_moonraker_conf + patch_moonraker #delete downloaded zip status_msg "Remove downloaded archive ..." rm -rf *.zip && ok_msg "Done!" && ok_msg "Fluidd installation complete!" echo } + +patch_moonraker(){ + mr_conf=${HOME}/moonraker.conf + # looking for a cors_domain entry in moonraker.conf + if [ ! "$(grep "^cors_domains:$" $mr_conf)" ]; then + #find trusted_clients line number and subtract one, to insert cors_domains later + line="$(grep -n "trusted_clients:" $mr_conf | cut -d":" -f1)i" + sed -i "$line cors_domains:" $mr_conf + fi + if [ "$(grep "^cors_domains:$" $mr_conf)" ]; then + hostname=$(hostname -I | cut -d" " -f1) + url1="\ \ \ \ http://*.local" + url2="\ \ \ \ http://app.fluidd.xyz" + url3="\ \ \ \ https://app.fluidd.xyz" + url4="\ \ \ \ http://$hostname:*" + #find cors_domains line number and add one, to insert urls later + line="$(expr $(grep -n "cors_domains:" $mr_conf | cut -d":" -f1) + 1)i" + [ ! "$(grep -E '^\s+http:\/\/\*\.local$' $mr_conf)" ] && sed -i "$line $url1" $mr_conf + [ ! "$(grep -E '^\s+http:\/\/app\.fluidd\.xyz$' $mr_conf)" ] && sed -i "$line $url2" $mr_conf + [ ! "$(grep -E '^\s+https:\/\/app\.fluidd\.xyz$' $mr_conf)" ] && sed -i "$line $url3" $mr_conf + [ ! "$(grep -E '^\s+http:\/\/([0-9]{1,3}\.){3}[0-9]{1,3}' $mr_conf)" ] && sed -i "$line $url4" $mr_conf + fi +} \ No newline at end of file From ed9b8d844b1ed1c244e1e389fed6964856b2aa77 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Wed, 18 Nov 2020 17:48:19 +0100 Subject: [PATCH 2/3] fix: must restart moonraker after changes to moonraker.conf --- scripts/install_klipper_webui.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/install_klipper_webui.sh b/scripts/install_klipper_webui.sh index b9b5275..8a3b7dd 100755 --- a/scripts/install_klipper_webui.sh +++ b/scripts/install_klipper_webui.sh @@ -255,6 +255,7 @@ patch_moonraker(){ #find trusted_clients line number and subtract one, to insert cors_domains later line="$(grep -n "trusted_clients:" $mr_conf | cut -d":" -f1)i" sed -i "$line cors_domains:" $mr_conf + mr_restart="true" fi if [ "$(grep "^cors_domains:$" $mr_conf)" ]; then hostname=$(hostname -I | cut -d" " -f1) @@ -264,9 +265,10 @@ patch_moonraker(){ url4="\ \ \ \ http://$hostname:*" #find cors_domains line number and add one, to insert urls later line="$(expr $(grep -n "cors_domains:" $mr_conf | cut -d":" -f1) + 1)i" - [ ! "$(grep -E '^\s+http:\/\/\*\.local$' $mr_conf)" ] && sed -i "$line $url1" $mr_conf - [ ! "$(grep -E '^\s+http:\/\/app\.fluidd\.xyz$' $mr_conf)" ] && sed -i "$line $url2" $mr_conf - [ ! "$(grep -E '^\s+https:\/\/app\.fluidd\.xyz$' $mr_conf)" ] && sed -i "$line $url3" $mr_conf - [ ! "$(grep -E '^\s+http:\/\/([0-9]{1,3}\.){3}[0-9]{1,3}' $mr_conf)" ] && sed -i "$line $url4" $mr_conf + [ ! "$(grep -E '^\s+http:\/\/\*\.local$' $mr_conf)" ] && sed -i "$line $url1" $mr_conf && mr_restart="true" + [ ! "$(grep -E '^\s+http:\/\/app\.fluidd\.xyz$' $mr_conf)" ] && sed -i "$line $url2" $mr_conf && mr_restart="true" + [ ! "$(grep -E '^\s+https:\/\/app\.fluidd\.xyz$' $mr_conf)" ] && sed -i "$line $url3" $mr_conf && mr_restart="true" + [ ! "$(grep -E '^\s+http:\/\/([0-9]{1,3}\.){3}[0-9]{1,3}' $mr_conf)" ] && sed -i "$line $url4" $mr_conf && mr_restart="true" fi + [ "$mr_restart" == "true" ] && restart_moonraker } \ No newline at end of file From 2e3975374a0758a5783b9e63f827332ef1bd3564 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Wed, 18 Nov 2020 18:03:41 +0100 Subject: [PATCH 3/3] Update Docs --- README.md | 5 ++++- docs/changelog.md | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 78f013f..83abddf 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ --- +## **📋 Please see the [Changelog](docs/changelog.md) for possible important information !** + +--- + ## **📢 Disclaimer: Usage of this script happens at your own risk!** This script acts as a helping hand for you to get set up in a fast and comfortable way.\ @@ -62,7 +66,6 @@ Feel free to check out his work. ## **📝 Notes:** -- ### **Important changes to the script will be listed in the [Changelog](docs/changelog.md)** - Tested **only** on Raspberry Pi OS Lite (Debian Buster) - During the use of this script you might be asked for your sudo password. There are several functions involved which need sudo privileges. diff --git a/docs/changelog.md b/docs/changelog.md index ffed9a3..f3e2900 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,10 @@ This document covers possible important changes to KIAUH. +### 2020-11-18 + +* Some changes to Fluidd caused a little rework on how KIAUH will install/update Fluidd from now on. Please see the [fluidd v1.0.0-rc0 release notes](https://github.com/cadriel/fluidd/releases/tag/v1.0.0-rc.0) for further information about what modifications to the moonraker.conf file exactly had to be done. In a nutshell, KIAUH will now always patch the required entries to the moonraker.conf if not already there. + ### 2020-10-30: * The user can now choose to install Klipper as a systemd service.