check-licenses

 1#!/usr/bin/env bash
 2
 3set -euo pipefail
 4
 5check_license () {
 6    for license in "LICENSE-AGPL" "LICENSE-GPL" "LICENSE-APACHE"; do
 7        if [[ -L "$1/$license" ]]; then
 8            return 0
 9        elif [[ -e "$1/$license" ]]; then
10            echo "Error: $1/$license exists but is not a symlink."
11            exit 1
12        fi
13    done
14    echo "Error: $1 does not contain a license symlink"
15    exit 1
16}
17
18git ls-files **/*/Cargo.toml | while read cargo_toml; do
19   check_license $(dirname "$cargo_toml");
20done