chore: add update functionality
Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
@@ -194,4 +194,49 @@ function compare_crowsnest_versions() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${versions}"
|
echo "${versions}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function update_menu() {
|
|||||||
8)
|
8)
|
||||||
do_action "update_moonraker_obico" "update_ui";;
|
do_action "update_moonraker_obico" "update_ui";;
|
||||||
9)
|
9)
|
||||||
do_action "update_system" "update_crowsnest";;
|
do_action "update_crowsnest" "update_ui";;
|
||||||
10)
|
10)
|
||||||
do_action "update_system" "update_ui";;
|
do_action "update_system" "update_ui";;
|
||||||
a)
|
a)
|
||||||
|
|||||||
Reference in New Issue
Block a user