diff --git a/install_newt_v2.sh b/install_newt_v2.sh index 6cbe861..cc30e99 100644 --- a/install_newt_v2.sh +++ b/install_newt_v2.sh @@ -6,6 +6,8 @@ INSTALL_DIR="/opt/newt" SERVICE_NAME="PVE-MGNT" SYMLINK="${INSTALL_DIR}/newt_latest" SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service" +UPDATER_SERVICE="/etc/systemd/system/newt-updater.service" +UPDATER_TIMER="/etc/systemd/system/newt-updater.timer" GREEN='\033[0;32m' YELLOW='\033[1;33m' @@ -29,27 +31,27 @@ download_newt() { x86_64) file="newt_linux_amd64" ;; aarch64) file="newt_linux_arm64" ;; armv7l) file="newt_linux_arm32" ;; - *) error "Nicht unterstützte Architektur: $arch" ;; + *) error "Unsupported architecture: $arch" ;; esac local url="https://github.com/${REPO}/releases/download/${version}/${file}" local target="${INSTALL_DIR}/newt_${version}" mkdir -p "$INSTALL_DIR" - info "⬇️ Lade $url herunter …" - curl -fsSL "$url" -o "${target}.tmp" || error "Download fehlgeschlagen." + info "⬇️ Downloading $url …" + curl -fsSL "$url" -o "${target}.tmp" || error "Download failed." chmod +x "${target}.tmp" mv "${target}.tmp" "$target" ln -sf "$target" "$SYMLINK" - info "✅ newt ${version} installiert als ${target}" + info "✅ Installed newt ${version} at ${target}" } setup_systemd_service() { - echo "🆔 Bitte gib die Pangolin-ID ein: " + echo "🆔 Please enter the Pangolin ID: " read -r PANGOLIN_ID - echo "🔑 Bitte gib das Secret ein: " + echo "🔑 Please enter the Secret: " read -r PANGOLIN_SECRET - echo "🌐 Bitte gib den Endpoint (z. B. https://pangolin.domain.de) ein: " + echo "🌐 Please enter the Endpoint (e.g. https://pangolin.domain.com): " read -r PANGOLIN_ENDPOINT cat > "$SERVICE_FILE" < "$UPDATER_SERVICE" < "$UPDATER_TIMER" </dev/null || true + rm -f "$SERVICE_FILE" + + # Remove updater + if systemctl is-active --quiet newt-updater.timer; then + systemctl stop newt-updater.timer + fi + systemctl disable newt-updater.timer 2>/dev/null || true + rm -f "$UPDATER_SERVICE" "$UPDATER_TIMER" + + systemctl daemon-reload + + # Delete installation dir (ask first) + if [ -d "$INSTALL_DIR" ]; then + read -p "❓ Do you want to remove ${INSTALL_DIR} and all versions? (y/N): " yn + case $yn in + [Yy]*) rm -rf "$INSTALL_DIR"; info "📂 ${INSTALL_DIR} was removed." ;; + *) warn "📂 ${INSTALL_DIR} was NOT removed." ;; + esac + fi + + info "🧹 Uninstallation completed!" } main() { @@ -127,8 +199,11 @@ main() { --reinstall) mode_reinstall ;; + --uninstall) + mode_uninstall + ;; *) - error "❌ Unbekannter Parameter: $1 (verwende --install, --update oder --reinstall)" + error "❌ Unknown parameter: $1 (use --install, --update, --reinstall or --uninstall)" ;; esac }