Files
fuesse-sexy/install.sh
Guido ef67219e73 install.sh startet Server detached; blaues Herz aus Emoji-Level entfernt
- install.sh startet den Server nach dem Setup im Hintergrund (nohup, PID-/Logfile,
  sauberer Neustart falls schon eine Instanz laeuft)
- server.pid/server.log in .gitignore
- 💙 aus scenes/emoji-chaos/config.json props entfernt

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-04 18:11:06 +02:00

120 lines
3.4 KiB
Bash
Executable File

#!/bin/sh
# Ein-Befehl-Setup fuer fuesse.sexy — installiert bei Bedarf Node.js selbst.
# Aufruf: ./install.sh (oder: sh install.sh)
set -e
echo ""
echo "🦶 fuesse.sexy — Setup"
echo "------------------------"
# Root/sudo bestimmen (fuer Systempakete)
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
elif command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
else
SUDO=""
fi
NODE_MAJOR=20 # LTS
install_node() {
echo ""
echo "📥 Node.js nicht gefunden — installiere Node ${NODE_MAJOR} automatisch ..."
OS="$(uname -s)"
if [ "$OS" = "Linux" ]; then
if command -v apt-get >/dev/null 2>&1; then
export DEBIAN_FRONTEND=noninteractive
$SUDO apt-get update
$SUDO apt-get install -y ca-certificates curl gnupg
curl -fsSL "https://deb.nodesource.com/setup_${NODE_MAJOR}.x" | $SUDO bash -
$SUDO apt-get install -y nodejs
elif command -v dnf >/dev/null 2>&1; then
curl -fsSL "https://rpm.nodesource.com/setup_${NODE_MAJOR}.x" | $SUDO bash -
$SUDO dnf install -y nodejs
elif command -v yum >/dev/null 2>&1; then
curl -fsSL "https://rpm.nodesource.com/setup_${NODE_MAJOR}.x" | $SUDO bash -
$SUDO yum install -y nodejs
elif command -v apk >/dev/null 2>&1; then
$SUDO apk add --no-cache nodejs npm
elif command -v pacman >/dev/null 2>&1; then
$SUDO pacman -Sy --noconfirm nodejs npm
else
echo "❌ Kein bekannter Paketmanager gefunden."
echo " Bitte Node.js manuell installieren: https://nodejs.org/"
exit 1
fi
elif [ "$OS" = "Darwin" ]; then
if command -v brew >/dev/null 2>&1; then
brew install node
else
echo "❌ Homebrew nicht gefunden."
echo " Bitte Node.js installieren: https://nodejs.org/ (LTS)"
exit 1
fi
else
echo "❌ Unbekanntes System ($OS) — bitte Node.js manuell installieren."
exit 1
fi
}
# 1) Node vorhanden? Sonst installieren.
if command -v node >/dev/null 2>&1; then
echo "✅ Node gefunden ($(node -v))"
else
install_node
if ! command -v node >/dev/null 2>&1; then
echo "❌ Node-Installation fehlgeschlagen. Bitte manuell installieren."
exit 1
fi
echo "✅ Node installiert ($(node -v))"
fi
# 2) npm vorhanden?
if ! command -v npm >/dev/null 2>&1; then
echo "❌ npm nicht gefunden (sollte mit Node kommen). Bitte npm installieren."
exit 1
fi
# 3) Abhaengigkeiten installieren
echo ""
echo "📦 Installiere Abhaengigkeiten (npm install) ..."
npm install
# 4) Server detached starten (laeuft im Hintergrund weiter, auch nach Logout)
PIDFILE="server.pid"
LOGFILE="server.log"
if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE" 2>/dev/null)" 2>/dev/null; then
OLD_PID="$(cat "$PIDFILE")"
echo ""
echo "🔄 Server läuft bereits (PID $OLD_PID) — wird neu gestartet ..."
kill "$OLD_PID" 2>/dev/null || true
sleep 1
fi
echo ""
echo "🚀 Starte Server im Hintergrund ..."
nohup node server/index.js > "$LOGFILE" 2>&1 < /dev/null &
NEW_PID=$!
echo "$NEW_PID" > "$PIDFILE"
sleep 1
if kill -0 "$NEW_PID" 2>/dev/null; then
echo ""
echo "🎉 Fertig! Server läuft (PID $NEW_PID)."
echo " Öffnen: http://<server-ip>:3000"
echo " Logs: tail -f server.log"
echo " Stoppen: kill \$(cat server.pid)"
echo ""
echo " (Für Autostart beim Boot: systemd-Dienst aus DEPLOY.md einrichten.)"
echo ""
else
echo ""
echo "❌ Server konnte nicht starten. Letzte Log-Zeilen:"
tail -n 20 "$LOGFILE" 2>/dev/null
exit 1
fi