45 lines
1.1 KiB
Bash
45 lines
1.1 KiB
Bash
#!/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
|
|
}
|
|
|
|
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
|
|
|
|
if [[ "$ENABLE_CRON" == "true" ]]; then
|
|
echo "Cron is enabled"
|
|
crond -b
|
|
else
|
|
echo "Cron is disabled"
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
verify_config_exist
|
|
setup_cron
|
|
|
|
chown -R nginx:nginx /usr/share/nginx/html
|
|
chown -R "${USER_ID}":"${GROUP_ID}" /content
|
|
chown -R "${USER_ID}":"${GROUP_ID}" /config
|
|
|
|
# NGINX script to sub variables in the template
|
|
echo "NGINX variable substitution..."
|
|
/docker-entrypoint.d/20-envsubst-on-templates.sh
|
|
|
|
echo "Starting Quartz..."
|
|
echo "Installing dependencies..."
|
|
npm i >/dev/null
|
|
|
|
echo "Building Quartz..."
|
|
npx quartz build >/dev/null
|
|
|
|
echo "Starting Nginx..."
|
|
exec nginx -g "daemon off;"
|
|
}
|
|
|
|
main
|