New env variable FIC_BASEURL to change the base URL

This commit is contained in:
nemunaire 2021-07-21 12:30:51 +02:00
commit 8f1b44e3dd
12 changed files with 161 additions and 73 deletions

27
configs/nginx-chbase.sh Executable file
View file

@ -0,0 +1,27 @@
#!/bin/sh
[ -z "${FIC_BASEURL}" ] && exit 0
[ -z "${PATH_STATIC}" ] && { >&2 echo "PATH_STATIC not defined"; exit 1; }
[ -n "${CURRENT_BASE}" ] || CURRENT_BASE="/"
run() {
local NEWBASE=$1
local FILE=$2
if [ -d "${FILE}" ]
then
for f in "${FILE}/"*.html "${FILE}/"*.js
do
run "${NEWBASE}" "${f}"
done
[ -d "${FILE}/js/" ] && run "${NEWBASE}" "${FILE}/js"
[ -d "${FILE}/views/" ] && run "${NEWBASE}" "${FILE}/views"
elif [ -f "${FILE}" ]
then
sed -ri "s@(href|src)=\"${CURRENT_BASE}@\1=\"${NEWBASE}@g;s@\\\$http.get\(\"${CURRENT_BASE}@\$http.get\(\"${NEWBASE}@g;s@\\\$http\((.*)\"${CURRENT_BASE}@\$http(\1\"${NEWBASE}@g" ${FILE}
fi
}
run "${FIC_BASEURL}" "${PATH_STATIC}"
exit 0