mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
30 lines
714 B
Bash
Executable file
30 lines
714 B
Bash
Executable file
#!/bin/bash
|
|
scriptPath=$(dirname -- "${0}")
|
|
domainPath="${scriptPath}/../../data/domain"
|
|
userscriptPath="./user.js"
|
|
resultUserscriptPath="./stable.user.js"
|
|
|
|
domain="${DOMAIN}"
|
|
|
|
if [ -f "${domainPath}" ]; then
|
|
domain=$(cat "${domainPath}")
|
|
fi
|
|
|
|
if [ -z "${domain}" ]; then
|
|
echo -e "\033[0;41m${domainPath} does not exist, and DOMAIN is not set!\033[0m"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "${userscriptPath}" ]; then
|
|
echo -e "\033[0;41m${userscriptPath} does not exist!\033[0m"
|
|
exit 1
|
|
fi
|
|
|
|
userscript=$(cat "${userscriptPath}")
|
|
|
|
toReplace="[DOMAIN]"
|
|
result="${userscript//"$toReplace"/"$domain"}"
|
|
|
|
echo "$result" > "${resultUserscriptPath}"
|
|
|
|
echo "Exported with domain: '${domain}' to '${resultUserscriptPath}'"
|