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. diff --git a/scripts/install_klipper_webui.sh b/scripts/install_klipper_webui.sh index e57e08e..8a3b7dd 100755 --- a/scripts/install_klipper_webui.sh +++ b/scripts/install_klipper_webui.sh @@ -239,8 +239,36 @@ 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 + mr_restart="true" + 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 && 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