2023-04-26 09:31:07 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
ROOT_DIR=/app
|
2023-05-08 19:34:30 -05:00
|
|
|
# Save old variables
|
|
|
|
|
|
|
|
# Get old vars
|
|
|
|
if [ -f .env.old ]; then
|
|
|
|
export $(echo $(cat .env.old | sed 's/#.*//g'| xargs) | envsubst)
|
|
|
|
else
|
2023-06-13 11:43:19 -05:00
|
|
|
export SAFETWITCH_BACKEND_DOMAIN_PLACEHOLDER=SAFETWITCH_BACKEND_DOMAIN_PLACEHOLDER
|
|
|
|
export SAFETWITCH_INSTANCE_DOMAIN_PLACEHOLDER=SAFETWITCH_INSTANCE_DOMAIN_PLACEHOLDER
|
|
|
|
export SAFETWITCH_HTTPS_PLACEHOLDER=SAFETWITCH_HTTPS_PLACEHOLDER
|
2024-02-12 21:54:59 -05:00
|
|
|
export SAFETWITCH_DEFAULT_THEME_PLACEHOLDER=SAFETWITCH_DEFAULT_THEME_PLACEHOLDER
|
|
|
|
export SAFETWITCH_DEFAULT_LOCALE_PLACEHOLDER=SAFETWITCH_DEFAULT_LOCALE_PLACEHOLDER
|
|
|
|
export SAFETWITCH_FALLBACK_LOCALE_PLACEHOLDER=SAFETWITCH_FALLBACK_LOCALE_PLACEHOLDER
|
2023-05-08 19:34:30 -05:00
|
|
|
fi
|
|
|
|
|
2023-04-26 09:31:07 -05:00
|
|
|
# Replace env vars in files served by NGINX
|
|
|
|
for file in $ROOT_DIR/assets/*.js $ROOT_DIR/index.html;
|
|
|
|
do
|
2023-06-13 11:43:19 -05:00
|
|
|
sed -i 's|'${SAFETWITCH_BACKEND_DOMAIN_PLACEHOLDER}'|'${SAFETWITCH_BACKEND_DOMAIN}'|g' $file
|
|
|
|
sed -i 's|'${SAFETWITCH_INSTANCE_DOMAIN_PLACEHOLDER}'|'${SAFETWITCH_INSTANCE_DOMAIN}'|g' $file
|
|
|
|
sed -i 's|'${SAFETWITCH_HTTPS_PLACEHOLDER}'|'${SAFETWITCH_HTTPS}'|g' $file
|
2024-02-12 11:27:19 -05:00
|
|
|
sed -i 's|'${SAFETWITCH_DEFAULT_THEME_PLACEHOLDER}'|'${SAFETWITCH_DEFAULT_THEME}'|g' $file
|
2024-02-12 21:54:59 -05:00
|
|
|
sed -i 's|'${SAFETWITCH_DEFAULT_LOCALE_PLACEHOLDER}'|'${SAFETWITCH_DEFAULT_LOCALE}'|g' $file
|
|
|
|
sed -i 's|'${SAFETWITCH_FALLBACK_LOCALE_PLACEHOLDER}'|'${SAFETWITCH_FALLBACK_LOCALE}'|g' $file
|
2023-04-26 09:31:07 -05:00
|
|
|
# Your other variables here...
|
|
|
|
done
|
|
|
|
|
2023-05-08 19:34:30 -05:00
|
|
|
# Save old variables
|
2023-06-13 11:43:19 -05:00
|
|
|
echo -e "SAFETWITCH_BACKEND_DOMAIN_PLACEHOLDER=${SAFETWITCH_BACKEND_DOMAIN}" > .env.old
|
|
|
|
echo -e "SAFETWITCH_INSTANCE_DOMAIN_PLACEHOLDER=${SAFETWITCH_INSTANCE_DOMAIN}" >> .env.old
|
|
|
|
echo -e "SAFETWITCH_HTTPS_PLACEHOLDER=${SAFETWITCH_HTTPS}" >> .env.old
|
2024-02-12 11:27:19 -05:00
|
|
|
echo -e "SAFETWITCH_DEFAULT_THEME_PLACEHOLDER=${SAFETWITCH_DEFAULT_THEME}" >> .env.old
|
2024-02-12 21:54:59 -05:00
|
|
|
echo -e "SAFETWITCH_DEFAULT_LOCALE_PLACEHOLDER=${SAFETWITCH_DEFAULT_LOCALE}" >> .env.old
|
|
|
|
echo -e "SAFETWITCH_FALLBACK_LOCALE_PLACEHOLDER=${SAFETWITCH_FALLBACK_LOCALE}" >> .env.old
|
2023-05-08 19:34:30 -05:00
|
|
|
|
2023-04-26 09:31:07 -05:00
|
|
|
# Starting NGINX
|
|
|
|
nginx -g 'daemon off;'
|