2021-07-21 10:30:51 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-10-22 08:44:09 +00:00
|
|
|
[ -f "/base_changed" ] && exit 0
|
|
|
|
|
2021-07-21 10:30:51 +00:00
|
|
|
[ -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
|
2022-06-10 16:54:45 +00:00
|
|
|
for f in "${FILE}/"*
|
2021-07-21 10:30:51 +00:00
|
|
|
do
|
2022-06-10 16:54:45 +00:00
|
|
|
case "${f}" in
|
|
|
|
"${FILE}/"*.html|"${FILE}/"*.js|"${FILE}/"*.css)
|
|
|
|
run "${NEWBASE}" "${f}";;
|
|
|
|
esac
|
2021-07-21 10:30:51 +00:00
|
|
|
done
|
|
|
|
elif [ -f "${FILE}" ]
|
|
|
|
then
|
2023-07-23 10:30:30 +00:00
|
|
|
echo "Updating base path for $FILE..."
|
|
|
|
sed -ri "s@<base href=\"${CURRENT_BASE}\">@<base href=\"${NEWBASE}\">@;s@\"${CURRENT_BASE}_app/@\"${NEWBASE}_app/@;s@base: \"${CURRENT_BASE%/}\"@base: \"${NEWBASE%/}\"@" ${FILE}
|
2021-07-21 10:30:51 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
run "${FIC_BASEURL}" "${PATH_STATIC}"
|
2021-10-22 08:44:09 +00:00
|
|
|
touch "/base_changed"
|
2021-07-21 10:30:51 +00:00
|
|
|
|
2023-05-12 14:30:17 +00:00
|
|
|
if [ "${FIC_BASEURL}" == "/" ] && [ -f /etc/nginx/conf.d/default.conf ]
|
|
|
|
then
|
|
|
|
sed -i "s:location / {:location @notneeded {:" /etc/nginx/conf.d/default.conf
|
|
|
|
fi
|
|
|
|
|
2023-08-03 10:59:41 +00:00
|
|
|
[ -n "${FIC_CUSTOM_HEAD}" ] && sed -i "s|</head>|${FIC_CUSTOM_HEAD}</head>|" "${PATH_STATIC}/index.html"
|
|
|
|
[ -n "${FIC_CUSTOM_BODY}" ] && sed -i "s|</body>|${FIC_CUSTOM_BODY}</body>|" "${PATH_STATIC}/index.html"
|
|
|
|
|
2021-07-21 10:30:51 +00:00
|
|
|
exit 0
|