diff options
-rwxr-xr-x | scripts/addLicense.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/addLicense.sh b/scripts/addLicense.sh new file mode 100755 index 0000000..890a2d2 --- /dev/null +++ b/scripts/addLicense.sh @@ -0,0 +1,56 @@ +## +# Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com> +# +# SPDX-License-Identifier: MIT +## + +COPYRIGHT_C="\ +/* + * Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com> + * + * SPDX-License-Identifier: MIT + */ +" + +COPYRIGHT_UNI="\ +// +// Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com> +// +// SPDX-License-Identifier: MIT +// +" + +COPYRIGHT_META="\ +## +# Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com> +# +# SPDX-License-Identifier: MIT +## +" + +DIR="$(dirname $(dirname "$(readlink -f "$0")"))" + +function insertCopyright { + FILENAME=${1} + COPYRIGHT=${2} + grep "Copyright" "${FILENAME}" > /dev/null + if [ $? -eq 1 ]; then + echo "${COPYRIGHT}" | cat - "${FILENAME}" > /tmp/out && mv /tmp/out "${FILENAME}"; + fi +} + +for i in $(find ${DIR} -type f -name "*.c"); +do + insertCopyright "${i}" "${COPYRIGHT_C}" +done + +for i in $(find ${DIR} -type f -name "*.uni"); +do + insertCopyright "${i}" "${COPYRIGHT_UNI}" +done + +for i in $(find ${DIR} -type f -name "*.dsc" -o -name "*.dec" -o -name "*.inf"); +do + insertCopyright "${i}" "${COPYRIGHT_META}" +done + |