quartz-docker/entrypoint.sh

46 lines
1.1 KiB
Bash
Raw Normal View History

2025-01-17 00:27:12 +00:00
#!/bin/bash
set -e
verify_config_exist() {
if [[ ! -f "/config/config.json" ]]; then
echo "Config file not found, copying default config..."
cp /usr/share/nginx/html/config.json /config/config.json
fi
}
2025-01-17 00:27:12 +00:00
setup_cron() {
echo "${BUILD_SCHEDULE} cd /usr/share/nginx/html/content && git pull >/dev/null 2>&1 && cd /usr/share/nginx/html && npx quartz build >/dev/null 2>&1" >/etc/crontabs/root
2025-01-17 00:27:12 +00:00
if [[ "$ENABLE_CRON" == "true" ]]; then
echo "Cron is enabled"
crond -b
else
echo "Cron is disabled"
2025-01-17 00:27:12 +00:00
fi
}
2025-01-17 02:27:03 +00:00
main() {
verify_config_exist
setup_cron
2025-01-17 00:27:12 +00:00
chown -R nginx:nginx /usr/share/nginx/html
chown -R "${USER_ID}":"${GROUP_ID}" /content
chown -R "${USER_ID}":"${GROUP_ID}" /config
2025-01-17 02:27:03 +00:00
# NGINX script to sub variables in the template
echo "NGINX variable substitution..."
/docker-entrypoint.d/20-envsubst-on-templates.sh
2025-01-17 00:27:12 +00:00
echo "Starting Quartz..."
echo "Installing dependencies..."
npm i >/dev/null
2025-01-17 02:27:03 +00:00
echo "Building Quartz..."
npx quartz build
2025-01-17 00:27:12 +00:00
echo "Starting Nginx..."
exec nginx -g "daemon off;"
}
2025-01-17 00:27:12 +00:00
main