init.sh hinzugefügt

This commit is contained in:
2025-12-19 15:43:57 +01:00
commit c607f18605
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -euo pipefail
# --- Check for root ---
if [[ "$EUID" -ne 0 ]]; then
echo "❌ Bitte als root ausführen (sudo)."
exit 1
fi
# --- User input ---
read -rp "Newt ID: " NEWT_ID
read -rp "Newt Secret: " NEWT_SECRET
read -rp "Newt Endpoint (z.B. https://app.pangolin.net): " NEWT_ENDPOINT
echo
echo "➡️ Installiere newt über Pangolin Installer..."
curl -fsSL https://static.pangolin.net/get-newt.sh | bash
# --- Verify binary ---
if [[ ! -x /usr/local/bin/newt ]]; then
echo "❌ newt wurde nicht korrekt installiert."
exit 1
fi
echo "✅ newt installiert."
# --- Create systemd service ---
echo "➡️ Erstelle systemd Service..."
cat >/etc/systemd/system/newt.service <<EOF
[Unit]
Description=Newt
After=network.target
[Service]
ExecStart=/usr/local/bin/newt --id ${NEWT_ID} --secret ${NEWT_SECRET} --endpoint ${NEWT_ENDPOINT}
Restart=always
User=root
[Install]
WantedBy=multi-user.target
EOF
# --- Reload & enable ---
systemctl daemon-reexec
systemctl daemon-reload
systemctl enable newt.service
systemctl restart newt.service
echo
echo "🎉 newt Service wurde erfolgreich installiert und gestartet!"
echo "🔍 Status:"
systemctl status newt.service --no-pager