aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/addLicense.sh
blob: 890a2d276f4a9d1cc0fbf97b29cdfd1d3027727f (plain)
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
##
# 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