#!/usr/bin/env bash # SPDX-License-Identifier: AGPL-3.0-only set -euo pipefail root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) test -s "$root/LICENSE" test -s "$root/COPYRIGHT" test -s "$root/examples/LICENSE" while IFS= read -r file; do case $file in *.sando.go) grep -Fq '// Code generated by himesan; DO NOT EDIT.' "$file" || { echo "generated provenance missing: $file" >&2; exit 1; } source=${file%.go} grep -Fq 'SPDX-License-Identifier: AGPL-3.0-only' "$source" || { echo "generated source licence missing: $source" >&2; exit 1; } ;; *) grep -Fq 'SPDX-License-Identifier: AGPL-3.0-only' "$file" || { echo "missing AGPL SPDX identifier: $file" >&2; exit 1; } ;; esac done < <(find "$root/cmd" "$root/internal" -type f \( -name '*.go' -o -name '*.sando' -o -name '*.css' -o -name '*.js' -o -name '*.svg' \) -print | LC_ALL=C sort) while IFS= read -r file; do grep -Fq 'SPDX-License-Identifier: AGPL-3.0-only' "$file" || { echo "missing AGPL SPDX identifier: $file" >&2; exit 1; } done < <(find "$root/docs" "$root/scripts" -type f \( -name '*.md' -o -name '*.sh' \) -print | LC_ALL=C sort) for file in Caddyfile.observatory observatory-agent.service observatory.env.example observatory.service; do grep -Fq 'SPDX-License-Identifier: AGPL-3.0-only' "$root/release/$file" || { echo "missing AGPL SPDX identifier: release/$file" >&2; exit 1; } done for file in agent.json server.json tend.json; do test "$(cat "$root/release/$file.license")" = 'SPDX-License-Identifier: AGPL-3.0-only' done for file in README.md SECURITY.md LICENSES.md .gitignore .gitattributes; do grep -Fq 'SPDX-License-Identifier: AGPL-3.0-only' "$root/$file" || { echo "missing AGPL SPDX identifier: $file" >&2; exit 1; } done for file in Caddyfile.sensitive-access-log README.md observatory-agent.service; do grep -Fq 'SPDX-License-Identifier: 0BSD' "$root/examples/$file" || { echo "missing 0BSD SPDX identifier: examples/$file" >&2; exit 1; } done for file in agent-credential.json agent-enrollment.json agent.json server.json; do test "$(cat "$root/examples/$file.license")" = 'SPDX-License-Identifier: 0BSD' done grep -Fq '"license": "AGPL-3.0-only"' "$root/test/browser/package.json" grep -Fq '"license": "AGPL-3.0-only"' "$root/test/browser/package-lock.json" echo "license boundaries verified"