diff --git a/resources/moonraker.conf b/resources/moonraker.conf index c86c6d3..2d1d3c2 100644 --- a/resources/moonraker.conf +++ b/resources/moonraker.conf @@ -4,9 +4,6 @@ port: %PORT% enable_debug_logging: False klippy_uds_address: %UDS% -[database] -database_path: %DB% - [authorization] trusted_clients: %LAN% @@ -23,6 +20,9 @@ cors_domains: http://*://my.mainsail.xyz http://*://app.fluidd.xyz +[database] +database_path: %DB% + [file_manager] config_path: %CFG% log_path: %LOG% @@ -34,21 +34,3 @@ log_path: %LOG% [update_manager] channel: dev refresh_interval: 168 - -[update_manager mainsail] -type: web -repo: mainsail-crew/mainsail -path: ~/mainsail - -[update_manager fluidd] -type: web -repo: fluidd-core/fluidd -path: ~/fluidd - -#[update_manager KlipperScreen] -#type: git_repo -#path: /home/%USER%/KlipperScreen -#origin: https://github.com/jordanruthe/KlipperScreen.git -#env: /home/%USER%/.KlipperScreen-env/bin/python -#requirements: scripts/KlipperScreen-requirements.txt -#install_script: scripts/KlipperScreen-install.sh \ No newline at end of file diff --git a/scripts/fluidd.sh b/scripts/fluidd.sh index fc7fc3a..c59339c 100644 --- a/scripts/fluidd.sh +++ b/scripts/fluidd.sh @@ -77,6 +77,9 @@ function install_fluidd(){ ### install fluidd fluidd_setup + ### add fluidd to the update manager in moonraker.conf + patch_fluidd_update_manager + ### install mjpg-streamer [ "${install_mjpg_streamer}" = "true" ] && install_mjpg-streamer @@ -368,4 +371,25 @@ function select_fluidd_port(){ fi done fi +} + +function patch_fluidd_update_manager(){ + local moonraker_configs + moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf") + for conf in ${moonraker_configs}; do + status_msg "Adding Fluidd to update manager in file:\n ${conf}" + ### add new line to conf if it doesn't end with one + [[ $(tail -c1 "${conf}" | wc -l) -eq 0 ]] && echo "" >> "${conf}" + ### add Fluidds update manager section to moonraker.conf + if grep -Eq "[update_manager fluidd]" "${conf}"; then + /bin/sh -c "cat >> ${conf}" << MOONRAKER_CONF + +[update_manager fluidd] +type: web +channel: stable +repo: fluidd-core/fluidd +path: ~/fluidd +MOONRAKER_CONF + fi + done } \ No newline at end of file diff --git a/scripts/klipperscreen.sh b/scripts/klipperscreen.sh index f1ca32d..50209bd 100644 --- a/scripts/klipperscreen.sh +++ b/scripts/klipperscreen.sh @@ -28,7 +28,13 @@ function install_klipperscreen(){ error="${error} Please upgrade Python." print_error "${error}" && return fi + + ### install KlipperScreen klipperscreen_setup + + ### add klipperscreen to the update manager in moonraker.conf + patch_klipperscreen_update_manager + do_action_service "restart" "KlipperScreen" } @@ -174,3 +180,30 @@ function compare_klipperscreen_versions(){ fi echo "${versions}" } + +#================================================# +#=================== HELPERS ====================# +#================================================# + +function patch_klipperscreen_update_manager(){ + local moonraker_configs + moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf") + for conf in ${moonraker_configs}; do + status_msg "Adding KlipperScreen to update manager in file:\n ${conf}" + ### add new line to conf if it doesn't end with one + [[ $(tail -c1 "${conf}" | wc -l) -eq 0 ]] && echo "" >> "${conf}" + ### add KlipperScreens update manager section to moonraker.conf + if grep -Eq "[update_manager KlipperScreen]" "${conf}"; then + /bin/sh -c "cat >> ${conf}" << MOONRAKER_CONF + +[update_manager KlipperScreen] +type: git_repo +path: ${HOME}/KlipperScreen +origin: https://github.com/jordanruthe/KlipperScreen.git +env: ${HOME}/.KlipperScreen-env/bin/python +requirements: scripts/KlipperScreen-requirements.txt +install_script: scripts/KlipperScreen-install.sh +MOONRAKER_CONF + fi + done +} diff --git a/scripts/mainsail.sh b/scripts/mainsail.sh index a920a62..c441651 100644 --- a/scripts/mainsail.sh +++ b/scripts/mainsail.sh @@ -74,9 +74,12 @@ function install_mainsail(){ ### symlink nginx log symlink_webui_nginx_log "mainsail" - ### install mainsail/fluidd + ### install mainsail mainsail_setup + ### add mainsail to the update manager in moonraker.conf + patch_mainsail_update_manager + ### install mjpg-streamer [ "${install_mjpg_streamer}" = "true" ] && install_mjpg-streamer @@ -490,4 +493,25 @@ function enable_mainsail_remotemode(){ [ ! -f "${MAINSAIL_DIR}/config.json" ] && return rm -f "${MAINSAIL_DIR}/config.json" echo -e "{\n \"remoteMode\":true\n}" >> "${MAINSAIL_DIR}/config.json" +} + +function patch_mainsail_update_manager(){ + local moonraker_configs + moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf") + for conf in ${moonraker_configs}; do + status_msg "Adding Mainsail to update manager in file:\n ${conf}" + ### add new line to conf if it doesn't end with one + [[ $(tail -c1 "${conf}" | wc -l) -eq 0 ]] && echo "" >> "${conf}" + ### add Mainsails update manager section to moonraker.conf + if grep -Eq "[update_manager mainsail]" "${conf}"; then + /bin/sh -c "cat >> ${conf}" << MOONRAKER_CONF + +[update_manager mainsail] +type: web +channel: stable +repo: mainsail-crew/mainsail +path: ~/mainsail +MOONRAKER_CONF + fi + done } \ No newline at end of file diff --git a/scripts/moonraker.sh b/scripts/moonraker.sh index 825ad2c..2ccaf09 100644 --- a/scripts/moonraker.sh +++ b/scripts/moonraker.sh @@ -66,7 +66,8 @@ function moonraker_setup_dialog(){ case "${yn}" in Y|y|Yes|yes|"") select_msg "Yes" - status_msg "Installing ${count} Moonraker instance(s) ... \n" + ((count == 1)) && status_msg "Installing single Moonraker instance ..." + ((count > 1)) && status_msg "Installing ${count} Moonraker instances ..." moonraker_setup "${count}" break;; N|n|No|no)