feat: add collectors and rules
This commit is contained in:
27
20-collectors/collect_constitution_hash.sh
Executable file
27
20-collectors/collect_constitution_hash.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
OUT_DIR="${1:?usage: collect_constitution_hash.sh <out_dir>}"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
LOCK_PATH="../vm-mcp/governance/constitution.lock"
|
||||
|
||||
hash_file() {
|
||||
local file="$1"
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
sha256sum "$file" | awk '{print $1}'
|
||||
else
|
||||
shasum -a 256 "$file" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -f "$LOCK_PATH" ]]; then
|
||||
HASH="$(hash_file "$LOCK_PATH")"
|
||||
cat > "$OUT_DIR/constitution_hash.json" <<JSON
|
||||
{"collected": true, "path": "$LOCK_PATH", "sha256": "$HASH"}
|
||||
JSON
|
||||
else
|
||||
cat > "$OUT_DIR/constitution_hash.json" <<'JSON'
|
||||
{"collected": false, "reason": "constitution.lock not found at expected path"}
|
||||
JSON
|
||||
fi
|
||||
Reference in New Issue
Block a user