From bad757e74fab3e507c55d7c52d14f14645c01f0c Mon Sep 17 00:00:00 2001 From: "manuel.maier" Date: Tue, 5 Aug 2025 23:40:47 +0200 Subject: [PATCH] =?UTF-8?q?reinstall=5Fnewt.sh=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall_newt.sh | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 reinstall_newt.sh diff --git a/reinstall_newt.sh b/reinstall_newt.sh new file mode 100644 index 0000000..86e19de --- /dev/null +++ b/reinstall_newt.sh @@ -0,0 +1,99 @@ +#!/bin/bash +set -e + +REPO="fosrl/newt" +INSTALL_DIR="/opt/newt" +SERVICE_NAME="PVE-MGNT" +SYMLINK="${INSTALL_DIR}/newt_latest" +SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service" + +info() { echo -e "\033[0;32m[INFO]\033[0m $1"; } +error() { echo -e "\033[0;31m[ERROR]\033[0m $1"; exit 1; } + +get_latest_version() { + curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep -Po '"tag_name": *"\K[^"]+' +} + +download_newt() { + local version="$1" + local arch=$(uname -m) + local file="" + + case "$arch" in + x86_64) file="newt_linux_amd64" ;; + aarch64) file="newt_linux_arm64" ;; + armv7l) file="newt_linux_arm32" ;; + *) error "Nicht unterstützte Architektur: $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." + chmod +x "${target}.tmp" + mv "${target}.tmp" "$target" + ln -sf "$target" "$SYMLINK" + info "✅ newt ${version} installiert als ${target}" +} + +cleanup_old_versions() { + cd "$INSTALL_DIR" + local keep=$(readlink -f newt_latest) + local versions=($(ls -1 newt_* | grep -v latest | sort -Vr)) + local count=0 + for ver in "${versions[@]}"; do + if [[ "$(readlink -f "$ver")" != "$keep" ]]; then + ((count++)) + if [ "$count" -gt 1 ]; then + info "🧹 Entferne alte Version: $ver" + rm -f "$ver" + fi + fi + done +} + +setup_systemd_service() { + echo "🆔 Bitte gib die Pangolin-ID ein: " + read -r PANGOLIN_ID + echo "🔑 Bitte gib das Secret ein: " + read -r PANGOLIN_SECRET + echo "🌐 Bitte gib den Endpoint (z. B. https://pangolin.domain.de) ein: " + read -r PANGOLIN_ENDPOINT + + cat > "$SERVICE_FILE" <