1
0
Fork 0
pixelfed/docker/shared/root/docker/entrypoint.d/04-defaults.envsh

34 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-01-04 16:08:01 +00:00
#!/bin/bash
# NOTE:
#
2024-01-04 21:55:24 +00:00
# This file is *sourced* not run by the entrypoint runner
2024-01-04 16:08:01 +00:00
# so any environment values set here will be accessible to all sub-processes
# and future entrypoint.d scripts
#
2024-01-04 21:55:24 +00:00
# We also don't need to source `helpers.sh` since it's already available
2024-01-04 16:08:01 +00:00
2024-01-05 00:11:20 +00:00
entrypoint-set-script-name "${BASH_SOURCE[0]}"
2024-01-04 16:08:01 +00:00
load-config-files
2024-01-17 14:46:07 +00:00
: "${MAX_PHOTO_SIZE:=15000}"
: "${MAX_ALBUM_LENGTH:=4}"
2024-01-15 18:53:54 +00:00
2024-01-04 21:55:24 +00:00
# We assign a 1MB buffer to the just-in-time calculated max post size to allow for fields and overhead
2024-01-15 17:16:00 +00:00
: "${POST_MAX_SIZE_BUFFER:=1M}"
2024-01-04 21:21:00 +00:00
log-info "POST_MAX_SIZE_BUFFER is set to [${POST_MAX_SIZE_BUFFER}]"
2024-01-04 16:08:01 +00:00
buffer=$(numfmt --invalid=fail --from=auto --to=none --to-unit=K "${POST_MAX_SIZE_BUFFER}")
2024-01-04 21:21:00 +00:00
log-info "POST_MAX_SIZE_BUFFER converted to KB is [${buffer}]"
2024-01-04 16:08:01 +00:00
2024-01-04 21:55:24 +00:00
# Automatically calculate the [post_max_size] value for [php.ini] and [nginx]
2024-01-04 21:21:00 +00:00
log-info "POST_MAX_SIZE will be calculated by [({MAX_PHOTO_SIZE} * {MAX_ALBUM_LENGTH}) + {POST_MAX_SIZE_BUFFER}]"
log-info " MAX_PHOTO_SIZE=${MAX_PHOTO_SIZE}"
log-info " MAX_ALBUM_LENGTH=${MAX_ALBUM_LENGTH}"
log-info " POST_MAX_SIZE_BUFFER=${buffer}"
2024-01-15 17:16:00 +00:00
: "${POST_MAX_SIZE:=$(numfmt --invalid=fail --from=auto --from-unit=K --to=si $(((MAX_PHOTO_SIZE * MAX_ALBUM_LENGTH) + buffer)))}"
2024-01-04 21:21:00 +00:00
log-info "POST_MAX_SIZE was calculated to [${POST_MAX_SIZE}]"
2024-01-04 16:08:01 +00:00
2024-01-04 21:55:24 +00:00
# NOTE: must export the value so it's available in other scripts!
2024-01-04 16:08:01 +00:00
export POST_MAX_SIZE