2021-06-08 23:46:09 +00:00
#!/bin/sh
2021-08-24 22:35:05 +00:00
[ -s /chbase-done ] && CURRENT_BASE = $( cat /chbase-done) || CURRENT_BASE = "/"
2021-06-08 23:46:09 +00:00
[ -n " ${ BASEURL } " ] || BASEURL = "/"
2021-08-30 17:43:35 +00:00
[ " ${ BASEURL } " = = "/" ] && BASEURL2 = "@baseurl" || BASEURL2 = " ${ BASEURL } "
2021-06-08 23:46:09 +00:00
run( ) {
local NEWBASE = $1
local FILE = $2
if [ -d " ${ FILE } " ]
then
2022-06-10 16:54:45 +00:00
for f in " ${ FILE } / " *
2021-06-08 23:46:09 +00:00
do
2022-06-10 16:54:45 +00:00
case " ${ f } " in
" ${ FILE } / " *.html| " ${ FILE } / " *.js)
run " ${ NEWBASE } " " ${ f } " ; ;
*)
[ -d " ${ f } " ] && run " ${ NEWBASE } " " ${ f } " ; ;
esac
2021-06-08 23:46:09 +00:00
done
elif [ -f " ${ FILE } " ]
then
2022-06-10 16:54:45 +00:00
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 " ${ FILE }
2021-06-08 23:46:09 +00:00
fi
}
2022-06-06 13:13:33 +00:00
[ " ${ CURRENT_BASE } " != " ${ BASEURL } " ] && {
2021-08-24 22:35:05 +00:00
run " ${ BASEURL } " /srv/htdocs-frontend
echo " ${ BASEURL } " > /chbase-done
}
2021-06-08 23:46:09 +00:00
exec /srv/frontend $@