diff options
Diffstat (limited to 'docker-entrypoint.sh')
-rw-r--r-- | docker-entrypoint.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..ccf58d7 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +echo "Setting umask to ${UMASK}" +umask ${UMASK} +echo "Creating download directory ${DOWNLOAD_DIR} and state directory ${STATE_DIR}" +mkdir -p "${DOWNLOAD_DIR}" "${STATE_DIR}" + +if [ `id -u` -eq 0 ] && [ `id -g` -eq 0 ]; then + if [ "${UID}" -eq 0 ]; then + echo "Warning: it is not recommended to run as root user, please check your setting of the UID environment variable" + fi + echo "Changing ownership of download and state directories to ${UID}:${GID}" + chown -R "${UID}":"${GID}" /app "${DOWNLOAD_DIR}" "${STATE_DIR}" + echo "Running MeTube as user ${UID}:${GID}" + su-exec "${UID}":"${GID}" python3 app/main.py +else + echo "User set by docker; running MeTube as `id -u`:`id -g`" + python3 app/main.py +fi |