2021-11-30 13:15:02 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-06-26 08:29:03 +00:00
|
|
|
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2021-12-01 12:42:53 +00:00
|
|
|
set -Eeuo pipefail
|
|
|
|
trap cleanup SIGINT SIGTERM ERR EXIT
|
2021-11-30 13:15:02 +00:00
|
|
|
|
2021-12-01 12:42:53 +00:00
|
|
|
readonly PROJECT_ROOT=$(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))
|
|
|
|
readonly DIST=$PROJECT_ROOT/static/cache/bundle/
|
2021-11-30 13:15:02 +00:00
|
|
|
readonly SOURCE="// @source https://github.com/mCaptcha/mCaptcha"
|
|
|
|
readonly LICENSE_END="// @license-end"
|
|
|
|
|
2021-12-02 08:55:29 +00:00
|
|
|
source $PROJECT_ROOT/scripts/lib.sh
|
2021-12-01 12:42:53 +00:00
|
|
|
|
|
|
|
print_license_msg() {
|
2021-12-02 08:55:29 +00:00
|
|
|
msg "${GREEN}- Applying $1 on $(get_file_name $2)"
|
2021-12-01 12:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
apply_agpl() {
|
|
|
|
print_license_msg "AGPL" $1
|
2022-07-22 19:17:44 +00:00
|
|
|
local AGPL='// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0'
|
2021-12-01 12:42:53 +00:00
|
|
|
echo $AGPL >> $1
|
|
|
|
}
|
|
|
|
|
|
|
|
apply_x11() {
|
|
|
|
print_license_msg "X11" $1
|
2022-07-22 19:17:44 +00:00
|
|
|
local MIT='// @license magnet:?xt=urn:btih:5305d91886084f776adcf57509a648432709a7c7&dn=x11.txt X11'
|
2021-12-01 12:42:53 +00:00
|
|
|
echo $MIT >> $1
|
|
|
|
}
|
|
|
|
|
|
|
|
apply_apache() {
|
|
|
|
print_license_msg "APACHE" $1
|
2022-07-22 19:17:44 +00:00
|
|
|
local APACHE='// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt Apache-2.0'
|
2021-12-01 12:42:53 +00:00
|
|
|
echo $APACHE >> $1
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_colors
|
|
|
|
|
2021-12-02 08:55:29 +00:00
|
|
|
msg "${BLUE}[*] LibreJS processor running"
|
|
|
|
|
2021-12-01 12:42:53 +00:00
|
|
|
for file in $(find $DIST -type f -a -name "*.js")
|
2021-11-30 13:15:02 +00:00
|
|
|
do
|
2022-07-22 19:17:44 +00:00
|
|
|
contents=""
|
|
|
|
cp $file $file.librejs
|
2021-12-01 12:42:53 +00:00
|
|
|
: > $file
|
|
|
|
|
|
|
|
name=$(get_file_name $file)
|
|
|
|
case $name in
|
|
|
|
"bundle.js")
|
|
|
|
apply_agpl $file
|
|
|
|
;;
|
2021-12-02 08:55:29 +00:00
|
|
|
"verificationWidget.js" | "bench.js")
|
2021-12-01 12:42:53 +00:00
|
|
|
apply_x11 $file
|
|
|
|
apply_apache $file
|
|
|
|
;;
|
|
|
|
*)
|
2021-12-02 08:55:29 +00:00
|
|
|
msg "${RED}- [!] License not configured for $name. Applying default license"
|
2021-12-01 12:42:53 +00:00
|
|
|
apply_agpl $file
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2021-11-30 13:15:02 +00:00
|
|
|
echo $SOURCE >> $file
|
2022-07-22 19:17:44 +00:00
|
|
|
cat $file.librejs >> $file
|
|
|
|
rm $file.librejs
|
2021-11-30 13:15:02 +00:00
|
|
|
echo $LICENSE_END >> $file
|
|
|
|
done
|