summaryrefslogtreecommitdiff
path: root/bin/meta-check
blob: eb4f8c7fe2060223ac18c225be7ebcaf20476d91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash

. libremessages

PATH="$(dirname "$0"):$PATH"

check-yaml() {
	file=$1
	msg 'Inspecting %q' "$file"
	norm=$(mktemp --tmpdir)
	trap "rm -f -- $(printf '%q' "$norm")" RETURN
	meta-normalize-stdio < "$file" > "$norm" || return $?
	colordiff -u "$file" "$norm" || return $?
}

main() {
	declare -i ret=0

	# Check the user YAML files
	for file in users/*.yml; do
		check-yaml "$file" || ret=$?
	done

	# Make sure there are no duplicate usernames
	dups=($(sed -n 's/^username: //p' -- users/*.yml| sort | uniq -d))
	if (( ${#dups[@]} )); then
	    error 'Duplicate usernames:'
	    plain '%s' "${dups[@]}"
	    ret=1
	fi

	# Check to make sure the pgp keys are OK
	if pgp-list-keyids | grep -Ev '^(trusted|secondary|revoked)/[a-z][a-z0-9]* [0-9A-F]{40}$'; then
	    error 'Bad pgp keys ^^^'
	    ret=1
	fi

	return $ret
}

main "$@"