feat: implement license platform business flows and delivery tooling
Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation. Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
22
scripts/backup-delivery.sh
Normal file
22
scripts/backup-delivery.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# Run during an upload/admin-write maintenance window. This script never reads or copies the signing key.
|
||||
: "${MYSQL_HOST:?set MYSQL_HOST}"
|
||||
: "${MYSQL_USER:?set MYSQL_USER}"
|
||||
: "${MYSQL_PASSWORD_FILE:?set protected MYSQL_PASSWORD_FILE}"
|
||||
: "${MYSQL_DATABASE:?set MYSQL_DATABASE}"
|
||||
: "${PACKAGE_STORAGE_ROOT:?set PACKAGE_STORAGE_ROOT to the private package directory}"
|
||||
: "${BACKUP_DIR:?set BACKUP_DIR to a protected destination}"
|
||||
case "$BACKUP_DIR" in /*) ;; *) echo 'BACKUP_DIR must be absolute' >&2; exit 1;; esac
|
||||
case "$PACKAGE_STORAGE_ROOT" in /*) ;; *) echo 'PACKAGE_STORAGE_ROOT must be absolute' >&2; exit 1;; esac
|
||||
mkdir -p "$BACKUP_DIR"; chmod 700 "$BACKUP_DIR"
|
||||
name=$(date -u +%Y%m%dT%H%M%SZ); work="$BACKUP_DIR/.delivery-$name"
|
||||
mkdir "$work"; trap 'unset MYSQL_PWD; rm -rf "$work"' EXIT HUP INT TERM
|
||||
export MYSQL_PWD=$(cat "$MYSQL_PASSWORD_FILE")
|
||||
mysqldump --host="$MYSQL_HOST" --port="${MYSQL_PORT:-3306}" --user="$MYSQL_USER" --single-transaction --no-tablespaces --routines --triggers "$MYSQL_DATABASE" > "$work/mysql.sql"
|
||||
unset MYSQL_PWD
|
||||
tar --sort=name --mtime='UTC 1970-01-01' --owner=0 --group=0 --numeric-owner -C "$PACKAGE_STORAGE_ROOT" -cf "$work/packages.tar" .
|
||||
(cd "$work" && sha256sum mysql.sql packages.tar > SHA256SUMS)
|
||||
printf '%s\n' 'Signing keys are intentionally excluded. Record migration version and quiescence window separately.' > "$work/METADATA.txt"
|
||||
mv "$work" "$BACKUP_DIR/delivery-$name"
|
||||
printf '%s\n' "$BACKUP_DIR/delivery-$name"
|
||||
Reference in New Issue
Block a user