SHA256
19 lines
901 B
Bash
Executable File
19 lines
901 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
host="${1:?remote host}"; dir="${2:?remote directory}"; expected="${3:?test or production}"
|
|
[[ "$expected" == test || "$expected" == production ]] || exit 2
|
|
# Read only: production opt-in must already be present in the remote private configuration.
|
|
ssh "$host" "python3 - '$dir/application.properties' '$expected'" <<'PYREMOTE'
|
|
from pathlib import Path
|
|
import sys, re
|
|
path, expected = Path(sys.argv[1]), sys.argv[2]
|
|
if not path.is_file(): raise SystemExit('Missing remote application.properties')
|
|
mode = None
|
|
for line in path.read_text().splitlines():
|
|
m = re.match(r'^\s*server\.testMode\s*[=:]\s*(.*?)\s*$', line)
|
|
if m: mode = m.group(1)
|
|
actual = 'production' if mode == 'false' else 'test'
|
|
if actual != expected: raise SystemExit(f'SHiNE deployment refused: expected {expected}, config is {actual}')
|
|
print(f'SHiNE mode preflight OK: {actual}')
|
|
PYREMOTE
|