2020-10-20 12:47:04 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
if [[ ${UMASK} ]]; then
|
2021-02-05 17:39:48 +01:00
|
|
|
echo "entrypoint: umask ${UMASK}"
|
2020-10-20 12:47:04 +02:00
|
|
|
umask "${UMASK}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${UID} ]] && [[ ${GID} ]] && [[ ${UID} != "0" ]] && [[ $(id -u) = "0" ]]; then
|
|
|
|
groupadd -f -g "${GID}" "${GID}"
|
|
|
|
usermod -o -u "${UID}" -g "${GID}" photoprism
|
2021-02-05 17:39:48 +01:00
|
|
|
|
|
|
|
if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then
|
|
|
|
echo "entrypoint: updating storage permissions"
|
2021-02-05 19:08:00 +01:00
|
|
|
chown -Rf photoprism /photoprism/storage /photoprism/import /photoprism/assets /var/lib/photoprism /tmp/photoprism
|
2021-02-05 17:39:48 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "entrypoint: uid ${UID}:${GID}"
|
|
|
|
echo "entrypoint: starting ${@}"
|
|
|
|
|
2020-10-20 12:47:04 +02:00
|
|
|
gosu "${UID}:${GID}" "$@" &
|
|
|
|
elif [[ ${UID} ]] && [[ ${UID} != "0" ]] && [[ $(id -u) = "0" ]]; then
|
|
|
|
usermod -o -u "${UID}" photoprism
|
2021-02-05 17:39:48 +01:00
|
|
|
|
|
|
|
if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then
|
|
|
|
echo "entrypoint: updating storage permissions"
|
2021-02-05 19:08:00 +01:00
|
|
|
chown -Rf photoprism /photoprism/storage /photoprism/import /photoprism/assets /var/lib/photoprism /tmp/photoprism
|
2021-02-05 17:39:48 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "entrypoint: uid ${UID}"
|
|
|
|
echo "entrypoint: starting ${@}"
|
|
|
|
|
2020-10-20 12:47:04 +02:00
|
|
|
gosu "${UID}" "$@" &
|
|
|
|
else
|
2021-02-05 17:39:48 +01:00
|
|
|
echo "entrypoint: uid $(id -u)"
|
|
|
|
echo "entrypoint: starting ${@}"
|
|
|
|
|
2020-10-20 12:47:04 +02:00
|
|
|
"$@" &
|
|
|
|
fi
|
|
|
|
|
|
|
|
PID=$!
|
|
|
|
|
|
|
|
trap "kill $PID" INT TERM
|
|
|
|
wait
|