#!/bin/sh -e
# Generates lists of files based on the license header


PLUGINDIR="../scripts"
# List of GPL plugins

tmplist=`tempfile`
find $PLUGINDIR -type f | grep -v .svn >$tmplist

cat $tmplist | xargs egrep -li "the terms of the GNU General Public Licen.e"  >license-gpl-full-header


cat $tmplist | xargs grep -li "^# GPL" >license-gpl-reduced-header
cat $tmplist | xargs grep -li "GNU GPL v2"  >>license-gpl-reduced-header
cat $tmplist | xargs grep -li "GNU Public Licen"  >>license-gpl-reduced-header
cat $tmplist | xargs grep -li "under the GPL"  >>license-gpl-reduced-header
cat $tmplist | xargs grep -li "under GPL"  >>license-gpl-reduced-header
cat $tmplist | xargs grep -li "GPLv2"  >>license-gpl-reduced-header
cat $tmplist | xargs grep -li "GPL v2" >>license-gpl-reduced-header
cat $tmplist | xargs grep -li "(GPL)"  >>license-gpl-reduced-header
cat $tmplist | xargs grep -li " GPL "  >>license-gpl-reduced-header
cat $tmplist | xargs grep -li -- "- GPL" >>license-gpl-reduced-header


cat $tmplist | xargs egrep -li "See the Nessus Scripts? License" >license-nsl-header

cat $tmplist | xargs grep -li "permitted provided that the following conditions"  >license-bsd-header

# Other plugins with no explict license
(ls $PLUGINDIR/* ; cat license*) | sort | uniq -c | grep " 1 " | awk '{print $2}' >license-no-license-header

rm -f $tmplist
