1#!/bin/sh
2set -eu
3
4handoff=${1:?Expected a legacy handoff directory}
5target=${2:?Expected a production target}
6port=${3:?Expected a target SSH port}
7printf '%s\n' "$handoff" | grep -Eq '^/mnt/storage1/apps/studio-handoff/[0-9]{8}T[0-9]{6}Z-[0-9a-f]{6}$' || {
8 echo 'Invalid legacy handoff directory' >&2
9 exit 1
10}
11ssh -p "$port" "$target" "
12 set -eu
13 test -f '$handoff/manifest.json'
14 pool=\$(findmnt -n -o SOURCE --mountpoint /srv)
15 test \"\$(findmnt -n -o FSTYPE --mountpoint /srv)\" = zfs
16 zpool list \"\$pool\" >/dev/null
17 apps=\$(findmnt -n -o SOURCE --mountpoint /mnt/storage1/apps)
18 test \"\$apps\" = \"\$pool/apps\"
19 test \"\$(findmnt -n -o FSTYPE --mountpoint /mnt/storage1/apps)\" = zfs
20 test \"\$(zfs get -H -o value encryption \"\$apps\")\" = aes-256-gcm
21" || {
22 echo 'Legacy handoff or encrypted apps dataset is unavailable' >&2
23 exit 1
24}