#!/bin/sh # Game-only update when item templates/quest objects have not changed. set -eu NEW=${1:?usage: deploy_game.sh NEW_GAME} SERVER=${SERVER:-/usr/metin2/server} PIDS=/usr/metin2/.mt40250-pids BACKUP=/root/backup-biolog-ava2-game/$(date +%Y%m%d-%H%M%S) [ -x "$NEW" ] && [ -f "$PIDS" ] mkdir -p "$BACKUP" cp -p "$SERVER/share/bin/game" "$BACKUP/game" cp -p "$PIDS" "$BACKUP/pids" cp -p "$NEW" "$SERVER/share/bin/game.bio-next" awk '$2!="db" && $2!="auth" {print $1}' "$PIDS" | while read -r pid; do kill -TERM "$pid" 2>/dev/null || true; done attempt=0 while ps ax -o command | grep -q '^[.]/game' && [ "$attempt" -lt 180 ]; do sleep 1;attempt=$((attempt+1));done if ps ax -o command | grep -q '^[.]/game';then echo "game cores did not stop; backup $BACKUP" >&2;exit 1;fi mv "$SERVER/share/bin/game.bio-next" "$SERVER/share/bin/game" awk '$2=="db" || $2=="auth" {print}' "$BACKUP/pids" > "$PIDS" awk '$2!="db" && $2!="auth" {print $2}' "$BACKUP/pids" | while read -r name;do (cd "$SERVER/$name" && exec ./game) >> "$SERVER/$name/console.log" 2>&1 & echo "$! $name" >> "$PIDS" done echo "Game update installed; backup: $BACKUP"