mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-19 10:19:27 -05:00
Fix: Explicitly set the HOME environment variable for running as root at startup (#9643)
* Explicitly set the HOME environment for the migrations to fix issue with certificates * Defines the HOME globally when we're running as root for startup
This commit is contained in:
parent
82a5680217
commit
e2860ed36d
@ -1,7 +0,0 @@
|
|||||||
#!/command/with-contenv /usr/bin/bash
|
|
||||||
# shellcheck shell=bash
|
|
||||||
declare -r data_dir="${PAPERLESS_DATA_DIR:-/usr/src/paperless/data}"
|
|
||||||
|
|
||||||
# shellcheck disable=SC2164
|
|
||||||
cd "${PAPERLESS_SRC_DIR}"
|
|
||||||
exec s6-setlock -n "${data_dir}/migration_lock" python3 manage.py migrate --skip-checks --no-input
|
|
@ -2,11 +2,17 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
declare -r log_prefix="[init-migrations]"
|
declare -r log_prefix="[init-migrations]"
|
||||||
|
|
||||||
|
declare -r data_dir="${PAPERLESS_DATA_DIR:-/usr/src/paperless/data}"
|
||||||
|
|
||||||
echo "${log_prefix} Apply database migrations..."
|
echo "${log_prefix} Apply database migrations..."
|
||||||
|
|
||||||
|
cd "${PAPERLESS_SRC_DIR}"
|
||||||
|
|
||||||
# The whole migrate, with flock, needs to run as the right user
|
# The whole migrate, with flock, needs to run as the right user
|
||||||
if [[ -n "${USER_IS_NON_ROOT}" ]]; then
|
if [[ -n "${USER_IS_NON_ROOT}" ]]; then
|
||||||
exec /etc/s6-overlay/s6-rc.d/init-migrations/migrate.sh
|
exec s6-setlock -n "${data_dir}/migration_lock" python3 manage.py migrate --skip-checks --no-input
|
||||||
else
|
else
|
||||||
exec s6-setuidgid paperless /etc/s6-overlay/s6-rc.d/init-migrations/migrate.sh
|
exec s6-setuidgid paperless \
|
||||||
|
s6-setlock -n "${data_dir}/migration_lock" \
|
||||||
|
python3 manage.py migrate --skip-checks --no-input
|
||||||
fi
|
fi
|
||||||
|
@ -15,5 +15,6 @@ if [ $(id -u) == $(id -u paperless) ]; then
|
|||||||
printf "true" > /var/run/s6/container_environment/USER_IS_NON_ROOT
|
printf "true" > /var/run/s6/container_environment/USER_IS_NON_ROOT
|
||||||
echo "${log_prefix} paperless-ngx docker container running under a user"
|
echo "${log_prefix} paperless-ngx docker container running under a user"
|
||||||
else
|
else
|
||||||
|
printf "/usr/src/paperless" > /var/run/s6/container_environment/HOME
|
||||||
echo "${log_prefix} paperless-ngx docker container starting init as root"
|
echo "${log_prefix} paperless-ngx docker container starting init as root"
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user