blob: 3d64307c450011ad131272032f898817b08b0a95 [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" \
23 ! -name "*.cfg" \
24 ! -name "*.cnf" \
25 ! -name "*.conf" \
26 ! -name "*.cql" \
27 ! -name "*.crt" \
28 ! -name "*.csr" \
29 ! -name "*.csv" \
30 ! -name "*.ctmpl" \
31 ! -name "*.curl" \
32 ! -name "*.db" \
33 ! -name "*.der" \
Zack Williams36ed1cc2018-06-04 16:28:02 -070034 ! -name "*.desc" \
Zack Williams7468c362018-04-06 09:52:30 -070035 ! -name "*.diff" \
36 ! -name "*.dnsmasq" \
37 ! -name "*.do" \
38 ! -name "*.docx" \
39 ! -name "*.eot" \
40 ! -name "*.gif" \
41 ! -name "*.gpg" \
42 ! -name "*.graffle" \
43 ! -name "*.iml" \
44 ! -name "*.in" \
45 ! -name "*.inc" \
46 ! -name "*.j2" \
47 ! -name "*.jar" \
48 ! -name "*.jks" \
49 ! -name "*.jpg" \
50 ! -name "*.json" \
51 ! -name "*.key" \
52 ! -name "*.list" \
53 ! -name "*.local" \
54 ! -name "*.log" \
55 ! -name "*.mak" \
56 ! -name "*.md" \
57 ! -name "*.mk" \
58 ! -name "*.oar" \
59 ! -name "*.p12" \
60 ! -name "*.patch" \
Zack Williamsfdd3ab32018-07-07 10:35:35 -070061 ! -name "*.pdf" \
Zack Williams7468c362018-04-06 09:52:30 -070062 ! -name "*.pcap" \
63 ! -name "*.pem" \
64 ! -name "*.png" \
65 ! -name "*.properties" \
66 ! -name "*.proto" \
67 ! -name "*.pyc" \
68 ! -name "*.repo" \
69 ! -name "*.robot" \
70 ! -name "*.rst" \
71 ! -name "*.rules" \
72 ! -name "*.service" \
73 ! -name "*.svg" \
74 ! -name "*.swp" \
75 ! -name "*.tar" \
76 ! -name "*.tar.gz" \
77 ! -name "*.toml" \
78 ! -name "*.ttf" \
79 ! -name "*.txt" \
80 ! -name "*.woff" \
81 ! -name "*.xproto" \
82 ! -name "*.xtarget" \
83 ! -name "*ignore" \
84 ! -name "*rc" \
85 ! -name "Dockerfile" \
86 ! -name "Dockerfile.*" \
87 ! -name "Makefile" \
88 ! -name "Makefile.*" \
89 ! -name "README" \
90 ! -path "*/vendor/*.go" \
91 ! -path "*conf*" \
92 ! -path "*git*" \
93 ! -path "*swagger*" \
Zack Williams32293ee2018-05-18 09:15:13 -070094 -print0 )
95
96exit ${fail_licensecheck}
Zack Williams7468c362018-04-06 09:52:30 -070097