|
22 | 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23 | 23 | # THE SOFTWARE. |
24 | 24 |
|
| 25 | +# Timezone setup: ensure all processes (nginx, gunicorn, Python logging) use |
| 26 | +# the same timezone so log timestamps are always aligned. |
| 27 | +# |
| 28 | +# When TZ is set it is the authority: /etc/localtime is updated to match so |
| 29 | +# that C programs such as nginx, which read the file directly, agree with |
| 30 | +# Python (which reads TZ via time.tzset() in gunicorn.conf.py). |
| 31 | +# |
| 32 | +# When TZ is not set it is derived from the environment in priority order: |
| 33 | +# 1. /etc/localtime symlink target (common Docker host-timezone pattern) |
| 34 | +# 2. /etc/timezone (plain-file bind-mount fallback) |
| 35 | +# The derived name is exported as TZ so Python and nginx both pick it up. |
| 36 | +if [ -n "${TZ}" ]; then |
| 37 | + if [ -f "/usr/share/zoneinfo/${TZ}" ]; then |
| 38 | + echo "${TZ}" > /etc/timezone 2>/dev/null || true |
| 39 | + echo "Timezone: ${TZ}" |
| 40 | + else |
| 41 | + echo "WARNING: TZ='${TZ}' is not a valid timezone name; timestamps may be inaccurate" |
| 42 | + fi |
| 43 | +elif [ -L /etc/localtime ]; then |
| 44 | + _tz=$(readlink /etc/localtime | sed 's|.*/zoneinfo/||') |
| 45 | + if [ -n "${_tz}" ] && [ -f "/usr/share/zoneinfo/${_tz}" ]; then |
| 46 | + export TZ="${_tz}" |
| 47 | + echo "Timezone derived from /etc/localtime symlink: ${TZ}" |
| 48 | + fi |
| 49 | +elif [ -f /etc/timezone ]; then |
| 50 | + _tz=$(cat /etc/timezone 2>/dev/null | tr -d '[:space:]') |
| 51 | + if [ -n "${_tz}" ] && [ -f "/usr/share/zoneinfo/${_tz}" ]; then |
| 52 | + export TZ="${_tz}" |
| 53 | + echo "Timezone derived from /etc/timezone: ${TZ}" |
| 54 | + fi |
| 55 | +fi |
| 56 | + |
25 | 57 | # Nginx configuration file |
26 | 58 | NGINX_CONF=/opt/apprise/webapp/etc/nginx.conf |
27 | 59 | echo "$STRICT_MODE" | cut -c1 | grep -E -m1 -q -i '\(a|y|1|e|t|+)\)' 2>/dev/null |
|
0 commit comments