Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 2 | |
| 3 | # licensecheck.sh |
| 4 | # checks for copyright/license headers on files |
| 5 | # excludes filename extensions where this check isn't pertinent |
| 6 | |
Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 7 | set +e -u -o pipefail |
| 8 | fail_licensecheck=0 |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 9 | |
Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 10 | while IFS= read -r -d '' f |
| 11 | do |
| 12 | grep -q "Copyright\|Apache License" "${f}" |
| 13 | rc=$? |
| 14 | if [[ $rc != 0 ]]; then |
| 15 | echo "ERROR: $f does not contain License Header" |
| 16 | fail_licensecheck=1 |
| 17 | fi |
| 18 | done < <(find . -name ".git" -prune -o -type f \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 19 | -name "*.*" \ |
| 20 | ! -name "*.PNG" \ |
| 21 | ! -name "*.asc" \ |
| 22 | ! -name "*.bat" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 23 | ! -name "*.cert" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 24 | ! -name "*.cfg" \ |
| 25 | ! -name "*.cnf" \ |
| 26 | ! -name "*.conf" \ |
| 27 | ! -name "*.cql" \ |
| 28 | ! -name "*.crt" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 29 | ! -name "*.csar" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 30 | ! -name "*.csr" \ |
| 31 | ! -name "*.csv" \ |
| 32 | ! -name "*.ctmpl" \ |
| 33 | ! -name "*.curl" \ |
| 34 | ! -name "*.db" \ |
| 35 | ! -name "*.der" \ |
Zack Williams | 36ed1cc | 2018-06-04 16:28:02 -0700 | [diff] [blame] | 36 | ! -name "*.desc" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 37 | ! -name "*.diff" \ |
| 38 | ! -name "*.dnsmasq" \ |
| 39 | ! -name "*.do" \ |
| 40 | ! -name "*.docx" \ |
| 41 | ! -name "*.eot" \ |
| 42 | ! -name "*.gif" \ |
| 43 | ! -name "*.gpg" \ |
| 44 | ! -name "*.graffle" \ |
| 45 | ! -name "*.iml" \ |
| 46 | ! -name "*.in" \ |
| 47 | ! -name "*.inc" \ |
Zack Williams | 4ceded1 | 2018-10-18 21:17:28 -0700 | [diff] [blame] | 48 | ! -name "*.install" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 49 | ! -name "*.j2" \ |
| 50 | ! -name "*.jar" \ |
| 51 | ! -name "*.jks" \ |
| 52 | ! -name "*.jpg" \ |
| 53 | ! -name "*.json" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 54 | ! -name "*.jsonld" \ |
| 55 | ! -name "*.JSON" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 56 | ! -name "*.key" \ |
| 57 | ! -name "*.list" \ |
| 58 | ! -name "*.local" \ |
| 59 | ! -name "*.log" \ |
| 60 | ! -name "*.mak" \ |
| 61 | ! -name "*.md" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 62 | ! -name "*.MF" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 63 | ! -name "*.mk" \ |
| 64 | ! -name "*.oar" \ |
| 65 | ! -name "*.p12" \ |
| 66 | ! -name "*.patch" \ |
Zack Williams | fdd3ab3 | 2018-07-07 10:35:35 -0700 | [diff] [blame] | 67 | ! -name "*.pdf" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 68 | ! -name "*.pcap" \ |
| 69 | ! -name "*.pem" \ |
| 70 | ! -name "*.png" \ |
| 71 | ! -name "*.properties" \ |
| 72 | ! -name "*.proto" \ |
| 73 | ! -name "*.pyc" \ |
| 74 | ! -name "*.repo" \ |
| 75 | ! -name "*.robot" \ |
| 76 | ! -name "*.rst" \ |
| 77 | ! -name "*.rules" \ |
| 78 | ! -name "*.service" \ |
| 79 | ! -name "*.svg" \ |
| 80 | ! -name "*.swp" \ |
| 81 | ! -name "*.tar" \ |
| 82 | ! -name "*.tar.gz" \ |
| 83 | ! -name "*.toml" \ |
| 84 | ! -name "*.ttf" \ |
| 85 | ! -name "*.txt" \ |
| 86 | ! -name "*.woff" \ |
| 87 | ! -name "*.xproto" \ |
| 88 | ! -name "*.xtarget" \ |
| 89 | ! -name "*ignore" \ |
| 90 | ! -name "*rc" \ |
| 91 | ! -name "Dockerfile" \ |
| 92 | ! -name "Dockerfile.*" \ |
| 93 | ! -name "Makefile" \ |
| 94 | ! -name "Makefile.*" \ |
| 95 | ! -name "README" \ |
| 96 | ! -path "*/vendor/*.go" \ |
| 97 | ! -path "*conf*" \ |
| 98 | ! -path "*git*" \ |
| 99 | ! -path "*swagger*" \ |
Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 100 | -print0 ) |
| 101 | |
| 102 | exit ${fail_licensecheck} |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 103 | |