diff --git a/scripts/install.sh b/scripts/install.sh index 63475f33..028a7200 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -111,12 +111,16 @@ install_uncloud_binaries() { trap "rm -rf '$tmp_dir'" EXIT local uncloudd_url + local uninstall_url if [ "${UNCLOUD_VERSION}" == "latest" ]; then 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 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 local uncloudd_download_path="${tmp_dir}/uncloudd.tar.gz" + local uninstall_download_path="${tmp_dir}/uninstall.sh" log "⏳ Downloading uncloudd binary: ${uncloudd_url}" if ! curl -fsSL -o "${uncloudd_download_path}" "${uncloudd_url}"; then @@ -128,6 +132,16 @@ install_uncloud_binaries() { fi 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. } diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index 4e268acb..b192579e 100644 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -41,7 +41,7 @@ if [ "$EUID" -ne 0 ]; then fi # 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:" echo "- Remove Uncloud systemd services" echo "- Remove Uncloud binaries and data" @@ -128,6 +128,10 @@ else log "WireGuard interface uncloud not found." fi +log "⏳ Removing uninstall script..." +rm -fv "${INSTALL_BIN_DIR}/uncloud-uninstall" +log "✓ Uninstall script removed." + echo log "✅ Uncloud has been uninstalled successfully!" log "Note: Docker installation was preserved. If you want to completely remove Docker as well, \