2021-01-15 15:02:06 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
if [[ ${UMASK} ]]; then
|
2021-02-22 21:09:50 +01:00
|
|
|
echo "umask ${UMASK}"
|
2021-01-15 15:02:06 +01:00
|
|
|
umask "${UMASK}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
find /go -type d -print0 | xargs -0 chmod 777
|
2021-01-17 11:56:28 +01:00
|
|
|
chmod -Rf a+rw /var/lib/photoprism /tmp/photoprism /go
|
2021-01-15 15:02:06 +01:00
|
|
|
|
|
|
|
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
|
2021-02-22 21:09:50 +01:00
|
|
|
echo "updating storage permissions..."
|
2021-02-05 17:39:48 +01:00
|
|
|
chown -Rf photoprism /photoprism /var/lib/photoprism /tmp/photoprism /go
|
|
|
|
fi
|
|
|
|
|
2021-02-22 21:09:50 +01:00
|
|
|
echo "running as uid ${UID}:${GID}"
|
|
|
|
echo "${@}"
|
2021-02-05 17:39:48 +01:00
|
|
|
|
2021-01-15 15:02:06 +01: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
|
2021-02-22 21:09:50 +01:00
|
|
|
echo "updating storage permissions..."
|
2021-02-05 17:39:48 +01:00
|
|
|
chown -Rf photoprism /photoprism /var/lib/photoprism /tmp/photoprism /go
|
|
|
|
fi
|
|
|
|
|
2021-02-22 21:09:50 +01:00
|
|
|
echo "running as uid ${UID}"
|
|
|
|
echo "${@}"
|
2021-02-05 17:39:48 +01:00
|
|
|
|
2021-01-15 15:02:06 +01:00
|
|
|
gosu "${UID}" "$@" &
|
|
|
|
else
|
2021-02-22 21:09:50 +01:00
|
|
|
echo "running as uid $(id -u)"
|
|
|
|
echo "${@}"
|
2021-02-05 17:39:48 +01:00
|
|
|
|
2021-01-15 15:02:06 +01:00
|
|
|
"$@" &
|
|
|
|
fi
|
|
|
|
|
|
|
|
PID=$!
|
|
|
|
|
|
|
|
trap "kill $PID" INT TERM
|
|
|
|
wait
|