feat: install uncloud-uninstall script when provisioning machine

This commit is contained in:
Pavel Sviderski
2025-03-04 12:50:29 +10:00
parent 91d58bc701
commit 90e357a1dc
2 changed files with 19 additions and 1 deletions
+14
View File
@@ -111,12 +111,16 @@ install_uncloud_binaries() {
trap "rm -rf '$tmp_dir'" EXIT trap "rm -rf '$tmp_dir'" EXIT
local uncloudd_url local uncloudd_url
local uninstall_url
if [ "${UNCLOUD_VERSION}" == "latest" ]; then if [ "${UNCLOUD_VERSION}" == "latest" ]; then
uncloudd_url="${UNCLOUD_GITHUB_URL}/releases/latest/download/uncloudd_linux_${file_arch}.tar.gz" uncloudd_url="${UNCLOUD_GITHUB_URL}/releases/latest/download/uncloudd_linux_${file_arch}.tar.gz"
uninstall_url="https://github.com/psviderski/uncloud/blob/main/scripts/uninstall.sh"
else else
uncloudd_url="${UNCLOUD_GITHUB_URL}/releases/download/${UNCLOUD_VERSION}/uncloudd_linux_${file_arch}.tar.gz" uncloudd_url="${UNCLOUD_GITHUB_URL}/releases/download/${UNCLOUD_VERSION}/uncloudd_linux_${file_arch}.tar.gz"
uninstall_url="https://github.com/psviderski/uncloud/blob/${UNCLOUD_VERSION}/scripts/uninstall.sh"
fi fi
local uncloudd_download_path="${tmp_dir}/uncloudd.tar.gz" local uncloudd_download_path="${tmp_dir}/uncloudd.tar.gz"
local uninstall_download_path="${tmp_dir}/uninstall.sh"
log "⏳ Downloading uncloudd binary: ${uncloudd_url}" log "⏳ Downloading uncloudd binary: ${uncloudd_url}"
if ! curl -fsSL -o "${uncloudd_download_path}" "${uncloudd_url}"; then if ! curl -fsSL -o "${uncloudd_download_path}" "${uncloudd_url}"; then
@@ -128,6 +132,16 @@ install_uncloud_binaries() {
fi fi
log "✓ uncloudd binary installed: ${uncloudd_install_path}" log "✓ uncloudd binary installed: ${uncloudd_install_path}"
log "⏳ Downloading uninstall script: ${uninstall_url}"
if ! curl -fsSL -o "${uninstall_download_path}" "${uninstall_url}"; then
error "Failed to download uninstall script."
fi
local uninstall_install_path="${INSTALL_BIN_DIR}/uncloud-uninstall"
if ! install "${uninstall_download_path}" "${uninstall_install_path}"; then
error "Failed to install uninstall.sh script to ${uninstall_install_path}"
fi
log "✓ uncloud-uninstall script installed: ${uninstall_install_path}"
# TODO: install uncloud CLI binary and create a uc alias. # TODO: install uncloud CLI binary and create a uc alias.
} }
+5 -1
View File
@@ -41,7 +41,7 @@ if [ "$EUID" -ne 0 ]; then
fi fi
# Confirm before proceeding. # Confirm before proceeding.
log "⚠️This script will uninstall Uncloud and remove ALL service containers deployed to this machine." log "⚠️This script will uninstall Uncloud and remove ALL Uncloud managed containers on this machine."
log "The following actions will be performed:" log "The following actions will be performed:"
echo "- Remove Uncloud systemd services" echo "- Remove Uncloud systemd services"
echo "- Remove Uncloud binaries and data" echo "- Remove Uncloud binaries and data"
@@ -128,6 +128,10 @@ else
log "WireGuard interface uncloud not found." log "WireGuard interface uncloud not found."
fi fi
log "⏳ Removing uninstall script..."
rm -fv "${INSTALL_BIN_DIR}/uncloud-uninstall"
log "✓ Uninstall script removed."
echo echo
log "✅ Uncloud has been uninstalled successfully!" log "✅ Uncloud has been uninstalled successfully!"
log "Note: Docker installation was preserved. If you want to completely remove Docker as well, \ log "Note: Docker installation was preserved. If you want to completely remove Docker as well, \