Files
metin2-client/tools/server/biolog/deploy_ava2.sh
T

30 lines
1.5 KiB
Bash

#!/bin/sh
# Switch the running 203 runtime to AVA2 bio.* and reload the added item templates.
set -eu
SERVER=${SERVER:-/usr/metin2/server}
OUT=${1:?usage: deploy_ava2.sh BUILD_DIR}
PYTHON=${PYTHON:-/usr/local/bin/python3.9}
HERE=$(cd "$(dirname "$0")" && pwd)
BACKUP=/root/backup-biolog-ava2/$(date +%Y%m%d-%H%M%S)
PIDS=/usr/metin2/.mt40250-pids
[ -x "$OUT/game" ] && [ -s "$OUT/items/items-server.tsv" ] && [ -s "$OUT/quest-stage/object/state/port_bio_reset" ]
mkdir -p "$BACKUP"
cp -p "$SERVER/share/bin/game" "$BACKUP/game"
cp -p "$PIDS" "$BACKUP/pids"
# Wait for graceful game saves before stopping their database process.
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 processes did not exit; backup $BACKUP" >&2;exit 1;fi
sh "$HERE/../stop_server.sh"
attempt=0
while ps ax -o command | grep -q '^[.]/\(db\|auth\)' && [ "$attempt" -lt 30 ]; do sleep 1;attempt=$((attempt+1));done
if ps ax -o command | grep -q '^[.]/\(db\|auth\)'; then echo "db/auth did not exit" >&2;exit 1;fi
"$PYTHON" "$HERE/install_ava2_data.py" "$SERVER" "$OUT/items" "$OUT/quest-stage" "$BACKUP/data"
cp -p "$OUT/game" "$SERVER/share/bin/game.biolog-new"
mv "$SERVER/share/bin/game.biolog-new" "$SERVER/share/bin/game"
sh "$HERE/../start_server.sh"
echo "AVA2 biolog installed; backup: $BACKUP"