60 lines
1.6 KiB
Bash
Executable File
60 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Farben für Ausgaben
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${GREEN}==== MindMap Projekt Server Deployment ====${NC}"
|
|
|
|
# Python-Umgebung erstellen
|
|
echo -e "${BLUE}Erstelle Python-Umgebung...${NC}"
|
|
python3 -m venv venv
|
|
source venv/bin/activate
|
|
|
|
# Python-Abhängigkeiten installieren
|
|
echo -e "${BLUE}Installiere Python-Abhängigkeiten...${NC}"
|
|
pip install -r website/requirements.txt
|
|
pip install gunicorn
|
|
|
|
# Tailwind CSS kompilieren
|
|
echo -e "${BLUE}Kompiliere Tailwind CSS...${NC}"
|
|
cd website
|
|
python build_css.py
|
|
cd ..
|
|
|
|
# Datenbank initialisieren, falls noch nicht vorhanden
|
|
echo -e "${BLUE}Initialisiere die Datenbank, falls nötig...${NC}"
|
|
cd website
|
|
python init_db.py
|
|
cd ..
|
|
|
|
# Systemd Service erstellen
|
|
echo -e "${BLUE}Erstelle Systemd Service...${NC}"
|
|
SERVICE_FILE="[Unit]
|
|
Description=MindMap Wissensnetzwerk
|
|
After=network.target
|
|
|
|
[Service]
|
|
User=$(whoami)
|
|
WorkingDirectory=$(pwd)/website
|
|
Environment=\"PATH=$(pwd)/venv/bin\"
|
|
ExecStart=$(pwd)/venv/bin/gunicorn --workers 3 --bind 0.0.0.0:5000 --log-level info 'run:app'
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target"
|
|
|
|
echo "$SERVICE_FILE" > mindmap.service
|
|
|
|
echo -e "${GREEN}==== Deployment abgeschlossen ====${NC}"
|
|
echo -e "${BLUE}Um den Service zu installieren, führe folgende Befehle aus:${NC}"
|
|
echo -e "sudo cp mindmap.service /etc/systemd/system/"
|
|
echo -e "sudo systemctl daemon-reload"
|
|
echo -e "sudo systemctl enable mindmap.service"
|
|
echo -e "sudo systemctl start mindmap.service"
|
|
echo -e ""
|
|
echo -e "${BLUE}Alternativ kannst du den Server manuell starten:${NC}"
|
|
echo -e "cd website"
|
|
echo -e "../venv/bin/gunicorn --workers 3 --bind 0.0.0.0:5000 'run:app'" |