chore(autoplay): 🔧 Update output path logic to use .local/ instead of /tmp in autoplay-batch.sh
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
a2e8f804b2
commit
1a5aa38103
1 changed files with 14 additions and 10 deletions
|
|
@ -25,7 +25,9 @@ GAME_DIR="$PROJECT_DIR/src/game"
|
|||
|
||||
COUNT="${1:-3}"
|
||||
TURN_LIMIT="${2:-500}"
|
||||
RESULTS_DIR="${3:-/tmp/autoplay_batch}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
RESULTS_DIR="${3:-$REPO_ROOT/.local/batches/autoplay_batch}"
|
||||
|
||||
if ! [[ "$COUNT" =~ ^[0-9]+$ ]] || [ "$COUNT" -lt 1 ]; then
|
||||
echo "ERROR: count must be a positive integer (got '$COUNT')" >&2
|
||||
|
|
@ -39,11 +41,12 @@ fi
|
|||
AUTOPLAY_HOST="${AUTOPLAY_HOST:-}"
|
||||
SAFETY_TIMEOUT=$(( TURN_LIMIT * 2 + 300 ))
|
||||
|
||||
# IMPORTANT: Flatpak sandboxes /tmp — result files written from inside the
|
||||
# sandbox to /tmp silently disappear. Use $HOME/tmp for local flatpak runs.
|
||||
if [ -z "$AUTOPLAY_HOST" ] && [[ "$RESULTS_DIR" == /tmp/* ]]; then
|
||||
RESULTS_DIR="$HOME/tmp/autoplay_batch"
|
||||
echo "INFO: Local flatpak run — redirecting results dir to $RESULTS_DIR (flatpak cannot write to /tmp)" >&2
|
||||
# Flatpak sandbox can't write to /tmp. Reject /tmp paths outright instead of
|
||||
# silently redirecting — persistent output belongs under the repo.
|
||||
if [[ "$RESULTS_DIR" == /tmp/* ]] || [[ "$RESULTS_DIR" == /private/tmp/* ]]; then
|
||||
echo "ERROR: results_dir under /tmp is forbidden (wiped on reboot, flatpak sandbox hostile)." >&2
|
||||
echo " Use a path under the repo (default: <repo>/.local/batches/) or \$HOME/tmp." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$RESULTS_DIR"
|
||||
|
|
@ -119,20 +122,21 @@ _run_remote() {
|
|||
if [ -z "${REMOTE_HOME:-}" ]; then
|
||||
REMOTE_HOME="$(ssh "$AUTOPLAY_HOST" 'echo "$HOME"')"
|
||||
fi
|
||||
local remote_game_dir="$REMOTE_HOME/tmp/autoplay_batch/game_${STAMP}_seed${seed}"
|
||||
local remote_game_dir="$REMOTE_HOME/Code/@projects/@magic-civilization/.local/batches/autoplay_batch/game_${STAMP}_seed${seed}"
|
||||
local remote_runner="$REMOTE_HOME/bin/run_ap3.sh"
|
||||
|
||||
ssh "$AUTOPLAY_HOST" "
|
||||
set -euo pipefail
|
||||
mkdir -p '$remote_game_dir'
|
||||
if [ ! -f /tmp/run_ap3.sh ]; then
|
||||
echo 'ERROR: /tmp/run_ap3.sh not found on $AUTOPLAY_HOST' >&2
|
||||
if [ ! -f '$remote_runner' ]; then
|
||||
echo 'ERROR: $remote_runner not found on $AUTOPLAY_HOST (expected persistent runner in \$HOME/bin)' >&2
|
||||
exit 1
|
||||
fi
|
||||
AUTO_PLAY=true \
|
||||
AUTO_PLAY_SEED='$seed' \
|
||||
AUTO_PLAY_TURN_LIMIT='$TURN_LIMIT' \
|
||||
AUTO_PLAY_DIR='$remote_game_dir' \
|
||||
bash /tmp/run_ap3.sh >'$remote_game_dir/game.log' 2>&1
|
||||
bash '$remote_runner' >'$remote_game_dir/game.log' 2>&1
|
||||
" || {
|
||||
echo "[seed $seed] SSH run exited with error — see $game_dir/game.log after scp" >&2
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue