blob: 160ee8bc251c57153b810ba619ed1944e74361aa [file] [log] [blame]
Zack Williams32293ee2018-05-18 09:15:13 -07001#!/usr/bin/env bash
Zack Williams7468c362018-04-06 09:52:30 -07002
3# licensecheck.sh
4# checks for copyright/license headers on files
5# excludes filename extensions where this check isn't pertinent
6
Zack Williams32293ee2018-05-18 09:15:13 -07007set +e -u -o pipefail
8fail_licensecheck=0
Zack Williams7468c362018-04-06 09:52:30 -07009
Zack Williams32293ee2018-05-18 09:15:13 -070010while IFS= read -r -d '' f
11do
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
18done < <(find . -name ".git" -prune -o -type f \
Zack Williams7468c362018-04-06 09:52:30 -070019 -name "*.*" \
20 ! -name "*.PNG" \
21 ! -name "*.asc" \
22 ! -name "*.bat" \
Carmelo Casconed79e4a92019-12-16 20:23:03 -080023 ! -name "*.bin" \
Zack Williams36192e32018-10-29 15:52:26 -070024 ! -name "*.cert" \
Zack Williams7468c362018-04-06 09:52:30 -070025 ! -name "*.cfg" \
26 ! -name "*.cnf" \
27 ! -name "*.conf" \
28 ! -name "*.cql" \
29 ! -name "*.crt" \
Zack Williams36192e32018-10-29 15:52:26 -070030 ! -name "*.csar" \
Zack Williams7468c362018-04-06 09:52:30 -070031 ! -name "*.csr" \
32 ! -name "*.csv" \
33 ! -name "*.ctmpl" \
34 ! -name "*.curl" \
35 ! -name "*.db" \
36 ! -name "*.der" \
Zack Williams36ed1cc2018-06-04 16:28:02 -070037 ! -name "*.desc" \
Zack Williams7468c362018-04-06 09:52:30 -070038 ! -name "*.diff" \
39 ! -name "*.dnsmasq" \
40 ! -name "*.do" \
41 ! -name "*.docx" \
42 ! -name "*.eot" \
43 ! -name "*.gif" \
44 ! -name "*.gpg" \
45 ! -name "*.graffle" \
Zack Williamsba2aea02018-12-17 22:37:45 -070046 ! -name "*.ico" \
Zack Williams7468c362018-04-06 09:52:30 -070047 ! -name "*.iml" \
48 ! -name "*.in" \
49 ! -name "*.inc" \
Zack Williams4ceded12018-10-18 21:17:28 -070050 ! -name "*.install" \
Zack Williams7468c362018-04-06 09:52:30 -070051 ! -name "*.j2" \
52 ! -name "*.jar" \
53 ! -name "*.jks" \
54 ! -name "*.jpg" \
55 ! -name "*.json" \
Zack Williams36192e32018-10-29 15:52:26 -070056 ! -name "*.jsonld" \
57 ! -name "*.JSON" \
Zack Williams7468c362018-04-06 09:52:30 -070058 ! -name "*.key" \
59 ! -name "*.list" \
60 ! -name "*.local" \
Zack Williamsba2aea02018-12-17 22:37:45 -070061 ! -path "*.lock" \
Zack Williams7468c362018-04-06 09:52:30 -070062 ! -name "*.log" \
63 ! -name "*.mak" \
64 ! -name "*.md" \
Zack Williams36192e32018-10-29 15:52:26 -070065 ! -name "*.MF" \
Zack Williams7468c362018-04-06 09:52:30 -070066 ! -name "*.mk" \
67 ! -name "*.oar" \
68 ! -name "*.p12" \
69 ! -name "*.patch" \
Zack Williams637f40c2019-03-12 13:02:37 -070070 ! -name "*.pb.go" \
Matteo Scandolo48d16fe2019-11-26 13:58:49 -070071 ! -name "*.pb.gw.go" \
Zack Williamsfdd3ab32018-07-07 10:35:35 -070072 ! -name "*.pdf" \
Zack Williams7468c362018-04-06 09:52:30 -070073 ! -name "*.pcap" \
74 ! -name "*.pem" \
75 ! -name "*.png" \
76 ! -name "*.properties" \
77 ! -name "*.proto" \
Scott Baker38843b12019-05-24 09:38:23 -070078 ! -name "*.protoset" \
Zack Williams7468c362018-04-06 09:52:30 -070079 ! -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 Williams88738882019-02-07 09:04:37 -070097 ! -name "*_pb2.py" \
98 ! -name "*_pb2_grpc.py" \
Zack Williams7468c362018-04-06 09:52:30 -070099 ! -name "Dockerfile" \
100 ! -name "Dockerfile.*" \
Zack Williamsd0f1ea32019-08-01 11:22:55 -0700101 ! -name "go.mod" \
102 ! -name "go.sum" \
Zack Williams7468c362018-04-06 09:52:30 -0700103 ! -name "Makefile" \
104 ! -name "Makefile.*" \
105 ! -name "README" \
Zack Williams7f03ff72019-01-14 14:10:35 -0700106 ! -path "*/vendor/*" \
Zack Williams7468c362018-04-06 09:52:30 -0700107 ! -path "*conf*" \
108 ! -path "*git*" \
109 ! -path "*swagger*" \
Andrea Campanellae46579e2020-06-26 15:09:40 +0200110 ! -path "*.drawio" \
Andrea Campanella5dc79682021-04-12 16:46:33 +0200111 ! -name "*.pb.h" \
112 ! -name "*.pb.cc" \
Zack Williams32293ee2018-05-18 09:15:13 -0700113 -print0 )
114
115exit ${fail_licensecheck}