Aktualisiere das Build-Skript, um C++ Standard auf Version 20 zu setzen. Ändere die Installation des C++ Compilers in install-dependencies.sh, um GCC 11 als Standard für Ubuntu 22 zu verwenden und entferne die Installation von GCC 15.
This commit is contained in:
committed by
Torsten (PC)
parent
77520ee46a
commit
4b9311713a
201
install-dependencies-ubuntu22.sh
Normal file
201
install-dependencies-ubuntu22.sh
Normal file
@@ -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 <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
int main() {
|
||||
std::cout << "C++20 Test erfolgreich!" << std::endl;
|
||||
|
||||
// Test C++20 Features
|
||||
auto lambda = [](auto x) { return x * 2; };
|
||||
std::vector<std::unique_ptr<int>> 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)"
|
||||
Reference in New Issue
Block a user