From 4f4b7fb3ebde7ac060e04efe484ea40de0249e3c Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 11 Jan 2023 19:19:47 +0100 Subject: [PATCH 01/12] feat: add crowsnest as mjpg replacement Signed-off-by: Stephan Wendel --- scripts/crowsnest.sh | 229 +++++++++++++++++++++++++++++++++++++ scripts/globals.sh | 5 + scripts/ui/install_menu.sh | 8 +- scripts/ui/main_menu.sh | 4 + scripts/ui/remove_menu.sh | 7 +- scripts/ui/update_menu.sh | 5 +- 6 files changed, 253 insertions(+), 5 deletions(-) create mode 100644 scripts/crowsnest.sh diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh new file mode 100644 index 0000000..9493d2b --- /dev/null +++ b/scripts/crowsnest.sh @@ -0,0 +1,229 @@ +#!/usr/bin/env bash + +#=======================================================================# +# Copyright (C) 2020 - 2022 Dominik Willner # +# # +# This file is part of KIAUH - Klipper Installation And Update Helper # +# https://github.com/th33xitus/kiauh # +# # +# This file may be distributed under the terms of the GNU GPLv3 license # +#=======================================================================# + +#=======================================================================# +# Crowsnest Installer brought to you by KwadFan # +# Copyright (C) 2022 KwadFan # +# https://github.com/KwadFan/crowsnest # +#=======================================================================# + +# Error Handling +set -e + +# Helper messages + +function multi_instance_message(){ + echo -e "Crowsnest is NOT designed to support Multi Instances." + echo -e "A Workaround for this is to choose the most used instance as a 'master'" + echo -e "Use this instance to setup your 'crowsnest.conf' and steering it's service.\n" + echo -e "Found the following instances:\n" + for i in ${1}; do + select_msg "${i}" + done + echo -e "\nLaunching crowsnest's configuration tool ..." + continue_config +} + +# Helper funcs +function clone_crowsnest(){ + $(command -v git) clone "${CROWSNEST_REPO}" -b master "${CROWSNEST_DIR}" +} + +function check_multi_instance(){ + local -a instances + readarray -t instances < <(find "${HOME}" -regex "${HOME}/[a-zA-Z0-9_]+_data/*" -printf "%P\n" 2> /dev/null | sort) + if [[ "${#instances[@]}" -gt 1 ]]; then + status_msg "Multi Instance Install detected ..." + multi_instance_message "${instances[*]}" + if [[ -d "${HOME}/crowsnest" ]]; then + pushd "${HOME}/crowsnest" &> /dev/null || exit 1 + if ! make config ;then + error_msg "Something went wrong! Please try again..." + if [[ -f "tools/.config" ]]; then + rm -f tools/.config + fi + exit 1 + fi + if [[ ! -f "tools/.config" ]]; then + log_error "failure while generating .config" + error_msg "Generating .config failed, installation aborted" + exit 1 + fi + popd &> /dev/null || exit 1 + fi + fi +} + +function continue_config() { + local reply + while true; do + read -erp "Continue? [Y/n]: " -i "Y" reply + case "${reply}" in + [Yy]* ) + break + ;; + [Nn]* ) + warn_msg "Installation aborted by user ... Exiting!" + exit 1 + ;; + * ) + echo -e "\e[31mERROR: Please type Y or N !\e[0m" + ;; + esac + done + return 0 +} + +# function install_basic_deps(){ +# local -a install +# local -a deps +# deps=(git make) +# for i in "${deps[@]}"; do +# if [[ -z "$(command -v "${i}")" ]]; then +# install+="${i}" +# fi +# done +# if [[ -n "${install[*]}" ]]; then +# ### Update system package info ( shameless stolen from klipper.sh ) +# status_msg "Updating package lists..." +# if ! sudo apt-get update --allow-releaseinfo-change; then +# log_error "failure while updating package lists" +# error_msg "Updating package lists failed!" +# exit 1 +# fi +# status_msg "Installing required packages..." +# if ! sudo apt-get install --yes "${install[@]}"; then +# log_error "failure while installing required crowsnest basic packages" +# error_msg "Installing required packages failed!" +# exit 1 +# fi +# else +# ok_msg "All basic dependencies met, nothing to do!" +# fi +# } + + +# Install func +function install_crowsnest(){ + + # Step 1: jump to home directory + pushd "${HOME}" &> /dev/null || exit 1 + + # Step 2: Clone crowsnest repo + status_msg "Cloning 'crowsnest' repository ..." + if [[ ! -d "${HOME}/crowsnest" ]] && + [[ -z "$(ls -A "${HOME}/crowsnest")" ]]; then + clone_crowsnest + else + ok_msg "crowsnest repository already exists ..." + fi + + # Step 3: Install dependencies + # status_msg "Install basic dependencies ..." + # install_basic_deps + dependency_check git make + + # Step 4: Check for Multi Instance + check_multi_instance + + # Step 5: Launch crowsnest installer + pushd "${HOME}/crowsnest" &> /dev/null || exit 1 + title_msg "Installer will prompt you for sudo password!" + status_msg "Launching crowsnest installer ..." + if ! sudo make install; then + error_msg "Something went wrong! Please try again..." + exit 1 + fi + + # Step 5: Leave directory (twice due two pushd) + popd &> /dev/null || exit 1 + popd &> /dev/null || exit 1 +} + +# Remove func +function remove_crowsnest(){ + pushd "${HOME}/crowsnest" &> /dev/null || exit 1 + title_msg "Uninstaller will prompt you for sudo password!" + status_msg "Launching crowsnest Uninstaller ..." + if ! make uninstall; then + error_msg "Something went wrong! Please try again..." + exit 1 + fi + if [[ -e "${CROWSNEST_DIR}" ]]; then + status_msg "Removing Crowsnest directory ..." + rm -rf "${CROWSNEST_DIR}" + fi +} + +# Status funcs +get_crowsnest_status(){ + local -a files + files=( + "${CROWSNEST_DIR}" + "/usr/local/bin/crowsnest" + "/etc/logrotate.d/crowsnest" + "/etc/systemd/system/crowsnest.service" + "$(find "${HOME}" -name 'crowsnest.env' 2> /dev/null || + echo "${HOME}/printer_data/systemd/crowsnest.env")" + ) + # Contains ugly hackaround for multi instance... :( + local count + count=0 + + for file in "${files[@]}"; do + [[ -e "${file}" ]] && count=$(( count +1 )) + done + if [[ "${count}" -eq "${#files[*]}" ]]; then + echo "Installed" + elif [[ "${count}" -gt 0 ]]; then + echo "Incomplete!" + else + echo "Not installed!" + fi +} + +# Update funcs +# Shameless stolen from KlipperScreen.sh +function get_local_crowsnest_commit() { + [[ ! -d ${CROWSNEST_DIR} || ! -d "${CROWSNEST_DIR}/.git" ]] && return + + local commit + cd "${CROWSNEST_DIR}" + commit="$(git describe HEAD --always --tags | cut -d "-" -f 1,2)" + echo "${commit}" +} + +function get_remote_crowsnest_commit() { + [[ ! -d ${CROWSNEST_DIR} || ! -d "${CROWSNEST_DIR}/.git" ]] && return + + local commit + cd "${CROWSNEST_DIR}" && git fetch origin -q + commit=$(git describe origin/master --always --tags | cut -d "-" -f 1,2) + echo "${commit}" +} + +function compare_crowsnest_versions() { + local versions local_ver remote_ver + local_ver="$(get_local_crowsnest_commit)" + remote_ver="$(get_remote_crowsnest_commit)" + + if [[ ${local_ver} != "${remote_ver}" ]]; then + versions="${yellow}$(printf " %-14s" "${local_ver}")${white}" + versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}" + # add moonraker to application_updates_available in kiauh.ini + add_to_application_updates "crowsnest" + else + versions="${green}$(printf " %-14s" "${local_ver}")${white}" + versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}" + fi + + echo "${versions}" +} \ No newline at end of file diff --git a/scripts/globals.sh b/scripts/globals.sh index 5ff9e0c..81629d6 100644 --- a/scripts/globals.sh +++ b/scripts/globals.sh @@ -68,4 +68,9 @@ function set_globals() { #=============== MOONRAKER-OBICO ================# MOONRAKER_OBICO_DIR="${HOME}/moonraker-obico" MOONRAKER_OBICO_REPO="https://github.com/TheSpaghettiDetective/moonraker-obico.git" + + #=============== Crowsnest ================# + CROWSNEST_DIR="${HOME}/crowsnest" + CROWSNEST_REPO="https://github.com/mainsail-crew/crowsnest.git" + } diff --git a/scripts/ui/install_menu.sh b/scripts/ui/install_menu.sh index 3b31689..8ac01c0 100755 --- a/scripts/ui/install_menu.sh +++ b/scripts/ui/install_menu.sh @@ -27,8 +27,10 @@ function install_ui() { echo -e "| 3) [Mainsail] | 8) [Telegram Bot] |" echo -e "| 4) [Fluidd] | 9) $(obico_install_title) |" echo -e "| | |" - echo -e "| Touchscreen GUI: | |" - echo -e "| 5) [KlipperScreen] | |" + echo -e "| Touchscreen GUI: | Webcam Streamer: |" + echo -e "| 5) [KlipperScreen] | 10) [Crowsnest] |" +# echo -e "| Touchscreen GUI: | |" +# echo -e "| 5) [KlipperScreen] | |" # echo -e "| Touchscreen GUI: | Webcam Streamer: |" # echo -e "| 5) [KlipperScreen] | 10) [MJPG-Streamer] |" back_footer @@ -66,6 +68,8 @@ function install_menu() { do_action "telegram_bot_setup_dialog" "install_ui";; 9) do_action "moonraker_obico_setup_dialog" "install_ui";; + 10) + do_action "install_crowsnest" "install_ui";; # 10) # do_action "install_mjpg-streamer" "install_ui";; # clear && print_header diff --git a/scripts/ui/main_menu.sh b/scripts/ui/main_menu.sh index 263ba24..ad9c14f 100755 --- a/scripts/ui/main_menu.sh +++ b/scripts/ui/main_menu.sh @@ -30,6 +30,7 @@ function main_ui() { echo -e "| | KlipperScreen: $(print_status "klipperscreen")|" echo -e "| 6) [Settings] | Telegram Bot: $(print_status "telegram_bot")|" echo -e "| | Obico: $(print_status "moonraker_obico")|" + echo -e "| | Crowsnest: $(print_status "crowsnest")|" echo -e "| | |" echo -e "| $(print_kiauh_version)| Octoprint: $(print_status "octoprint")|" quit_footer @@ -107,6 +108,9 @@ function main_menu() { "start octoprint") do_action_service "start" "octoprint"; main_ui;; "stop octoprint") do_action_service "stop" "octoprint"; main_ui;; "restart octoprint") do_action_service "restart" "octoprint"; main_ui;; + "start crowsnest") do_action_service "start" "crowsnest"; main_ui;; + "stop crowsnest") do_action_service "stop" "crowsnest"; main_ui;; + "restart crowsnest") do_action_service "restart" "crowsnest"; main_ui;; update) do_action "update_kiauh" "main_ui";; 0)clear && print_header #upload_selection diff --git a/scripts/ui/remove_menu.sh b/scripts/ui/remove_menu.sh index 4cf743d..a1aed4d 100755 --- a/scripts/ui/remove_menu.sh +++ b/scripts/ui/remove_menu.sh @@ -22,8 +22,9 @@ function remove_ui() { echo -e "| 2) [Moonraker] | |" echo -e "| | Webcam Streamer: |" echo -e "| Klipper Webinterface: | 7) [MJPG-Streamer] |" - echo -e "| 3) [Mainsail] | |" - echo -e "| 4) [Fluidd] | Other: |" + echo -e "| 3) [Mainsail] | 12) [Crowsnest] |" + echo -e "| 4) [Fluidd] | |" + echo -e "| | Other: |" echo -e "| | 8) [PrettyGCode] |" echo -e "| Touchscreen GUI: | 9) [Telegram Bot] |" echo -e "| 5) [KlipperScreen] | 10) [Obico for Klipper] |" @@ -60,6 +61,8 @@ function remove_menu() { do_action "remove_moonraker_obico" "remove_ui";; 11) do_action "remove_nginx" "remove_ui";; + 12) + do_action "remove_crowsnest" "remove_ui";; B|b) clear; main_menu; break;; *) diff --git a/scripts/ui/update_menu.sh b/scripts/ui/update_menu.sh index a4fb2c3..800edcf 100755 --- a/scripts/ui/update_menu.sh +++ b/scripts/ui/update_menu.sh @@ -32,8 +32,9 @@ function update_ui() { echo -e "| 6) [PrettyGCode] |$(compare_prettygcode_versions)|" echo -e "| 7) [Telegram Bot] |$(compare_telegram_bot_versions)|" echo -e "| 8) [Obico for Klipper]|$(compare_moonraker_obico_versions)|" + echo -e "| 9) [Crowsnest] |$(compare_crowsnest_versions)|" echo -e "| |------------------------------|" - echo -e "| 9) [System] | $(check_system_updates) |" + echo -e "| 10)[System] | $(check_system_updates) |" back_footer } @@ -63,6 +64,8 @@ function update_menu() { 8) do_action "update_moonraker_obico" "update_ui";; 9) + do_action "update_system" "update_crowsnest";; + 10) do_action "update_system" "update_ui";; a) do_action "update_all" "update_ui";; -- 2.39.5 From 12175681c4e0fe74c5ec72e66e9daefc9283b3d2 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 19 Jan 2023 16:05:25 +0100 Subject: [PATCH 02/12] chore: remove unused code Signed-off-by: Stephan Wendel --- scripts/crowsnest.sh | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index 9493d2b..d3db172 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -82,35 +82,6 @@ function continue_config() { return 0 } -# function install_basic_deps(){ -# local -a install -# local -a deps -# deps=(git make) -# for i in "${deps[@]}"; do -# if [[ -z "$(command -v "${i}")" ]]; then -# install+="${i}" -# fi -# done -# if [[ -n "${install[*]}" ]]; then -# ### Update system package info ( shameless stolen from klipper.sh ) -# status_msg "Updating package lists..." -# if ! sudo apt-get update --allow-releaseinfo-change; then -# log_error "failure while updating package lists" -# error_msg "Updating package lists failed!" -# exit 1 -# fi -# status_msg "Installing required packages..." -# if ! sudo apt-get install --yes "${install[@]}"; then -# log_error "failure while installing required crowsnest basic packages" -# error_msg "Installing required packages failed!" -# exit 1 -# fi -# else -# ok_msg "All basic dependencies met, nothing to do!" -# fi -# } - - # Install func function install_crowsnest(){ -- 2.39.5 From 08dbafa087bf0614deef89f1a92be1a74dad9d8d Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 26 Jan 2023 20:54:33 +0100 Subject: [PATCH 03/12] chore: changed userinput style Contains also indentation to two spaces instead of four as requested by th33xitus Signed-off-by: Stephan Wendel --- scripts/crowsnest.sh | 217 ++++++++++++++++++++++--------------------- 1 file changed, 110 insertions(+), 107 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index d3db172..f31c13d 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -15,150 +15,153 @@ # https://github.com/KwadFan/crowsnest # #=======================================================================# +# shellcheck enable=require-variable-braces +# shellcheck disable=SC2154 + # Error Handling set -e # Helper messages function multi_instance_message(){ - echo -e "Crowsnest is NOT designed to support Multi Instances." - echo -e "A Workaround for this is to choose the most used instance as a 'master'" - echo -e "Use this instance to setup your 'crowsnest.conf' and steering it's service.\n" - echo -e "Found the following instances:\n" - for i in ${1}; do - select_msg "${i}" - done - echo -e "\nLaunching crowsnest's configuration tool ..." - continue_config + echo -e "Crowsnest is NOT designed to support Multi Instances." + echo -e "A Workaround for this is to choose the most used instance as a 'master'" + echo -e "Use this instance to setup your 'crowsnest.conf' and steering it's service.\n" + echo -e "Found the following instances:\n" + for i in ${1}; do + select_msg "${i}" + done + echo -e "\nLaunching crowsnest's configuration tool ..." + continue_config } # Helper funcs function clone_crowsnest(){ - $(command -v git) clone "${CROWSNEST_REPO}" -b master "${CROWSNEST_DIR}" + $(command -v git) clone "${CROWSNEST_REPO}" -b master "${CROWSNEST_DIR}" } function check_multi_instance(){ - local -a instances - readarray -t instances < <(find "${HOME}" -regex "${HOME}/[a-zA-Z0-9_]+_data/*" -printf "%P\n" 2> /dev/null | sort) - if [[ "${#instances[@]}" -gt 1 ]]; then - status_msg "Multi Instance Install detected ..." - multi_instance_message "${instances[*]}" - if [[ -d "${HOME}/crowsnest" ]]; then - pushd "${HOME}/crowsnest" &> /dev/null || exit 1 - if ! make config ;then - error_msg "Something went wrong! Please try again..." - if [[ -f "tools/.config" ]]; then - rm -f tools/.config - fi - exit 1 - fi - if [[ ! -f "tools/.config" ]]; then - log_error "failure while generating .config" - error_msg "Generating .config failed, installation aborted" - exit 1 - fi - popd &> /dev/null || exit 1 + local -a instances + readarray -t instances < <(find "${HOME}" -regex "${HOME}/[a-zA-Z0-9_]+_data/*" -printf "%P\n" 2> /dev/null | sort) + if [[ "${#instances[@]}" -gt 1 ]]; then + status_msg "Multi Instance Install detected ..." + multi_instance_message "${instances[*]}" + if [[ -d "${HOME}/crowsnest" ]]; then + pushd "${HOME}/crowsnest" &> /dev/null || exit 1 + if ! make config ;then + error_msg "Something went wrong! Please try again..." + if [[ -f "tools/.config" ]]; then + rm -f tools/.config fi + exit 1 + fi + if [[ ! -f "tools/.config" ]]; then + log_error "failure while generating .config" + error_msg "Generating .config failed, installation aborted" + exit 1 + fi + popd &> /dev/null || exit 1 fi + fi } function continue_config() { - local reply - while true; do - read -erp "Continue? [Y/n]: " -i "Y" reply - case "${reply}" in - [Yy]* ) - break - ;; - [Nn]* ) - warn_msg "Installation aborted by user ... Exiting!" - exit 1 - ;; - * ) - echo -e "\e[31mERROR: Please type Y or N !\e[0m" - ;; - esac - done - return 0 + local reply + while true; do + read -erp "${cyan}###### Continuing with configuration? (y/N):${white} " reply + case "${reply}" in + [Yy]* ) + break + ;; + [Nn]* ) + warn_msg "Installation aborted by user ... Exiting!" + exit 1 + ;; + * ) + echo -e "\e[31mERROR: Please type Y or N !\e[0m" + ;; + esac + done + return 0 } # Install func function install_crowsnest(){ - # Step 1: jump to home directory - pushd "${HOME}" &> /dev/null || exit 1 + # Step 1: jump to home directory + pushd "${HOME}" &> /dev/null || exit 1 - # Step 2: Clone crowsnest repo - status_msg "Cloning 'crowsnest' repository ..." - if [[ ! -d "${HOME}/crowsnest" ]] && - [[ -z "$(ls -A "${HOME}/crowsnest")" ]]; then - clone_crowsnest - else - ok_msg "crowsnest repository already exists ..." - fi + # Step 2: Clone crowsnest repo + status_msg "Cloning 'crowsnest' repository ..." + if [[ ! -d "${HOME}/crowsnest" ]] && + [[ -z "$(ls -A "${HOME}/crowsnest")" ]]; then + clone_crowsnest + else + ok_msg "crowsnest repository already exists ..." + fi - # Step 3: Install dependencies - # status_msg "Install basic dependencies ..." - # install_basic_deps - dependency_check git make + # Step 3: Install dependencies + # status_msg "Install basic dependencies ..." + # install_basic_deps + dependency_check git make - # Step 4: Check for Multi Instance - check_multi_instance + # Step 4: Check for Multi Instance + check_multi_instance - # Step 5: Launch crowsnest installer - pushd "${HOME}/crowsnest" &> /dev/null || exit 1 - title_msg "Installer will prompt you for sudo password!" - status_msg "Launching crowsnest installer ..." - if ! sudo make install; then - error_msg "Something went wrong! Please try again..." - exit 1 - fi + # Step 5: Launch crowsnest installer + pushd "${HOME}/crowsnest" &> /dev/null || exit 1 + title_msg "Installer will prompt you for sudo password!" + status_msg "Launching crowsnest installer ..." + if ! sudo make install; then + error_msg "Something went wrong! Please try again..." + exit 1 + fi - # Step 5: Leave directory (twice due two pushd) - popd &> /dev/null || exit 1 - popd &> /dev/null || exit 1 + # Step 5: Leave directory (twice due two pushd) + popd &> /dev/null || exit 1 + popd &> /dev/null || exit 1 } # Remove func function remove_crowsnest(){ - pushd "${HOME}/crowsnest" &> /dev/null || exit 1 - title_msg "Uninstaller will prompt you for sudo password!" - status_msg "Launching crowsnest Uninstaller ..." - if ! make uninstall; then - error_msg "Something went wrong! Please try again..." - exit 1 - fi - if [[ -e "${CROWSNEST_DIR}" ]]; then - status_msg "Removing Crowsnest directory ..." - rm -rf "${CROWSNEST_DIR}" - fi + pushd "${HOME}/crowsnest" &> /dev/null || exit 1 + title_msg "Uninstaller will prompt you for sudo password!" + status_msg "Launching crowsnest Uninstaller ..." + if ! make uninstall; then + error_msg "Something went wrong! Please try again..." + exit 1 + fi + if [[ -e "${CROWSNEST_DIR}" ]]; then + status_msg "Removing Crowsnest directory ..." + rm -rf "${CROWSNEST_DIR}" + fi } # Status funcs get_crowsnest_status(){ - local -a files - files=( - "${CROWSNEST_DIR}" - "/usr/local/bin/crowsnest" - "/etc/logrotate.d/crowsnest" - "/etc/systemd/system/crowsnest.service" - "$(find "${HOME}" -name 'crowsnest.env' 2> /dev/null || - echo "${HOME}/printer_data/systemd/crowsnest.env")" - ) - # Contains ugly hackaround for multi instance... :( - local count - count=0 + local -a files + files=( + "${CROWSNEST_DIR}" + "/usr/local/bin/crowsnest" + "/etc/logrotate.d/crowsnest" + "/etc/systemd/system/crowsnest.service" + "$(find "${HOME}" -name 'crowsnest.env' 2> /dev/null || + echo "${HOME}/printer_data/systemd/crowsnest.env")" + ) + # Contains ugly hackaround for multi instance... :( + local count + count=0 - for file in "${files[@]}"; do - [[ -e "${file}" ]] && count=$(( count +1 )) - done - if [[ "${count}" -eq "${#files[*]}" ]]; then - echo "Installed" - elif [[ "${count}" -gt 0 ]]; then - echo "Incomplete!" - else - echo "Not installed!" - fi + for file in "${files[@]}"; do + [[ -e "${file}" ]] && count=$(( count +1 )) + done + if [[ "${count}" -eq "${#files[*]}" ]]; then + echo "Installed" + elif [[ "${count}" -gt 0 ]]; then + echo "Incomplete!" + else + echo "Not installed!" + fi } # Update funcs -- 2.39.5 From 06c0f3c55064376e81bbdba3b5dddc3d3bdf64c7 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 18:56:56 +0100 Subject: [PATCH 04/12] refactor: re-arrange/ clean up menus Signed-off-by: Dominik Willner --- scripts/ui/install_menu.sh | 9 --------- scripts/ui/main_menu.sh | 2 +- scripts/ui/remove_menu.sh | 11 ++++------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/scripts/ui/install_menu.sh b/scripts/ui/install_menu.sh index 8ac01c0..c17942f 100755 --- a/scripts/ui/install_menu.sh +++ b/scripts/ui/install_menu.sh @@ -29,10 +29,6 @@ function install_ui() { echo -e "| | |" echo -e "| Touchscreen GUI: | Webcam Streamer: |" echo -e "| 5) [KlipperScreen] | 10) [Crowsnest] |" -# echo -e "| Touchscreen GUI: | |" -# echo -e "| 5) [KlipperScreen] | |" -# echo -e "| Touchscreen GUI: | Webcam Streamer: |" -# echo -e "| 5) [KlipperScreen] | 10) [MJPG-Streamer] |" back_footer } @@ -70,11 +66,6 @@ function install_menu() { do_action "moonraker_obico_setup_dialog" "install_ui";; 10) do_action "install_crowsnest" "install_ui";; -# 10) -# do_action "install_mjpg-streamer" "install_ui";; -# clear && print_header -# print_error "Function currently disabled! Sorry!" -# install_ui;; B|b) clear; main_menu; break;; *) diff --git a/scripts/ui/main_menu.sh b/scripts/ui/main_menu.sh index ad9c14f..42e9a06 100755 --- a/scripts/ui/main_menu.sh +++ b/scripts/ui/main_menu.sh @@ -29,8 +29,8 @@ function main_ui() { echo -e "| | Fluidd: $(print_status "fluidd")|" echo -e "| | KlipperScreen: $(print_status "klipperscreen")|" echo -e "| 6) [Settings] | Telegram Bot: $(print_status "telegram_bot")|" - echo -e "| | Obico: $(print_status "moonraker_obico")|" echo -e "| | Crowsnest: $(print_status "crowsnest")|" + echo -e "| | Obico: $(print_status "moonraker_obico")|" echo -e "| | |" echo -e "| $(print_kiauh_version)| Octoprint: $(print_status "octoprint")|" quit_footer diff --git a/scripts/ui/remove_menu.sh b/scripts/ui/remove_menu.sh index a1aed4d..2cae157 100755 --- a/scripts/ui/remove_menu.sh +++ b/scripts/ui/remove_menu.sh @@ -21,10 +21,9 @@ function remove_ui() { echo -e "| 1) [Klipper] | 6) [OctoPrint] |" echo -e "| 2) [Moonraker] | |" echo -e "| | Webcam Streamer: |" - echo -e "| Klipper Webinterface: | 7) [MJPG-Streamer] |" - echo -e "| 3) [Mainsail] | 12) [Crowsnest] |" - echo -e "| 4) [Fluidd] | |" - echo -e "| | Other: |" + echo -e "| Klipper Webinterface: | 7) [Crowsnest] |" + echo -e "| 3) [Mainsail] | |" + echo -e "| 4) [Fluidd] | Other: |" echo -e "| | 8) [PrettyGCode] |" echo -e "| Touchscreen GUI: | 9) [Telegram Bot] |" echo -e "| 5) [KlipperScreen] | 10) [Obico for Klipper] |" @@ -52,7 +51,7 @@ function remove_menu() { 6) do_action "remove_octoprint" "remove_ui";; 7) - do_action "remove_mjpg-streamer" "remove_ui";; + do_action "remove_crowsnest" "remove_ui";; 8) do_action "remove_prettygcode" "remove_ui";; 9) @@ -61,8 +60,6 @@ function remove_menu() { do_action "remove_moonraker_obico" "remove_ui";; 11) do_action "remove_nginx" "remove_ui";; - 12) - do_action "remove_crowsnest" "remove_ui";; B|b) clear; main_menu; break;; *) -- 2.39.5 From 1221220f7d7ed568aa6b14cc8635541f89906394 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 19:15:16 +0100 Subject: [PATCH 05/12] chore: some reformatting Signed-off-by: Dominik Willner --- scripts/crowsnest.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index f31c13d..b8f6ef8 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -70,16 +70,15 @@ function continue_config() { while true; do read -erp "${cyan}###### Continuing with configuration? (y/N):${white} " reply case "${reply}" in - [Yy]* ) - break - ;; - [Nn]* ) + Y|y|Yes|yes) + select_msg "Yes" + break;; + N|n|No|no|"") + select_msg "No" warn_msg "Installation aborted by user ... Exiting!" - exit 1 - ;; - * ) - echo -e "\e[31mERROR: Please type Y or N !\e[0m" - ;; + exit 1;; + *) + error_msg "Invalid Input!\n";; esac done return 0 @@ -93,16 +92,13 @@ function install_crowsnest(){ # Step 2: Clone crowsnest repo status_msg "Cloning 'crowsnest' repository ..." - if [[ ! -d "${HOME}/crowsnest" ]] && - [[ -z "$(ls -A "${HOME}/crowsnest")" ]]; then + if [[ ! -d "${HOME}/crowsnest" && -z "$(ls -A "${HOME}/crowsnest")" ]]; then clone_crowsnest else ok_msg "crowsnest repository already exists ..." fi # Step 3: Install dependencies - # status_msg "Install basic dependencies ..." - # install_basic_deps dependency_check git make # Step 4: Check for Multi Instance @@ -159,7 +155,7 @@ get_crowsnest_status(){ echo "Installed" elif [[ "${count}" -gt 0 ]]; then echo "Incomplete!" - else + else echo "Not installed!" fi } -- 2.39.5 From d5e202a18eca5863e3d134c81f95513cbf5e9a20 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 19:21:35 +0100 Subject: [PATCH 06/12] chore: cleanup variable braces are enabled by global role, other rule seems to be not required? Signed-off-by: Dominik Willner --- scripts/crowsnest.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index b8f6ef8..f0547d8 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -15,9 +15,6 @@ # https://github.com/KwadFan/crowsnest # #=======================================================================# -# shellcheck enable=require-variable-braces -# shellcheck disable=SC2154 - # Error Handling set -e -- 2.39.5 From 518f31f6589ec06872b1b1245d12cb1495fb49d3 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 19:42:26 +0100 Subject: [PATCH 07/12] chore: fix some typos and pipe error to null Signed-off-by: Dominik Willner --- scripts/crowsnest.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index f0547d8..b76957e 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -21,9 +21,9 @@ set -e # Helper messages function multi_instance_message(){ - echo -e "Crowsnest is NOT designed to support Multi Instances." + echo -e "Crowsnest is NOT designed to support multi instances." echo -e "A Workaround for this is to choose the most used instance as a 'master'" - echo -e "Use this instance to setup your 'crowsnest.conf' and steering it's service.\n" + echo -e "Use this instance to set up your 'crowsnest.conf' and steering it's service.\n" echo -e "Found the following instances:\n" for i in ${1}; do select_msg "${i}" @@ -41,7 +41,7 @@ function check_multi_instance(){ local -a instances readarray -t instances < <(find "${HOME}" -regex "${HOME}/[a-zA-Z0-9_]+_data/*" -printf "%P\n" 2> /dev/null | sort) if [[ "${#instances[@]}" -gt 1 ]]; then - status_msg "Multi Instance Install detected ..." + status_msg "Multi instance install detected ..." multi_instance_message "${instances[*]}" if [[ -d "${HOME}/crowsnest" ]]; then pushd "${HOME}/crowsnest" &> /dev/null || exit 1 @@ -65,7 +65,7 @@ function check_multi_instance(){ function continue_config() { local reply while true; do - read -erp "${cyan}###### Continuing with configuration? (y/N):${white} " reply + read -erp "${cyan}###### Continue with configuration? (y/N):${white} " reply case "${reply}" in Y|y|Yes|yes) select_msg "Yes" @@ -89,7 +89,7 @@ function install_crowsnest(){ # Step 2: Clone crowsnest repo status_msg "Cloning 'crowsnest' repository ..." - if [[ ! -d "${HOME}/crowsnest" && -z "$(ls -A "${HOME}/crowsnest")" ]]; then + if [[ ! -d "${HOME}/crowsnest" && -z "$(ls -A "${HOME}/crowsnest" 2> /dev/null)" ]]; then clone_crowsnest else ok_msg "crowsnest repository already exists ..." @@ -119,14 +119,15 @@ function install_crowsnest(){ function remove_crowsnest(){ pushd "${HOME}/crowsnest" &> /dev/null || exit 1 title_msg "Uninstaller will prompt you for sudo password!" - status_msg "Launching crowsnest Uninstaller ..." + status_msg "Launching crowsnest uninstaller ..." if ! make uninstall; then error_msg "Something went wrong! Please try again..." exit 1 fi if [[ -e "${CROWSNEST_DIR}" ]]; then - status_msg "Removing Crowsnest directory ..." + status_msg "Removing crowsnest directory ..." rm -rf "${CROWSNEST_DIR}" + ok_msg "Directory removed!" fi } -- 2.39.5 From e2a4bee5dc4e99c0a9ece0c77a8af67a3695b149 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 19:54:29 +0100 Subject: [PATCH 08/12] chore: fix one leftover typo Signed-off-by: Dominik Willner --- scripts/crowsnest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index b76957e..523de3f 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -22,7 +22,7 @@ set -e function multi_instance_message(){ echo -e "Crowsnest is NOT designed to support multi instances." - echo -e "A Workaround for this is to choose the most used instance as a 'master'" + echo -e "A workaround for this is to choose the most used instance as a 'master'" echo -e "Use this instance to set up your 'crowsnest.conf' and steering it's service.\n" echo -e "Found the following instances:\n" for i in ${1}; do -- 2.39.5 From 85849ecf5609c045991943b9d1590c71a0d2f646 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 3 Feb 2023 21:33:29 +0100 Subject: [PATCH 09/12] chore: add update functionality Signed-off-by: Stephan Wendel --- scripts/crowsnest.sh | 47 ++++++++++++++++++++++++++++++++++++++- scripts/ui/update_menu.sh | 2 +- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index 523de3f..90ba2e6 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -194,4 +194,49 @@ function compare_crowsnest_versions() { fi echo "${versions}" -} \ No newline at end of file +} + +function update_crowsnest() { + ## Helper Func + function install_crowsnest_dependencies() { + local packages + local install_script="${CROWSNEST_DIR}/tools/install.sh" + + ### read PKGLIST from official install-script + status_msg "Reading dependencies..." + # shellcheck disable=SC2016 + packages="$(grep "PKGLIST=" "${install_script}" | cut -d'"' -f2 | sed 's/\${PKGLIST}//g' | tr -d '\n')" + + echo "${cyan}${packages}${white}" | tr '[:space:]' '\n' + read -r -a packages <<< "${packages}" + + ### Update system package info + status_msg "Updating package lists..." + if ! sudo apt-get update --allow-releaseinfo-change; then + log_error "failure while updating package lists" + error_msg "Updating package lists failed!" + exit 1 + fi + + ### Install required packages + status_msg "Installing required packages..." + if ! sudo apt-get install --yes "${packages[@]}"; then + log_error "failure while installing required crowsnest packages" + error_msg "Installing required packages failed!" + exit 1 + fi + } + + do_action_service "stop" "crowsnest" + + if [[ ! -d ${CROWSNEST_DIR} ]]; then + clone_moonraker "${CROWSNEST_REPO}" + else + status_msg "Updating Crowsnest ..." + cd "${CROWSNEST_DIR}" && git pull + ### read PKGLIST and install possible new dependencies + install_crowsnest_dependencies + fi + ok_msg "Update complete!" + do_action_service "restart" "crowsnest" +} diff --git a/scripts/ui/update_menu.sh b/scripts/ui/update_menu.sh index 800edcf..8e7f7a9 100755 --- a/scripts/ui/update_menu.sh +++ b/scripts/ui/update_menu.sh @@ -64,7 +64,7 @@ function update_menu() { 8) do_action "update_moonraker_obico" "update_ui";; 9) - do_action "update_system" "update_crowsnest";; + do_action "update_crowsnest" "update_ui";; 10) do_action "update_system" "update_ui";; a) -- 2.39.5 From ce67e8ddb3a5cf67d2cb455e3754c3564f55e3d3 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 3 Feb 2023 21:39:34 +0100 Subject: [PATCH 10/12] chore: move nested function Signed-off-by: Stephan Wendel --- scripts/crowsnest.sh | 49 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index 90ba2e6..bbd5e95 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -196,37 +196,36 @@ function compare_crowsnest_versions() { echo "${versions}" } -function update_crowsnest() { - ## Helper Func - function install_crowsnest_dependencies() { - local packages - local install_script="${CROWSNEST_DIR}/tools/install.sh" +function install_crowsnest_dependencies() { + local packages + local install_script="${CROWSNEST_DIR}/tools/install.sh" - ### read PKGLIST from official install-script - status_msg "Reading dependencies..." - # shellcheck disable=SC2016 - packages="$(grep "PKGLIST=" "${install_script}" | cut -d'"' -f2 | sed 's/\${PKGLIST}//g' | tr -d '\n')" + ### read PKGLIST from official install-script + status_msg "Reading dependencies..." + # shellcheck disable=SC2016 + packages="$(grep "PKGLIST=" "${install_script}" | cut -d'"' -f2 | sed 's/\${PKGLIST}//g' | tr -d '\n')" - echo "${cyan}${packages}${white}" | tr '[:space:]' '\n' + echo "${cyan}${packages}${white}" | tr '[:space:]' '\n' read -r -a packages <<< "${packages}" - ### Update system package info - status_msg "Updating package lists..." - if ! sudo apt-get update --allow-releaseinfo-change; then - log_error "failure while updating package lists" - error_msg "Updating package lists failed!" - exit 1 - fi + ### Update system package info + status_msg "Updating package lists..." + if ! sudo apt-get update --allow-releaseinfo-change; then + log_error "failure while updating package lists" + error_msg "Updating package lists failed!" + exit 1 + fi - ### Install required packages - status_msg "Installing required packages..." - if ! sudo apt-get install --yes "${packages[@]}"; then - log_error "failure while installing required crowsnest packages" - error_msg "Installing required packages failed!" - exit 1 - fi - } + ### Install required packages + status_msg "Installing required packages..." + if ! sudo apt-get install --yes "${packages[@]}"; then + log_error "failure while installing required crowsnest packages" + error_msg "Installing required packages failed!" + exit 1 + fi +} +function update_crowsnest() { do_action_service "stop" "crowsnest" if [[ ! -d ${CROWSNEST_DIR} ]]; then -- 2.39.5 From 7945399923a1d887bfcefb60d6a6cc26e2cd49a4 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 3 Feb 2023 21:44:20 +0100 Subject: [PATCH 11/12] fix: fix typo in func update_crowsnest Signed-off-by: Stephan Wendel --- scripts/crowsnest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index bbd5e95..f8ed048 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -229,7 +229,7 @@ function update_crowsnest() { do_action_service "stop" "crowsnest" if [[ ! -d ${CROWSNEST_DIR} ]]; then - clone_moonraker "${CROWSNEST_REPO}" + clone_crowsnest else status_msg "Updating Crowsnest ..." cd "${CROWSNEST_DIR}" && git pull -- 2.39.5 From 078df2a0b91308702b2594ca5e1dd7ff8d6647bd Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 21:59:29 +0100 Subject: [PATCH 12/12] changelog.md: update changelog Signed-off-by: Dominik Willner --- docs/changelog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 6d1a9db..2381537 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,12 @@ This document covers possible important changes to KIAUH. +### 2023-02-03 +The installer for MJPG-Streamer got replaced by crowsnest. It is an improved webcam service, utilizing ustreamer. +Please have a look here for additional info about crowsnest and how to configure it: https://github.com/mainsail-crew/crowsnest \ +It's unsure if the previous MJPG-Streamer installer will be updated and make its way back into KIAUH. +A big thanks to [KwadFan](https://github.com/KwadFan) for writing the crowsnest implementation. + ### 2022-10-31 Some functions got updated, though not all of them. -- 2.39.5