Skip to content

Instantly share code, notes, and snippets.

@SISheogorath
Created October 11, 2017 11:32
Show Gist options
  • Save SISheogorath/593c54607dc2881b5a207f4584411fba to your computer and use it in GitHub Desktop.
Save SISheogorath/593c54607dc2881b5a207f4584411fba to your computer and use it in GitHub Desktop.
A file that generates the source code files with an AGPL header including Copyright notices for all involved people.

The generate-header.sh is a small tool, provided for license changes.

It runs across a git repository and adds an AGPL header to all .js files.

To prevent any loss of data, it's not overwritten. Instead .agpl ist added to the file name.

Now the review process can start and you only have to verify that you can change the license to AGPL for this file. If you are allowed to do so, mv one file over the other. If you are already sure that you are allowed to do it, add a mv ${file}.agpl ${file} statement at the end of the if statement.

If you want to use it for non-JS, please make sure your comment stile is correct and change file ending filter.

#!/bin/sh
if [[ "$1" = "" ]]; then
cat <<EOF
Please add a software name
Usage:
./$0 <software name>
Example:
./$0 "my awesome software"
EOF
exit 1
fi
git ls-tree -r --name-only $(git rev-parse --abbrev-ref HEAD) "./" | while read file ; do
if [[ ${file: -3} == ".js" ]]; then
cat <<EOF >"${file}.agpl"
/*
This file is part of $1
$(git log --follow --pretty="format: Copyright (C) $(date +%Y) %an <%ae>" -- "$file" | sort | uniq)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
EOF
cat "$file" >> "${file}.agpl"
echo "$file.agpl"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment