Add update-ypchat.sh script for deployment and service management

- Introduced a new script, update-ypchat.sh, to streamline the deployment and update process for the ypchat service.
- Replaced the previous update.sh script, consolidating commands for fetching updates, deploying, and managing the service.
- Added support for initial setup and service installation if not already present.
- Ensured proper execution of application dependencies and service restart with appropriate user permissions.
This commit is contained in:
Torsten Schulz (local)
2026-03-19 14:12:44 +01:00
parent e3928e0b65
commit 1e092a7232
2 changed files with 86 additions and 7 deletions

44
update-ypchat.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
# Single entry point for deployment/update.
# Default: regular update
# --init : first-time setup (service installation)
set -euo pipefail
MODE="${1:-update}"
REPO_DIR="/home/torsten/singlechat"
TARGET_DIR="/opt/ypchat"
SERVICE_NAME="ypchat"
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
APP_USER="www-data"
echo "=========================================="
echo "SingleChat Update"
echo "Mode: ${MODE}"
echo "=========================================="
cd "$REPO_DIR"
git fetch --all --prune
git pull
echo "Deploy nach ${TARGET_DIR}..."
sudo "$REPO_DIR/deploy-to-opt.sh"
if [[ "$MODE" == "--init" || "$MODE" == "init" ]]; then
echo "Initiales Setup: Service wird installiert..."
sudo "$REPO_DIR/install-service-ypchat.sh"
elif [[ ! -f "$SERVICE_FILE" ]]; then
echo "Service-Datei nicht gefunden, installiere Service einmalig..."
sudo "$REPO_DIR/install-service-ypchat.sh"
fi
echo "Installiere/aktualisiere App-Abhängigkeiten und baue Client..."
sudo -u "$APP_USER" bash -c "cd '$TARGET_DIR' && ./install.sh"
echo "Starte Service neu..."
sudo systemctl restart "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager -l
echo ""
echo "✓ Update erfolgreich abgeschlossen."

View File

@@ -1,9 +1,44 @@
#!/bin/bash
git fetch
# Single entry point for deployment/update.
# Default: regular update
# --init : first-time setup (service installation)
set -euo pipefail
MODE="${1:-update}"
REPO_DIR="/home/torsten/singlechat"
TARGET_DIR="/opt/ypchat"
SERVICE_NAME="ypchat"
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
APP_USER="www-data"
echo "=========================================="
echo "SingleChat Update"
echo "Mode: ${MODE}"
echo "=========================================="
cd "$REPO_DIR"
git fetch --all --prune
git pull
sudo ./deploy-to-opt.sh
sudo ./install-service-ypchat.sh
sudo ./install.sh
sudo ./quick-update.sh
sudo ./fix-dependencies.sh
sudo systemctl restart ypchat
echo "Deploy nach ${TARGET_DIR}..."
sudo "$REPO_DIR/deploy-to-opt.sh"
if [[ "$MODE" == "--init" || "$MODE" == "init" ]]; then
echo "Initiales Setup: Service wird installiert..."
sudo "$REPO_DIR/install-service-ypchat.sh"
elif [[ ! -f "$SERVICE_FILE" ]]; then
echo "Service-Datei nicht gefunden, installiere Service einmalig..."
sudo "$REPO_DIR/install-service-ypchat.sh"
fi
echo "Installiere/aktualisiere App-Abhängigkeiten und baue Client..."
sudo -u "$APP_USER" bash -c "cd '$TARGET_DIR' && ./install.sh"
echo "Starte Service neu..."
sudo systemctl restart "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager -l
echo ""
echo "✓ Update erfolgreich abgeschlossen."