Files
yourpart3/install-dependencies.sh

158 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
# YourPart Daemon Dependencies Installation Script für Ubuntu 22
# Führen Sie dieses Script auf dem Server aus, bevor Sie das Deployment durchführen
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..."
# 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
# 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++
# 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..."
apt install -y \
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 postgresql-contrib
# 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 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 \
netstat-nat \
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
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"