add chapters and deploy script
This commit is contained in:
103
deploy.sh
Executable file
103
deploy.sh
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
|
||||
# MathQuest Deployment Script
|
||||
# Führe dieses Script auf dem Server aus
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 MathQuest Deployment Script"
|
||||
echo "================================"
|
||||
echo ""
|
||||
|
||||
# Farben für Output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Variablen
|
||||
APP_DIR="/var/www/mathquest"
|
||||
SERVICE_NAME="mathquest"
|
||||
NGINX_CONF="/etc/nginx/sites-available/mathquest.conf"
|
||||
NGINX_ENABLED="/etc/nginx/sites-enabled/mathquest.conf"
|
||||
|
||||
# Prüfe ob als root ausgeführt
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "${RED}❌ Bitte führe dieses Script als root aus (sudo ./deploy.sh)${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${YELLOW}📦 Schritt 1: Erstelle Verzeichnis...${NC}"
|
||||
mkdir -p $APP_DIR
|
||||
echo -e "${GREEN}✅ Verzeichnis erstellt${NC}"
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}📝 Schritt 2: Kopiere Dateien...${NC}"
|
||||
echo "Bitte kopiere die Dateien manuell nach $APP_DIR"
|
||||
echo "Oder verwende: scp -r * user@server:$APP_DIR/"
|
||||
echo ""
|
||||
read -p "Drücke Enter, wenn die Dateien kopiert wurden..."
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}📦 Schritt 3: Installiere Dependencies...${NC}"
|
||||
cd $APP_DIR
|
||||
if [ -f "package.json" ]; then
|
||||
npm install --production
|
||||
echo -e "${GREEN}✅ Dependencies installiert${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ package.json nicht gefunden!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}🔧 Schritt 4: Setze Berechtigungen...${NC}"
|
||||
chown -R www-data:www-data $APP_DIR
|
||||
chmod +x $APP_DIR/server.js
|
||||
echo -e "${GREEN}✅ Berechtigungen gesetzt${NC}"
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}⚙️ Schritt 5: Installiere systemd Service...${NC}"
|
||||
if [ -f "$APP_DIR/mathquest.service" ]; then
|
||||
cp $APP_DIR/mathquest.service /etc/systemd/system/$SERVICE_NAME.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable $SERVICE_NAME
|
||||
echo -e "${GREEN}✅ Service installiert und aktiviert${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ mathquest.service nicht gefunden!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}🌐 Schritt 6: Konfiguriere Nginx...${NC}"
|
||||
if [ -f "$APP_DIR/nginx-mathquest.conf" ]; then
|
||||
cp $APP_DIR/nginx-mathquest.conf $NGINX_CONF
|
||||
ln -sf $NGINX_CONF $NGINX_ENABLED
|
||||
nginx -t
|
||||
if [ $? -eq 0 ]; then
|
||||
systemctl reload nginx
|
||||
echo -e "${GREEN}✅ Nginx konfiguriert${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Nginx Konfiguration fehlerhaft!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}❌ nginx-mathquest.conf nicht gefunden!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}🚀 Schritt 7: Starte Service...${NC}"
|
||||
systemctl start $SERVICE_NAME
|
||||
sleep 2
|
||||
systemctl status $SERVICE_NAME --no-pager
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✅ Deployment abgeschlossen!${NC}"
|
||||
echo ""
|
||||
echo "Nützliche Befehle:"
|
||||
echo " Status prüfen: systemctl status $SERVICE_NAME"
|
||||
echo " Logs ansehen: journalctl -u $SERVICE_NAME -f"
|
||||
echo " Neustarten: systemctl restart $SERVICE_NAME"
|
||||
echo " Stoppen: systemctl stop $SERVICE_NAME"
|
||||
echo ""
|
||||
echo "Die App sollte jetzt unter https://mathquest.lydix.de erreichbar sein!"
|
||||
Reference in New Issue
Block a user