2021-06-23 03:43:24 +00:00
|
|
|
#!/bin/bash -ae
|
2020-02-10 08:00:54 +00:00
|
|
|
|
|
|
|
## Thanks
|
|
|
|
# https://serverfault.com/a/919212
|
|
|
|
##
|
|
|
|
|
2021-05-21 12:41:00 +00:00
|
|
|
rsync -a --delete /var/www/html/assets/* /assets
|
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
/rsync
|
2020-02-10 08:00:54 +00:00
|
|
|
|
2021-11-09 12:15:33 +00:00
|
|
|
# shellcheck disable=SC2012
|
|
|
|
touch /var/www/html/sites/.build -r "$(ls -td /assets/* | head -n 1)"
|
2020-07-13 17:42:29 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${FRAPPE_PY}" ]] && FRAPPE_PY='0.0.0.0'
|
2020-02-10 08:00:54 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${FRAPPE_PY_PORT}" ]] && FRAPPE_PY_PORT='8000'
|
2020-02-10 08:00:54 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${FRAPPE_SOCKETIO}" ]] && FRAPPE_SOCKETIO='0.0.0.0'
|
2020-02-10 08:00:54 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${SOCKETIO_PORT}" ]] && SOCKETIO_PORT='9000'
|
2020-02-10 08:00:54 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${HTTP_TIMEOUT}" ]] && HTTP_TIMEOUT='120'
|
2021-01-04 13:00:24 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${UPSTREAM_REAL_IP_ADDRESS}" ]] && UPSTREAM_REAL_IP_ADDRESS='127.0.0.1'
|
2021-02-17 11:25:41 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${UPSTREAM_REAL_IP_RECURSIVE}" ]] && UPSTREAM_REAL_IP_RECURSIVE='off'
|
2021-02-17 11:25:41 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${UPSTREAM_REAL_IP_HEADER}" ]] && UPSTREAM_REAL_IP_HEADER='X-Forwarded-For'
|
2021-02-17 11:25:41 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${FRAPPE_SITE_NAME_HEADER}" ]] && FRAPPE_SITE_NAME_HEADER="\$host"
|
2021-03-26 07:56:55 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${HTTP_HOST}" ]] && HTTP_HOST="\$http_host"
|
2021-03-26 07:56:55 +00:00
|
|
|
|
2021-11-21 10:53:32 +00:00
|
|
|
[[ -z "${WEB_PORT}" ]] && WEB_PORT="8080"
|
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
[[ -z "${SKIP_NGINX_TEMPLATE_GENERATION}" ]] && SKIP_NGINX_TEMPLATE_GENERATION='0'
|
2021-03-26 07:56:55 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
if [[ ${SKIP_NGINX_TEMPLATE_GENERATION} == 1 ]]; then
|
2021-03-26 13:48:46 +00:00
|
|
|
echo "Skipping default NGINX template generation. Please mount your own NGINX config file inside /etc/nginx/conf.d"
|
|
|
|
else
|
|
|
|
echo "Generating default template"
|
2021-11-09 10:05:29 +00:00
|
|
|
# shellcheck disable=SC2016
|
2021-03-26 13:48:46 +00:00
|
|
|
envsubst '${FRAPPE_PY}
|
|
|
|
${FRAPPE_PY_PORT}
|
|
|
|
${FRAPPE_SOCKETIO}
|
|
|
|
${SOCKETIO_PORT}
|
|
|
|
${HTTP_TIMEOUT}
|
|
|
|
${UPSTREAM_REAL_IP_ADDRESS}
|
|
|
|
${UPSTREAM_REAL_IP_RECURSIVE}
|
|
|
|
${FRAPPE_SITE_NAME_HEADER}
|
|
|
|
${HTTP_HOST}
|
2021-11-21 10:53:32 +00:00
|
|
|
${UPSTREAM_REAL_IP_HEADER}
|
|
|
|
${WEB_PORT}' \
|
2021-06-23 03:43:24 +00:00
|
|
|
</etc/nginx/conf.d/default.conf.template >/etc/nginx/conf.d/default.conf
|
2021-03-26 13:48:46 +00:00
|
|
|
fi
|
2020-02-10 08:00:54 +00:00
|
|
|
|
2021-06-23 03:43:24 +00:00
|
|
|
echo "Waiting for frappe-python to be available on ${FRAPPE_PY} port ${FRAPPE_PY_PORT}"
|
2021-11-09 10:05:29 +00:00
|
|
|
# shellcheck disable=SC2016
|
2021-06-23 03:43:24 +00:00
|
|
|
timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' ${FRAPPE_PY} ${FRAPPE_PY_PORT}
|
|
|
|
echo "Frappe-python available on ${FRAPPE_PY} port ${FRAPPE_PY_PORT}"
|
|
|
|
echo "Waiting for frappe-socketio to be available on ${FRAPPE_SOCKETIO} port ${SOCKETIO_PORT}"
|
2021-11-09 10:05:29 +00:00
|
|
|
# shellcheck disable=SC2016
|
2021-06-23 03:43:24 +00:00
|
|
|
timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' ${FRAPPE_SOCKETIO} ${SOCKETIO_PORT}
|
|
|
|
echo "Frappe-socketio available on ${FRAPPE_SOCKETIO} port ${SOCKETIO_PORT}"
|
2020-03-04 14:15:25 +00:00
|
|
|
|
2020-02-10 08:00:54 +00:00
|
|
|
exec "$@"
|