server/entrypoint-frontend.sh

27 lines
724 B
Bash
Executable File

#!/bin/sh
CURRENT_BASE="/"
[ -n "${BASEURL}" ] || BASEURL="/"
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
}
[ "${CURRENT_BASE}" != "${BASEURL}"] && run "${BASEURL}" /srv/htdocs-frontend
exec /srv/frontend $@