blob: 5bbcdf889be30b5796f24302b791132ac8922fd8 [file] [log] [blame]
Zack Williams3403ff42019-08-13 18:30:42 -07001#!/usr/bin/env bash
2
3# licensecheck.sh
4# checks for copyright/license headers on files
5# excludes filename extensions where this check isn't pertinent
6
7set +e -u -o pipefail
8fail_licensecheck=0
9
10while 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 \
19 -name "*.*" \
20 ! -name "*.PNG" \
21 ! -name "*.asc" \
22 ! -name "*.bat" \
23 ! -name "*.cert" \
24 ! -name "*.cfg" \
25 ! -name "*.cnf" \
26 ! -name "*.conf" \
27 ! -name "*.cql" \
28 ! -name "*.crt" \
29 ! -name "*.csar" \
30 ! -name "*.csr" \
31 ! -name "*.csv" \
32 ! -name "*.ctmpl" \
33 ! -name "*.curl" \
34 ! -name "*.db" \
35 ! -name "*.der" \
36 ! -name "*.desc" \
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 "*.ico" \
46 ! -name "*.iml" \
47 ! -name "*.in" \
48 ! -name "*.inc" \
49 ! -name "*.install" \
50 ! -name "*.j2" \
51 ! -name "*.jar" \
52 ! -name "*.jks" \
53 ! -name "*.jpg" \
54 ! -name "*.json" \
55 ! -name "*.jsonld" \
56 ! -name "*.JSON" \
57 ! -name "*.key" \
58 ! -name "*.list" \
59 ! -name "*.local" \
60 ! -path "*.lock" \
61 ! -name "*.log" \
62 ! -name "*.mak" \
63 ! -name "*.md" \
64 ! -name "*.MF" \
65 ! -name "*.mk" \
66 ! -name "*.oar" \
67 ! -name "*.p12" \
68 ! -name "*.patch" \
69 ! -name "*.pb.go" \
70 ! -name "*.pdf" \
71 ! -name "*.pcap" \
72 ! -name "*.pem" \
73 ! -name "*.png" \
74 ! -name "*.properties" \
75 ! -name "*.proto" \
76 ! -name "*.protoset" \
77 ! -name "*.pyc" \
78 ! -name "*.repo" \
79 ! -name "*.robot" \
80 ! -name "*.rst" \
81 ! -name "*.rules" \
82 ! -name "*.service" \
83 ! -name "*.svg" \
84 ! -name "*.swp" \
85 ! -name "*.tar" \
86 ! -name "*.tar.gz" \
87 ! -name "*.toml" \
88 ! -name "*.ttf" \
89 ! -name "*.txt" \
90 ! -name "*.woff" \
91 ! -name "*.xproto" \
92 ! -name "*.xtarget" \
93 ! -name "*ignore" \
94 ! -name "*rc" \
95 ! -name "*_pb2.py" \
96 ! -name "*_pb2_grpc.py" \
97 ! -name "Dockerfile" \
98 ! -name "Dockerfile.*" \
99 ! -name "go.mod" \
100 ! -name "go.sum" \
101 ! -name "Makefile" \
102 ! -name "Makefile.*" \
103 ! -name "README" \
104 ! -path "*/vendor/*" \
105 ! -path "*conf*" \
106 ! -path "*git*" \
107 ! -path "*swagger*" \
108 -print0 )
109
110exit ${fail_licensecheck}