petersweb-infra/bump-riverside.sh

36 lines
1 KiB
Bash
Raw Normal View History

2026-05-25 11:00:40 -08:00
#!/usr/bin/env bash
set -euo pipefail
COMPOSE=/root/petersweb-infra/nixos/arion-riverside/arion-compose.nix
usage() {
echo "Usage: $0 <sha256-digest>"
echo " e.g. $0 sha256:6cf107d892fbb7f615b4e616b330209704b9d7a2ed204e05c830c3a4d0bfa308"
exit 1
}
[[ $# -eq 1 ]] || usage
NEW_DIGEST="${1#sha256:}" # strip leading "sha256:" if provided
# Validate: hex string of the right length
if ! [[ "$NEW_DIGEST" =~ ^[0-9a-f]{64}$ ]]; then
echo "Error: digest must be a 64-character lowercase hex string (got: $NEW_DIGEST)" >&2
exit 1
fi
OLD_LINE=$(grep -n 'riverside@sha256:' "$COMPOSE")
echo "Current: $OLD_LINE"
sed -i -E "s|(riverside@sha256:)[0-9a-f]{64}|\1${NEW_DIGEST}|" "$COMPOSE"
NEW_LINE=$(grep -n 'riverside@sha256:' "$COMPOSE")
echo "Updated: $NEW_LINE"
2026-05-25 12:10:14 -08:00
echo "Clearing Drupal config table to trigger fresh install on next boot..."
docker exec riverside-postgres psql -U drupal -d drupal -c "DROP TABLE IF EXISTS config;"
echo "Restarting riverside container..."
docker restart riverside
echo "Done. Tail logs with: docker logs -f riverside"