@@ -25,14 +25,51 @@ function update_script() {
2525 header_info
2626 check_container_storage
2727 check_container_resources
28- if [[ ! -d /var ]]; then
28+ if [[ ! -d /opt/kasm/current ]]; then
2929 msg_error " No ${APP} Installation Found!"
3030 exit
3131 fi
32- msg_info " Updating LXC"
33- $STD apt update
34- $STD apt -y upgrade
35- msg_ok " Updated LXC"
32+
33+ msg_info " Checking for new version"
34+ CURRENT_VERSION=$( readlink -f /opt/kasm/current | awk -F' /' ' {print $4}' )
35+ 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)
36+ if [[ -z " $KASM_URL " ]]; then
37+ msg_error " Unable to detect latest Kasm release URL."
38+ exit 1
39+ fi
40+ KASM_VERSION=$( echo " $KASM_URL " | sed -E ' s/.*kasm_release_([0-9]+\.[0-9]+\.[0-9]+).*/\1/' )
41+ msg_info " Checked for new version"
42+
43+ msg_info " Removing outdated docker-compose plugin"
44+ [ -f ~ /.docker/cli-plugins/docker-compose ] && rm -rf ~ /.docker/cli-plugins/docker-compose
45+ msg_ok " Removed outdated docker-compose plugin"
46+
47+ if [[ -z " $CURRENT_VERSION " ]] || [[ " $KASM_VERSION " != " $CURRENT_VERSION " ]]; then
48+ msg_info " Updating Kasm"
49+ cd /tmp
50+
51+ msg_warn " WARNING: This script will run an external installer from a third-party source (https://www.kasmweb.com/)."
52+ msg_warn " The following code is NOT maintained or audited by our repository."
53+ msg_warn " If you have any doubts or concerns, please review the installer code before proceeding:"
54+ msg_custom " ${TAB3}${GATEWAY}${BGN}${CL} " " \e[1;34m" " → upgrade.sh inside tar.gz $KASM_URL "
55+ echo
56+ read -r -p " ${TAB3} Do you want to continue? [y/N]: " CONFIRM
57+ if [[ ! " $CONFIRM " =~ ^([yY][eE][sS]| [yY])$ ]]; then
58+ msg_error " Aborted by user. No changes have been made."
59+ exit 10
60+ fi
61+ curl -fsSL -o " /tmp/kasm_release_${KASM_VERSION} .tar.gz" " $KASM_URL "
62+ tar -xf " kasm_release_${KASM_VERSION} .tar.gz"
63+ chmod +x /tmp/kasm_release/install.sh
64+ rm -f /tmp/kasm_release_${KASM_VERSION} .tar.gz
65+
66+ bash /tmp/kasm_release/upgrade.sh --proxy-port 443
67+ rm -rf /tmp/kasm_release
68+ msg_ok " Updated Successfully"
69+ else
70+ msg_ok " No update required. Kasm is already at v${KASM_VERSION} "
71+
72+ fi
3673 exit
3774}
3875
0 commit comments