-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlicense
More file actions
executable file
·180 lines (154 loc) · 6.39 KB
/
license
File metadata and controls
executable file
·180 lines (154 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/sh
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2022 Jeremy Brubaker <jbru362@gmail.com>
#
# abstract: print various open source licenses
#
# Documentation {{{1
#
VERSION='1.0'
print_help() (
[ -n "$1" ] && printf "%s\n" "$1"
cat <<END
Usage: $0 [OPTION] <license>
Print various open source licenses
-n NAME name to use in the MIT license
-e EMAIL email address to use in the MIT license
-h display this help and exit
-v output version information and exit
The license will be downloaded from the internet. Supported values for <license>
are:
gpl|gpl3 GNU General Public License Version 3
gpl2 GNU General Public License Version 2
lgpl Lesser GNU Public License Version 2.1
fdl Free Documentation License Version 1.2
mit MIT License
mitna MIT No Attribution License
moz|mozill Mozilla License Version 2.0
apache Apache License Version 2.0
bsd|bsd2|3bsd 3-clause BSD License
freebsd|2bsd Free BSD License (2-clause BSD license)
0bsd BSD Zero Clause License
END
) >&2
print_version() (
cat <<END
$0 $VERSION
Copyright (C) 2022 Orion Arts
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jeremy Brubaker.
END
) >&2
# Process options {{{1
#
while getopts ':n:e:hv' c; do
case $c in
n) name="$OPTARG" ;;
e) email="$OPTARG" ;;
h) print_help; exit 0 ;;
v) print_version; exit 0 ;;
?) print_help "Invalid option: -$OPTARG"; exit 1 ;;
esac
done
shift $((OPTIND-1))
OPTIND=1
license=${1:-gpl}
# name = passed in, /etc/passwd comment field, $USER
name=${name:-$(getent passwd "$USER" | cut -d: -f5)}
name=${name:-"$USER"}
# email = passwed in, $USER@hostname
email=${email:-$USER@$(hostname)}
# Main {{{1
#
unknown_license() {
printf "Unknown license\n" >&2
exit 1
}
case "$license" in
gpl2) curl -q "https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" 2>/dev/null ;;
gpl3|gpl) curl -q "https://www.gnu.org/licenses/gpl-3.0.txt" 2>/dev/null ;;
lgpl*) curl -q "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt" 2>/dev/null ;;
fdl*) curl -q "https://www.gnu.org/licenses/old-licenses/fdl-1.2.txt" 2>/dev/null ;;
moz|mozilla) curl -q "https://www.mozilla.org/media/MPL/2.0/index.48a3fe23ed13.txt" 2>/dev/null ;;
apache) curl -q "https://www.apache.org/licenses/LICENSE-2.0.txt" 2>/dev/null ;;
mit)
curl -q https://mit-license.org/license.txt 2>/dev/null |
sed "1,2d
s/^Copyright.*/Copyright (c) $(date +%Y) $name <$email> /
\$s/\(.*\)/\1\n/"
;;
mitna)
curl -q https://raw.githubusercontent.com/aws/mit-0/master/MIT-0 2>/dev/null |
sed "1,2d
s/<year>/$(date +%Y)/
s/<copyright holders>/$name <$email>/"
;;
bsd|bsd2|3bsd)
cat <<EOF
Copyright (c) $(date +%Y) $name <$email>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EOF
;;
freebsd|2bsd)
cat <<EOF
Copyright (c) $(date +%Y) $name <$email>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
EOF
;;
0bsd)
cat <<EOF
Copyright (C) $(date +%Y) by $name <$email>
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
EOF
;;
*) unknown_license ;;
esac