#!/bin/sh set -eu ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd) runtime_dir=${WNH_RUNTIME_ENV_DIR:-"$ROOT/output/runtime"} target=${WNH_ANDROID_TEST_ENV_FILE:-"$runtime_dir/android-test.env"} mkdir -p "$runtime_dir" chmod 700 "$runtime_dir" if [ -f "$target" ]; then chmod 600 "$target" echo "The generated Android test runtime environment already exists; no setting was changed." exit 0 fi port=$(od -An -N4 -tu4 /dev/urandom | awk '{print 30000 + ($1 % 20000)}') umask 077 { printf 'WNH_ANDROID_TEST_BASE_URL=http://127.0.0.1:%s\n' "$port" } > "$target" chmod 600 "$target" echo "Generated isolated Android test runtime state in output/runtime/android-test.env with mode 0600."