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" \ |
Zack Williams | ba2aea0 | 2018-12-17 22:37:45 -0700 | [diff] [blame] | 45 | ! -name "*.ico" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 46 | ! -name "*.iml" \ |
| 47 | ! -name "*.in" \ |
| 48 | ! -name "*.inc" \ |
Zack Williams | 4ceded1 | 2018-10-18 21:17:28 -0700 | [diff] [blame] | 49 | ! -name "*.install" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 50 | ! -name "*.j2" \ |
| 51 | ! -name "*.jar" \ |
| 52 | ! -name "*.jks" \ |
| 53 | ! -name "*.jpg" \ |
| 54 | ! -name "*.json" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 55 | ! -name "*.jsonld" \ |
| 56 | ! -name "*.JSON" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 57 | ! -name "*.key" \ |
| 58 | ! -name "*.list" \ |
| 59 | ! -name "*.local" \ |
Zack Williams | ba2aea0 | 2018-12-17 22:37:45 -0700 | [diff] [blame] | 60 | ! -path "*.lock" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 61 | ! -name "*.log" \ |
| 62 | ! -name "*.mak" \ |
| 63 | ! -name "*.md" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 64 | ! -name "*.MF" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 65 | ! -name "*.mk" \ |
| 66 | ! -name "*.oar" \ |
| 67 | ! -name "*.p12" \ |
| 68 | ! -name "*.patch" \ |
Zack Williams | fdd3ab3 | 2018-07-07 10:35:35 -0700 | [diff] [blame] | 69 | ! -name "*.pdf" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 70 | ! -name "*.pcap" \ |
| 71 | ! -name "*.pem" \ |
| 72 | ! -name "*.png" \ |
| 73 | ! -name "*.properties" \ |
| 74 | ! -name "*.proto" \ |
| 75 | ! -name "*.pyc" \ |
| 76 | ! -name "*.repo" \ |
| 77 | ! -name "*.robot" \ |
| 78 | ! -name "*.rst" \ |
| 79 | ! -name "*.rules" \ |
| 80 | ! -name "*.service" \ |
| 81 | ! -name "*.svg" \ |
| 82 | ! -name "*.swp" \ |
| 83 | ! -name "*.tar" \ |
| 84 | ! -name "*.tar.gz" \ |
| 85 | ! -name "*.toml" \ |
| 86 | ! -name "*.ttf" \ |
| 87 | ! -name "*.txt" \ |
| 88 | ! -name "*.woff" \ |
| 89 | ! -name "*.xproto" \ |
| 90 | ! -name "*.xtarget" \ |
| 91 | ! -name "*ignore" \ |
| 92 | ! -name "*rc" \ |
| 93 | ! -name "Dockerfile" \ |
| 94 | ! -name "Dockerfile.*" \ |
| 95 | ! -name "Makefile" \ |
| 96 | ! -name "Makefile.*" \ |
| 97 | ! -name "README" \ |
| 98 | ! -path "*/vendor/*.go" \ |
| 99 | ! -path "*conf*" \ |
| 100 | ! -path "*git*" \ |
| 101 | ! -path "*swagger*" \ |
Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 102 | -print0 ) |
| 103 | |
| 104 | exit ${fail_licensecheck} |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 105 | |