blob: c358294cec30cbafcb3ba6ab9c090e1c7b243dd1 [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" \
Zack Williams36192e32018-10-29 15:52:26 -070023 ! -name "*.cert" \
Zack Williams7468c362018-04-06 09:52:30 -070024 ! -name "*.cfg" \
25 ! -name "*.cnf" \
26 ! -name "*.conf" \
27 ! -name "*.cql" \
28 ! -name "*.crt" \
Zack Williams36192e32018-10-29 15:52:26 -070029 ! -name "*.csar" \
Zack Williams7468c362018-04-06 09:52:30 -070030 ! -name "*.csr" \
31 ! -name "*.csv" \
32 ! -name "*.ctmpl" \
33 ! -name "*.curl" \
34 ! -name "*.db" \
35 ! -name "*.der" \
Zack Williams36ed1cc2018-06-04 16:28:02 -070036 ! -name "*.desc" \
Zack Williams7468c362018-04-06 09:52:30 -070037 ! -name "*.diff" \
38 ! -name "*.dnsmasq" \
39 ! -name "*.do" \
40 ! -name "*.docx" \
41 ! -name "*.eot" \
42 ! -name "*.gif" \
43 ! -name "*.gpg" \
44 ! -name "*.graffle" \
Zack Williamsba2aea02018-12-17 22:37:45 -070045 ! -name "*.ico" \
Zack Williams7468c362018-04-06 09:52:30 -070046 ! -name "*.iml" \
47 ! -name "*.in" \
48 ! -name "*.inc" \
Zack Williams4ceded12018-10-18 21:17:28 -070049 ! -name "*.install" \
Zack Williams7468c362018-04-06 09:52:30 -070050 ! -name "*.j2" \
51 ! -name "*.jar" \
52 ! -name "*.jks" \
53 ! -name "*.jpg" \
54 ! -name "*.json" \
Zack Williams36192e32018-10-29 15:52:26 -070055 ! -name "*.jsonld" \
56 ! -name "*.JSON" \
Zack Williams7468c362018-04-06 09:52:30 -070057 ! -name "*.key" \
58 ! -name "*.list" \
59 ! -name "*.local" \
Zack Williamsba2aea02018-12-17 22:37:45 -070060 ! -path "*.lock" \
Zack Williams7468c362018-04-06 09:52:30 -070061 ! -name "*.log" \
62 ! -name "*.mak" \
63 ! -name "*.md" \
Zack Williams36192e32018-10-29 15:52:26 -070064 ! -name "*.MF" \
Zack Williams7468c362018-04-06 09:52:30 -070065 ! -name "*.mk" \
66 ! -name "*.oar" \
67 ! -name "*.p12" \
68 ! -name "*.patch" \
Zack Williams637f40c2019-03-12 13:02:37 -070069 ! -name "*.pb.go" \
Matteo Scandolo48d16fe2019-11-26 13:58:49 -070070 ! -name "*.pb.gw.go" \
Zack Williamsfdd3ab32018-07-07 10:35:35 -070071 ! -name "*.pdf" \
Zack Williams7468c362018-04-06 09:52:30 -070072 ! -name "*.pcap" \
73 ! -name "*.pem" \
74 ! -name "*.png" \
75 ! -name "*.properties" \
76 ! -name "*.proto" \
Scott Baker38843b12019-05-24 09:38:23 -070077 ! -name "*.protoset" \
Zack Williams7468c362018-04-06 09:52:30 -070078 ! -name "*.pyc" \
79 ! -name "*.repo" \
80 ! -name "*.robot" \
81 ! -name "*.rst" \
82 ! -name "*.rules" \
83 ! -name "*.service" \
84 ! -name "*.svg" \
85 ! -name "*.swp" \
86 ! -name "*.tar" \
87 ! -name "*.tar.gz" \
88 ! -name "*.toml" \
89 ! -name "*.ttf" \
90 ! -name "*.txt" \
91 ! -name "*.woff" \
92 ! -name "*.xproto" \
93 ! -name "*.xtarget" \
94 ! -name "*ignore" \
95 ! -name "*rc" \
Zack Williams88738882019-02-07 09:04:37 -070096 ! -name "*_pb2.py" \
97 ! -name "*_pb2_grpc.py" \
Zack Williams7468c362018-04-06 09:52:30 -070098 ! -name "Dockerfile" \
99 ! -name "Dockerfile.*" \
Zack Williamsd0f1ea32019-08-01 11:22:55 -0700100 ! -name "go.mod" \
101 ! -name "go.sum" \
Zack Williams7468c362018-04-06 09:52:30 -0700102 ! -name "Makefile" \
103 ! -name "Makefile.*" \
104 ! -name "README" \
Zack Williams7f03ff72019-01-14 14:10:35 -0700105 ! -path "*/vendor/*" \
Zack Williams7468c362018-04-06 09:52:30 -0700106 ! -path "*conf*" \
107 ! -path "*git*" \
108 ! -path "*swagger*" \
Zack Williams32293ee2018-05-18 09:15:13 -0700109 -print0 )
110
111exit ${fail_licensecheck}