Files
mtusi2026lab2/scripts/session_ttl.sh

30 lines
685 B
Bash
Executable File

#!/bin/sh
set -eu
project_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$project_root"
env_file=${ENV_FILE:-.env}
case "${SESSION_TTL_ACTION:-}" in
short)
ttl=${SHORT_SESSION_TTL_SECONDS:-2}
case "$ttl" in
''|*[!0-9]*|0)
echo "SHORT_SESSION_TTL_SECONDS must be a positive integer" >&2
exit 2
;;
esac
SESSION_TTL_SECONDS="$ttl" docker compose --env-file "$env_file" \
up -d --no-deps --force-recreate --wait api
;;
restore)
docker compose --env-file "$env_file" \
up -d --no-deps --force-recreate --wait api
;;
*)
echo "SESSION_TTL_ACTION must be short or restore" >&2
exit 2
;;
esac