This repository has been archived on 2025-06-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
server/entrypoint-frontend.sh

33 lines
1 KiB
Bash
Executable file

#!/bin/sh
[ -s /chbase-done ] && CURRENT_BASE=$(cat /chbase-done) || CURRENT_BASE="/"
[ -n "${BASEURL}" ] || BASEURL="/"
[ "${BASEURL}" == "/" ] && BASEURL2="@baseurl" || BASEURL2="${BASEURL}"
run() {
local NEWBASE=$1
local FILE=$2
if [ -d "${FILE}" ]
then
for f in "${FILE}/"*
do
case "${f}" in
"${FILE}/"*.html|"${FILE}/"*.js)
run "${NEWBASE}" "${f}";;
*)
[ -d "${f}" ] && run "${NEWBASE}" "${f}";;
esac
done
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;s@\"${CURRENT_BASE}_app/immutable/@\"${NEWBASE}_app/immutable/@g;s@\"${CURRENT_BASE}_app/\"@\"${NEWBASE}_app/\"@g" ${FILE}
fi
}
[ "${CURRENT_BASE}" != "${BASEURL}" ] && {
run "${BASEURL}" /srv/htdocs-frontend
echo "${BASEURL}" > /chbase-done
}
exec /srv/frontend $@