53 lines
1.2 KiB
Bash
53 lines
1.2 KiB
Bash
|
|
#!/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
|