blob: e40802a4d1f36637f76f7c6c8dbd73e63e5670db [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" \
34 ! -name "*.diff" \
35 ! -name "*.dnsmasq" \
36 ! -name "*.do" \
37 ! -name "*.docx" \
38 ! -name "*.eot" \
39 ! -name "*.gif" \
40 ! -name "*.gpg" \
41 ! -name "*.graffle" \
42 ! -name "*.iml" \
43 ! -name "*.in" \
44 ! -name "*.inc" \
45 ! -name "*.j2" \
46 ! -name "*.jar" \
47 ! -name "*.jks" \
48 ! -name "*.jpg" \
49 ! -name "*.json" \
50 ! -name "*.key" \
51 ! -name "*.list" \
52 ! -name "*.local" \
53 ! -name "*.log" \
54 ! -name "*.mak" \
55 ! -name "*.md" \
56 ! -name "*.mk" \
57 ! -name "*.oar" \
58 ! -name "*.p12" \
59 ! -name "*.patch" \
60 ! -name "*.pcap" \
61 ! -name "*.pem" \
62 ! -name "*.png" \
63 ! -name "*.properties" \
64 ! -name "*.proto" \
65 ! -name "*.pyc" \
66 ! -name "*.repo" \
67 ! -name "*.robot" \
68 ! -name "*.rst" \
69 ! -name "*.rules" \
70 ! -name "*.service" \
71 ! -name "*.svg" \
72 ! -name "*.swp" \
73 ! -name "*.tar" \
74 ! -name "*.tar.gz" \
75 ! -name "*.toml" \
76 ! -name "*.ttf" \
77 ! -name "*.txt" \
78 ! -name "*.woff" \
79 ! -name "*.xproto" \
80 ! -name "*.xtarget" \
81 ! -name "*ignore" \
82 ! -name "*rc" \
83 ! -name "Dockerfile" \
84 ! -name "Dockerfile.*" \
85 ! -name "Makefile" \
86 ! -name "Makefile.*" \
87 ! -name "README" \
88 ! -path "*/vendor/*.go" \
89 ! -path "*conf*" \
90 ! -path "*git*" \
91 ! -path "*swagger*" \
Zack Williams32293ee2018-05-18 09:15:13 -070092 -print0 )
93
94exit ${fail_licensecheck}
Zack Williams7468c362018-04-06 09:52:30 -070095