Refactor update_script for Kasm updates

This commit is contained in:
Tobias
2025-11-18 21:31:04 +01:00
committed by GitHub
parent 4b6106c2fb
commit 6013871809

View File

@@ -25,23 +25,28 @@ function update_script() {
header_info header_info
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -d /var ]]; then if [[ ! -d /opt/kasm/current ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
msg_info "Updating Kasm" msg_info "Checking for new version"
cd /tmp CURRENT_VERSION=$(readlink -f /opt/kasm/current | awk -F'/' '{print $4}')
KASM_URL=$(curl -fsSL "https://www.kasm.com/downloads" \ KASM_URL=$(curl -fsSL "https://www.kasm.com/downloads" | tr '\n' ' ' | grep -oE 'https://kasm-static-content[^"]*kasm_release_[0-9]+\.[0-9]+\.[0-9]+\.[a-z0-9]+\.tar\.gz' | head -n 1)
| tr '\n' ' ' \
| grep -oE 'https://kasm-static-content[^"]*kasm_release_[0-9]+\.[0-9]+\.[0-9]+\.[a-z0-9]+\.tar\.gz' \
| head -n 1
)
if [[ -z "$KASM_URL" ]]; then if [[ -z "$KASM_URL" ]]; then
msg_error "Unable to detect latest Kasm release URL." msg_error "Unable to detect latest Kasm release URL."
exit 1 exit 1
fi fi
KASM_VERSION=$(echo "$KASM_URL" | sed -E 's/.*kasm_release_([0-9]+\.[0-9]+\.[0-9]+).*/\1/') KASM_VERSION=$(echo "$KASM_URL" | sed -E 's/.*kasm_release_([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
msg_info "Checked for new version"
msg_info "Removing outdated docker-compose plugin"
[ -f ~/.docker/cli-plugins/docker-compose ] && rm -rf ~/.docker/cli-plugins/docker-compose
msg_ok "Removed outdated docker-compose plugin"
if [[ -z "$CURRENT_VERSION" ]] || [[ "$KASM_VERSION" != "$CURRENT_VERSION" ]]; then
msg_info "Updating Kasm"
cd /tmp
msg_warn "WARNING: This script will run an external installer from a third-party source (https://www.kasmweb.com/)." msg_warn "WARNING: This script will run an external installer from a third-party source (https://www.kasmweb.com/)."
msg_warn "The following code is NOT maintained or audited by our repository." msg_warn "The following code is NOT maintained or audited by our repository."
@@ -61,6 +66,10 @@ function update_script() {
bash /tmp/kasm_release/upgrade.sh --proxy-port 443 bash /tmp/kasm_release/upgrade.sh --proxy-port 443
rm -rf /tmp/kasm_release rm -rf /tmp/kasm_release
msg_ok "Updated Successfully" msg_ok "Updated Successfully"
else
msg_ok "No update required. Kasm is already at v${KASM_VERSION}"
fi
exit exit
} }