Aktualisiere die Compiler-Version in CMakeLists.txt und install-dependencies-ubuntu22.sh von GCC 15 auf GCC 13 für bessere Unterstützung von C++23. Passe die Installationsmeldungen und Standard-Compiler-Einstellungen entsprechend an.
This commit is contained in:
committed by
Torsten (PC)
parent
b1f9073f4d
commit
c2a54e29f8
160
deploy-server.sh
Normal file
160
deploy-server.sh
Normal file
@@ -0,0 +1,160 @@
|
||||
#!/bin/bash
|
||||
|
||||
# YourPart Daemon Server-Side Deployment Script
|
||||
# Führen Sie dieses Script auf dem Server aus, nachdem Sie den Code hochgeladen haben
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Farben für Output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Konfiguration
|
||||
DAEMON_USER="yourpart"
|
||||
PROJECT_NAME="yourpart-daemon"
|
||||
REMOTE_DIR="/opt/yourpart"
|
||||
SERVICE_NAME="yourpart-daemon"
|
||||
BUILD_DIR="build"
|
||||
|
||||
# Funktionen
|
||||
log_info() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Prüfe ob wir im richtigen Verzeichnis sind
|
||||
if [ ! -f "CMakeLists.txt" ] || [ ! -f "daemon.conf" ]; then
|
||||
log_error "Bitte führen Sie dieses Script aus dem Projektverzeichnis aus!"
|
||||
log_info "Stellen Sie sicher, dass CMakeLists.txt und daemon.conf vorhanden sind."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Starte Server-Side Deployment für YourPart Daemon..."
|
||||
|
||||
# 1. Prüfe Dependencies
|
||||
log_info "Prüfe Dependencies..."
|
||||
if ! command -v cmake &> /dev/null; then
|
||||
log_error "CMake nicht gefunden. Führen Sie zuerst install-dependencies-ubuntu22.sh aus!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v gcc-15 &> /dev/null && ! command -v gcc &> /dev/null; then
|
||||
log_error "GCC nicht gefunden. Führen Sie zuerst install-dependencies-ubuntu22.sh aus!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2. Baue Projekt
|
||||
log_info "Baue Projekt auf dem Server..."
|
||||
if [ ! -d "$BUILD_DIR" ]; then
|
||||
mkdir "$BUILD_DIR"
|
||||
fi
|
||||
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
# Konfiguriere CMake
|
||||
log_info "Konfiguriere CMake..."
|
||||
if command -v gcc-15 &> /dev/null; then
|
||||
log_info "Verwende GCC 15 für C++23"
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=23 -DCMAKE_C_COMPILER=gcc-15 -DCMAKE_CXX_COMPILER=g++-15
|
||||
elif command -v gcc-13 &> /dev/null; then
|
||||
log_info "Verwende GCC 13 für C++23"
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=23 -DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13
|
||||
else
|
||||
log_info "Verwende Standard-GCC 11 mit C++20"
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20
|
||||
fi
|
||||
|
||||
# Kompiliere
|
||||
log_info "Kompiliere Projekt..."
|
||||
make -j$(nproc)
|
||||
|
||||
cd ..
|
||||
|
||||
log_success "Build abgeschlossen"
|
||||
|
||||
# 3. Erstelle Benutzer falls nicht vorhanden
|
||||
log_info "Prüfe Benutzer $DAEMON_USER..."
|
||||
if ! id "$DAEMON_USER" &>/dev/null; then
|
||||
log_info "Erstelle Benutzer $DAEMON_USER..."
|
||||
useradd --system --shell /bin/false --home-dir "$REMOTE_DIR" --create-home "$DAEMON_USER"
|
||||
log_success "Benutzer $DAEMON_USER erstellt"
|
||||
else
|
||||
log_info "Benutzer $DAEMON_USER existiert bereits"
|
||||
fi
|
||||
|
||||
# 4. Erstelle Verzeichnisse
|
||||
log_info "Erstelle Verzeichnisse..."
|
||||
mkdir -p "$REMOTE_DIR"/{logs,config}
|
||||
mkdir -p /etc/yourpart
|
||||
mkdir -p /var/log/yourpart
|
||||
|
||||
# 5. Kopiere Dateien
|
||||
log_info "Kopiere Dateien..."
|
||||
cp "$BUILD_DIR/yourpart-daemon" /usr/local/bin/
|
||||
cp daemon.conf /etc/yourpart/
|
||||
cp yourpart-daemon.service /etc/systemd/system/
|
||||
|
||||
# 6. Setze Berechtigungen
|
||||
log_info "Setze Berechtigungen..."
|
||||
chmod +x /usr/local/bin/yourpart-daemon
|
||||
chown -R "$DAEMON_USER:$DAEMON_USER" "$REMOTE_DIR"
|
||||
chown -R "$DAEMON_USER:$DAEMON_USER" /var/log/yourpart
|
||||
chmod 600 /etc/yourpart/daemon.conf
|
||||
|
||||
# 7. Lade systemd neu
|
||||
log_info "Lade systemd Konfiguration neu..."
|
||||
systemctl daemon-reload
|
||||
|
||||
# 8. Aktiviere Service
|
||||
log_info "Aktiviere Service..."
|
||||
systemctl enable "$SERVICE_NAME"
|
||||
|
||||
# 9. Starte Service
|
||||
log_info "Starte Service..."
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
log_info "Service läuft bereits, starte neu..."
|
||||
systemctl restart "$SERVICE_NAME"
|
||||
else
|
||||
systemctl start "$SERVICE_NAME"
|
||||
fi
|
||||
|
||||
# 10. Prüfe Status
|
||||
log_info "Prüfe Service-Status..."
|
||||
sleep 2
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
log_success "Service läuft erfolgreich!"
|
||||
systemctl status "$SERVICE_NAME" --no-pager
|
||||
else
|
||||
log_error "Service konnte nicht gestartet werden!"
|
||||
log_info "Logs anzeigen mit: journalctl -u $SERVICE_NAME -f"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 11. Zeige nützliche Befehle
|
||||
log_success "Deployment erfolgreich abgeschlossen!"
|
||||
log_info ""
|
||||
log_info "Nützliche Befehle:"
|
||||
log_info "- Service-Status: systemctl status $SERVICE_NAME"
|
||||
log_info "- Service stoppen: systemctl stop $SERVICE_NAME"
|
||||
log_info "- Service starten: systemctl start $SERVICE_NAME"
|
||||
log_info "- Service neustarten: systemctl restart $SERVICE_NAME"
|
||||
log_info "- Logs anzeigen: journalctl -u $SERVICE_NAME -f"
|
||||
log_info "- Logs der letzten 100 Zeilen: journalctl -u $SERVICE_NAME -n 100"
|
||||
log_info ""
|
||||
log_info "Konfigurationsdatei: /etc/yourpart/daemon.conf"
|
||||
log_info "Log-Verzeichnis: /var/log/yourpart/"
|
||||
log_info "Service-Datei: /etc/systemd/system/$SERVICE_NAME.service"
|
||||
Reference in New Issue
Block a user