#!/usr/bin/env bash set -euo pipefail TARGET_DIR="/workspace/docs/studio-bundle" while [[ $# -gt 0 ]]; do case "$1" in --target) TARGET_DIR="$2" shift 2 ;; -h|--help) echo "Usage: $0 [--target /path/to/install]" exit 0 ;; *) echo "Unknown option: $1" >&2 exit 1 ;; esac done SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" echo "[1/4] Verifying SHA-256 checksums..." sha256sum -c SHA256SUMS echo "[2/4] Installing Studio artifacts into $TARGET_DIR..." mkdir -p "$TARGET_DIR/artifacts" "$TARGET_DIR/almanac" "$TARGET_DIR/cloudflare" "$TARGET_DIR/audio" cp -a artifacts/. "$TARGET_DIR/artifacts/" cp -a almanac/. "$TARGET_DIR/almanac/" cp -a cloudflare/. "$TARGET_DIR/cloudflare/" if [[ -d audio ]] && [[ -n "$(ls -A audio 2>/dev/null)" ]]; then cp -a audio/. "$TARGET_DIR/audio/" fi cp -a MANIFEST.json README.md GROK_BOT_INSTALL.md SHA256SUMS update_audio_manifest.py install.sh "$TARGET_DIR/" chmod +x "$TARGET_DIR/install.sh" "$TARGET_DIR/cloudflare/deploy_worker.sh" echo "[3/4] Running pompous_v1_2.py verification suite..." python3 "$TARGET_DIR/artifacts/pompous_v1_2.py" echo "[4/4] Writing Grok Bot installation receipt..." python3 -c " import hashlib, json, os from datetime import datetime, timezone target = os.path.abspath('$TARGET_DIR') receipt = { 'installed_at_utc': datetime.now(timezone.utc).isoformat(), 'target_dir': target, 'artifact_count': len(os.listdir(os.path.join(target, 'artifacts'))), 'pompous_v1_2_sha256': hashlib.sha256(open(os.path.join(target, 'artifacts', 'pompous_v1_2.py'), 'rb').read()).hexdigest(), 'almanac_html_sha256': hashlib.sha256(open(os.path.join(target, 'almanac', 'index.html'), 'rb').read()).hexdigest(), 'worker_sha256': hashlib.sha256(open(os.path.join(target, 'cloudflare', 'almanac_worker.py'), 'rb').read()).hexdigest(), 'status': 'INSTALLED_AND_VERIFIED', } out = os.path.join(target, 'INSTALL_RECEIPT.json') with open(out, 'w', encoding='utf-8') as f: json.dump(receipt, f, indent=2) print('Receipt written:', out) " echo "Grok Bot Studio bundle installed cleanly at: $TARGET_DIR"