- Ergänze die `ExecReload`-Anweisung in `install.sh`, um das Neuladen des Servers bei Empfang des SIGUSR1-Signals zu ermöglichen. - Dies verbessert die Handhabung von Konfigurationsänderungen ohne einen vollständigen Neustart des Servers.
100 lines
2.9 KiB
Bash
Executable File
100 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# YourChat Installations Script
|
|
# Installiert die Anwendung als Systemdienst
|
|
|
|
set -e # Beende bei Fehlern
|
|
|
|
echo "=== YourChat - Installation Script ==="
|
|
|
|
# Prüfe ob Build existiert
|
|
if [ ! -f "build/yourchat" ]; then
|
|
echo "Fehler: Build nicht gefunden. Bitte zuerst ./deploy/build.sh ausführen."
|
|
exit 1
|
|
fi
|
|
|
|
# Installationsverzeichnis erstellen
|
|
echo "=== Installationsverzeichnis erstellen ==="
|
|
sudo mkdir -p /opt/yourchat
|
|
sudo mkdir -p /opt/yourchat/logs
|
|
|
|
# Systemweite Konfiguration erstellen
|
|
echo "=== Systemweite Konfiguration erstellen ==="
|
|
sudo mkdir -p /etc/yourpart
|
|
|
|
# Anwendung installieren
|
|
echo "=== Anwendung installieren ==="
|
|
sudo cp build/yourchat /opt/yourchat/
|
|
sudo cp build/ws_probe /opt/yourchat/
|
|
sudo chmod +x /opt/yourchat/yourchat
|
|
sudo chmod +x /opt/yourchat/ws_probe
|
|
|
|
# Konfiguration installieren (nur wenn nicht vorhanden)
|
|
echo "=== Konfiguration installieren ==="
|
|
if [ ! -f "/etc/yourpart/chatconfig.json" ]; then
|
|
sudo cp config/chatconfig.json /etc/yourpart/
|
|
echo "Konfigurationsdatei installiert."
|
|
else
|
|
echo "Konfigurationsdatei existiert bereits - wird nicht überschrieben."
|
|
fi
|
|
|
|
# Korrigiere falls die Datei am falschen Ort liegt
|
|
if [ -f "/opt/yourchat/chatconfig.json" ] && [ ! -f "/etc/yourpart/chatconfig.json" ]; then
|
|
echo "Korrigiere Konfigurationsdatei-Pfad..."
|
|
sudo mv /opt/yourchat/chatconfig.json /etc/yourpart/
|
|
sudo chown yourchat:yourchat /etc/yourpart/chatconfig.json
|
|
sudo chmod 644 /etc/yourpart/chatconfig.json
|
|
fi
|
|
|
|
# Systemd Service erstellen
|
|
echo "=== Systemd Service erstellen ==="
|
|
sudo tee /etc/systemd/system/yourchat.service > /dev/null <<EOF
|
|
[Unit]
|
|
Description=YourChat Server
|
|
After=network.target postgresql.service
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=yourchat
|
|
Group=yourchat
|
|
WorkingDirectory=/opt/yourchat
|
|
ExecStart=/opt/yourchat/yourchat
|
|
ExecReload=/bin/kill -USR1 \$MAINPID
|
|
Restart=always
|
|
RestartSec=10
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
# Benutzer erstellen
|
|
echo "=== Benutzer erstellen ==="
|
|
if ! id "yourchat" &>/dev/null; then
|
|
sudo useradd -r -s /bin/false -d /opt/yourchat yourchat
|
|
echo "Benutzer 'yourchat' erstellt."
|
|
else
|
|
echo "Benutzer 'yourchat' existiert bereits."
|
|
fi
|
|
|
|
# Berechtigungen setzen
|
|
echo "=== Berechtigungen setzen ==="
|
|
sudo chown -R yourchat:yourchat /opt/yourchat
|
|
sudo chmod 755 /opt/yourchat
|
|
sudo chown yourchat:yourchat /etc/yourpart/chatconfig.json
|
|
sudo chmod 644 /etc/yourpart/chatconfig.json
|
|
|
|
# Systemd Service aktivieren
|
|
echo "=== Systemd Service aktivieren ==="
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable yourchat.service
|
|
|
|
echo "=== Installation abgeschlossen! ==="
|
|
echo ""
|
|
echo "Nächste Schritte:"
|
|
echo "1. Konfiguration anpassen: sudo nano /opt/yourchat/config/chatconfig.json"
|
|
echo "2. Service starten: sudo systemctl start yourchat"
|
|
echo "3. Status prüfen: sudo systemctl status yourchat"
|
|
echo "4. Logs anzeigen: sudo journalctl -u yourchat -f"
|