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)