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" \ |
Carmelo Cascone | d79e4a9 | 2019-12-16 20:23:03 -0800 | [diff] [blame] | 23 | ! -name "*.bin" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 24 | ! -name "*.cert" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 25 | ! -name "*.cfg" \ |
| 26 | ! -name "*.cnf" \ |
| 27 | ! -name "*.conf" \ |
| 28 | ! -name "*.cql" \ |
| 29 | ! -name "*.crt" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 30 | ! -name "*.csar" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 31 | ! -name "*.csr" \ |
| 32 | ! -name "*.csv" \ |
| 33 | ! -name "*.ctmpl" \ |
| 34 | ! -name "*.curl" \ |
| 35 | ! -name "*.db" \ |
| 36 | ! -name "*.der" \ |
Zack Williams | 36ed1cc | 2018-06-04 16:28:02 -0700 | [diff] [blame] | 37 | ! -name "*.desc" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 38 | ! -name "*.diff" \ |
| 39 | ! -name "*.dnsmasq" \ |
| 40 | ! -name "*.do" \ |
| 41 | ! -name "*.docx" \ |
| 42 | ! -name "*.eot" \ |
| 43 | ! -name "*.gif" \ |
| 44 | ! -name "*.gpg" \ |
| 45 | ! -name "*.graffle" \ |
Zack Williams | ba2aea0 | 2018-12-17 22:37:45 -0700 | [diff] [blame] | 46 | ! -name "*.ico" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 47 | ! -name "*.iml" \ |
| 48 | ! -name "*.in" \ |
| 49 | ! -name "*.inc" \ |
Zack Williams | 4ceded1 | 2018-10-18 21:17:28 -0700 | [diff] [blame] | 50 | ! -name "*.install" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 51 | ! -name "*.j2" \ |
| 52 | ! -name "*.jar" \ |
| 53 | ! -name "*.jks" \ |
| 54 | ! -name "*.jpg" \ |
| 55 | ! -name "*.json" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 56 | ! -name "*.jsonld" \ |
| 57 | ! -name "*.JSON" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 58 | ! -name "*.key" \ |
| 59 | ! -name "*.list" \ |
| 60 | ! -name "*.local" \ |
Zack Williams | ba2aea0 | 2018-12-17 22:37:45 -0700 | [diff] [blame] | 61 | ! -path "*.lock" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 62 | ! -name "*.log" \ |
| 63 | ! -name "*.mak" \ |
| 64 | ! -name "*.md" \ |
Zack Williams | 36192e3 | 2018-10-29 15:52:26 -0700 | [diff] [blame] | 65 | ! -name "*.MF" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 66 | ! -name "*.mk" \ |
| 67 | ! -name "*.oar" \ |
| 68 | ! -name "*.p12" \ |
| 69 | ! -name "*.patch" \ |
Zack Williams | 637f40c | 2019-03-12 13:02:37 -0700 | [diff] [blame] | 70 | ! -name "*.pb.go" \ |
Matteo Scandolo | 48d16fe | 2019-11-26 13:58:49 -0700 | [diff] [blame] | 71 | ! -name "*.pb.gw.go" \ |
Zack Williams | fdd3ab3 | 2018-07-07 10:35:35 -0700 | [diff] [blame] | 72 | ! -name "*.pdf" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 73 | ! -name "*.pcap" \ |
| 74 | ! -name "*.pem" \ |
| 75 | ! -name "*.png" \ |
| 76 | ! -name "*.properties" \ |
| 77 | ! -name "*.proto" \ |
Scott Baker | 38843b1 | 2019-05-24 09:38:23 -0700 | [diff] [blame] | 78 | ! -name "*.protoset" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 79 | ! -name "*.pyc" \ |
| 80 | ! -name "*.repo" \ |
| 81 | ! -name "*.robot" \ |
| 82 | ! -name "*.rst" \ |
| 83 | ! -name "*.rules" \ |
| 84 | ! -name "*.service" \ |
| 85 | ! -name "*.svg" \ |
| 86 | ! -name "*.swp" \ |
| 87 | ! -name "*.tar" \ |
| 88 | ! -name "*.tar.gz" \ |
| 89 | ! -name "*.toml" \ |
| 90 | ! -name "*.ttf" \ |
| 91 | ! -name "*.txt" \ |
| 92 | ! -name "*.woff" \ |
| 93 | ! -name "*.xproto" \ |
| 94 | ! -name "*.xtarget" \ |
| 95 | ! -name "*ignore" \ |
| 96 | ! -name "*rc" \ |
Zack Williams | 8873888 | 2019-02-07 09:04:37 -0700 | [diff] [blame] | 97 | ! -name "*_pb2.py" \ |
| 98 | ! -name "*_pb2_grpc.py" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 99 | ! -name "Dockerfile" \ |
| 100 | ! -name "Dockerfile.*" \ |
Zack Williams | d0f1ea3 | 2019-08-01 11:22:55 -0700 | [diff] [blame] | 101 | ! -name "go.mod" \ |
| 102 | ! -name "go.sum" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 103 | ! -name "Makefile" \ |
| 104 | ! -name "Makefile.*" \ |
| 105 | ! -name "README" \ |
Zack Williams | 7f03ff7 | 2019-01-14 14:10:35 -0700 | [diff] [blame] | 106 | ! -path "*/vendor/*" \ |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 107 | ! -path "*conf*" \ |
| 108 | ! -path "*git*" \ |
| 109 | ! -path "*swagger*" \ |
Andrea Campanella | e46579e | 2020-06-26 15:09:40 +0200 | [diff] [blame] | 110 | ! -path "*.drawio" \ |
Andrea Campanella | 5dc7968 | 2021-04-12 16:46:33 +0200 | [diff] [blame] | 111 | ! -name "*.pb.h" \ |
| 112 | ! -name "*.pb.cc" \ |
Zack Williams | 32293ee | 2018-05-18 09:15:13 -0700 | [diff] [blame] | 113 | -print0 ) |
| 114 | |
| 115 | exit ${fail_licensecheck} |