blob: 2cf265592381c32f95094406473b6dcf351a6b0b [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" \
Zack Williams4ceded12018-10-18 21:17:28 -070046 ! -name "*.install" \
Zack Williams7468c362018-04-06 09:52:30 -070047 ! -name "*.j2" \
48 ! -name "*.jar" \
49 ! -name "*.jks" \
50 ! -name "*.jpg" \
51 ! -name "*.json" \
52 ! -name "*.key" \
53 ! -name "*.list" \
54 ! -name "*.local" \
55 ! -name "*.log" \
56 ! -name "*.mak" \
57 ! -name "*.md" \
58 ! -name "*.mk" \
59 ! -name "*.oar" \
60 ! -name "*.p12" \
61 ! -name "*.patch" \
Zack Williamsfdd3ab32018-07-07 10:35:35 -070062 ! -name "*.pdf" \
Zack Williams7468c362018-04-06 09:52:30 -070063 ! -name "*.pcap" \
64 ! -name "*.pem" \
65 ! -name "*.png" \
66 ! -name "*.properties" \
67 ! -name "*.proto" \
68 ! -name "*.pyc" \
69 ! -name "*.repo" \
70 ! -name "*.robot" \
71 ! -name "*.rst" \
72 ! -name "*.rules" \
73 ! -name "*.service" \
74 ! -name "*.svg" \
75 ! -name "*.swp" \
76 ! -name "*.tar" \
77 ! -name "*.tar.gz" \
78 ! -name "*.toml" \
79 ! -name "*.ttf" \
80 ! -name "*.txt" \
81 ! -name "*.woff" \
82 ! -name "*.xproto" \
83 ! -name "*.xtarget" \
84 ! -name "*ignore" \
85 ! -name "*rc" \
86 ! -name "Dockerfile" \
87 ! -name "Dockerfile.*" \
88 ! -name "Makefile" \
89 ! -name "Makefile.*" \
90 ! -name "README" \
91 ! -path "*/vendor/*.go" \
92 ! -path "*conf*" \
93 ! -path "*git*" \
94 ! -path "*swagger*" \
Zack Williams32293ee2018-05-18 09:15:13 -070095 -print0 )
96
97exit ${fail_licensecheck}
Zack Williams7468c362018-04-06 09:52:30 -070098