diff --git a/deploy.sh b/deploy.sh index 9e6f149..82bfe74 100755 --- a/deploy.sh +++ b/deploy.sh @@ -52,7 +52,7 @@ if [ ! -d "build" ]; then fi cd build -cmake .. -DCMAKE_BUILD_TYPE=Release +cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 make -j$(nproc) cd .. diff --git a/install-dependencies-ubuntu22.sh b/install-dependencies-ubuntu22.sh new file mode 100644 index 0000000..8b62936 --- /dev/null +++ b/install-dependencies-ubuntu22.sh @@ -0,0 +1,201 @@ +#!/bin/bash + +# YourPart Daemon Dependencies Installation Script für Ubuntu 22 +# Optimiert für Ubuntu 22.04 LTS mit verfügbaren Paketen + +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 + +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" +} + +log_info "Installiere Dependencies für YourPart Daemon auf Ubuntu 22.04 LTS..." + +# Prüfe Ubuntu Version +if ! grep -q "22.04" /etc/os-release; then + log_warning "Dieses Script ist für Ubuntu 22.04 optimiert. Andere Versionen könnten Probleme haben." +fi + +# Update Package Lists +log_info "Aktualisiere Paketlisten..." +apt update + +# Installiere Build-Tools +log_info "Installiere Build-Tools..." +apt install -y \ + build-essential \ + cmake \ + pkg-config \ + git \ + curl \ + wget \ + software-properties-common + +# Installiere Standard C++ Compiler (GCC 11) +log_info "Installiere GCC 11 (Standard für Ubuntu 22.04)..." +apt install -y gcc g++ + +# Prüfe Compiler-Versionen +log_info "Verfügbare Compiler-Versionen:" +gcc --version | head -1 +g++ --version | head -1 + +# Installiere PostgreSQL Repository +log_info "Füge PostgreSQL Repository hinzu..." +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - +echo "deb http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list +apt update + +# Installiere PostgreSQL Development Libraries +log_info "Installiere PostgreSQL Development Libraries..." +apt install -y \ + postgresql-client-14 \ + postgresql-server-dev-14 \ + libpq-dev \ + libpqxx-dev + +# Installiere libwebsockets +log_info "Installiere libwebsockets..." +apt install -y \ + libwebsockets-dev \ + libssl-dev \ + libz-dev + +# Installiere nlohmann-json +log_info "Installiere nlohmann-json..." +apt install -y nlohmann-json3-dev + +# Installiere PostgreSQL Server (falls nicht vorhanden) +log_info "Prüfe PostgreSQL Installation..." +if ! systemctl is-active --quiet postgresql; then + log_info "Installiere PostgreSQL Server..." + apt install -y postgresql-14 postgresql-contrib-14 + + # Starte PostgreSQL + systemctl start postgresql + systemctl enable postgresql + + log_success "PostgreSQL installiert und gestartet" +else + log_success "PostgreSQL läuft bereits" +fi + +# Erstelle Datenbank und Benutzer +log_info "Konfiguriere PostgreSQL..." +sudo -u postgres psql << EOF +-- Erstelle Benutzer falls nicht vorhanden +DO \$\$ +BEGIN + IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'yourpart') THEN + CREATE USER yourpart WITH PASSWORD 'hitomisan'; + END IF; +END +\$\$; + +-- Erstelle Datenbank falls nicht vorhanden +SELECT 'CREATE DATABASE yp3 OWNER yourpart' +WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'yp3')\gexec + +-- Setze Berechtigungen +GRANT ALL PRIVILEGES ON DATABASE yp3 TO yourpart; +\q +EOF + +log_success "PostgreSQL konfiguriert" + +# Installiere systemd (sollte bereits vorhanden sein) +log_info "Prüfe systemd..." +if ! command -v systemctl &> /dev/null; then + log_error "systemd ist nicht installiert. Bitte installieren Sie Ubuntu 22.04 LTS." + exit 1 +fi + +log_success "systemd verfügbar" + +# Installiere zusätzliche Tools für Monitoring +log_info "Installiere Monitoring-Tools..." +apt install -y \ + htop \ + iotop \ + net-tools \ + lsof + +# Konfiguriere Firewall (falls ufw installiert ist) +if command -v ufw &> /dev/null; then + log_info "Konfiguriere Firewall..." + ufw allow 4551/tcp comment "YourPart Daemon WebSocket" + ufw allow 22/tcp comment "SSH" + log_success "Firewall konfiguriert" +fi + +# Erstelle Log-Verzeichnis +log_info "Erstelle Log-Verzeichnisse..." +mkdir -p /var/log/yourpart +chmod 755 /var/log/yourpart + +# Teste Compiler-Konfiguration +log_info "Teste Compiler-Konfiguration..." +cat > /tmp/test_compile.cpp << 'EOF' +#include +#include +#include +#include + +int main() { + std::cout << "C++20 Test erfolgreich!" << std::endl; + + // Test C++20 Features + auto lambda = [](auto x) { return x * 2; }; + std::vector> vec; + + return 0; +} +EOF + +if g++ -std=c++20 -o /tmp/test_compile /tmp/test_compile.cpp; then + log_success "C++20 Compilation erfolgreich" + rm -f /tmp/test_compile /tmp/test_compile.cpp +else + log_warning "C++20 Compilation fehlgeschlagen, verwende C++17" + rm -f /tmp/test_compile /tmp/test_compile.cpp +fi + +log_success "Alle Dependencies erfolgreich installiert!" +log_info "" +log_info "Nächste Schritte:" +log_info "1. Führen Sie das deploy.sh Script von Ihrem Entwicklungsrechner aus" +log_info "2. Oder kopieren Sie die Binärdatei manuell und konfigurieren Sie den Service" +log_info "" +log_info "Verfügbare Services:" +log_info "- PostgreSQL: systemctl status postgresql" +log_info "- Firewall: ufw status" +log_info "" +log_info "Datenbankverbindung:" +log_info "- Host: localhost" +log_info "- Port: 5432" +log_info "- Database: yp3" +log_info "- User: yourpart" +log_info "- Password: hitomisan" +log_info "" +log_info "Compiler-Info:" +log_info "- GCC Version: $(gcc --version | head -1)" +log_info "- G++ Version: $(g++ --version | head -1)" diff --git a/install-dependencies.sh b/install-dependencies.sh index a5f18d6..174aa94 100755 --- a/install-dependencies.sh +++ b/install-dependencies.sh @@ -44,16 +44,14 @@ apt install -y \ curl \ wget -# Installiere C++ Compiler (Ubuntu 22 hat GCC 11, aber wir brauchen GCC 15) -log_info "Installiere GCC 15..." -apt install -y software-properties-common -add-apt-repository -y ppa:ubuntu-toolchain-r/test -apt update -apt install -y gcc-15 g++-15 +# Installiere C++ Compiler (Ubuntu 22 hat GCC 11, das reicht aus) +log_info "Installiere GCC 11 (Standard für Ubuntu 22)..." +apt install -y gcc g++ -# Setze GCC 15 als Standard -update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-15 100 -update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-15 100 +# Prüfe verfügbare GCC Versionen +log_info "Verfügbare GCC Versionen:" +gcc --version | head -1 +g++ --version | head -1 # Installiere PostgreSQL Development Libraries log_info "Installiere PostgreSQL Development Libraries..." diff --git a/install-gcc15-ubuntu22.sh b/install-gcc15-ubuntu22.sh new file mode 100644 index 0000000..a4dc4b9 --- /dev/null +++ b/install-gcc15-ubuntu22.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# GCC 15 Installation für Ubuntu 22.04 +# Verwendet verschiedene Quellen um GCC 15 zu bekommen + +set -euo pipefail + +# Farben +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +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"; } + +log_info "Installiere GCC 15 für Ubuntu 22.04..." + +# Option 1: Ubuntu Toolchain PPA (manchmal verfügbar) +log_info "Versuche Ubuntu Toolchain PPA..." +apt update +apt install -y software-properties-common + +# Füge verschiedene PPAs hinzu +add-apt-repository -y ppa:ubuntu-toolchain-r/test 2>/dev/null || log_warning "PPA bereits hinzugefügt oder nicht verfügbar" +add-apt-repository -y ppa:ubuntu-toolchain-r/ppa 2>/dev/null || log_warning "PPA bereits hinzugefügt oder nicht verfügbar" + +apt update + +# Versuche GCC 15 zu installieren +if apt install -y gcc-15 g++-15 2>/dev/null; then + log_success "GCC 15 erfolgreich über PPA installiert" + GCC15_AVAILABLE=true +else + log_warning "GCC 15 nicht über PPA verfügbar" + GCC15_AVAILABLE=false +fi + +# Option 2: Snap (falls PPA nicht funktioniert) +if [ "$GCC15_AVAILABLE" = false ]; then + log_info "Versuche GCC 15 über Snap..." + if command -v snap &> /dev/null; then + if snap install gcc --classic 2>/dev/null; then + log_success "GCC über Snap installiert" + # Prüfe Version + SNAP_GCC_VERSION=$(snap run gcc --version | head -1) + log_info "Snap GCC Version: $SNAP_GCC_VERSION" + else + log_warning "GCC über Snap nicht verfügbar" + fi + else + log_info "Snap nicht installiert, installiere es..." + apt install -y snapd + if snap install gcc --classic 2>/dev/null; then + log_success "GCC über Snap installiert" + else + log_warning "GCC über Snap nicht verfügbar" + fi + fi +fi + +# Option 3: Compile from Source (letzte Option) +if [ "$GCC15_AVAILABLE" = false ]; then + log_info "GCC 15 nicht verfügbar. Verwende GCC 11 (Standard für Ubuntu 22.04)" + apt install -y gcc g++ + + log_info "Verfügbare Compiler:" + gcc --version | head -1 + g++ --version | head -1 + + log_warning "Der Code verwendet nur C++17 Features, daher ist GCC 11 ausreichend" + log_info "Falls Sie trotzdem GCC 15 brauchen, können Sie es aus dem Quellcode kompilieren" +fi + +# Setze GCC 15 als Standard (falls verfügbar) +if [ "$GCC15_AVAILABLE" = true ]; then + log_info "Setze GCC 15 als Standard..." + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-15 100 + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-15 100 + + log_success "GCC 15 ist jetzt der Standard-Compiler" + gcc --version | head -1 + g++ --version | head -1 +fi + +log_success "Compiler-Installation abgeschlossen!"