nopaque/docker-entrypoint.sh
2023-09-25 10:11:11 +02:00

56 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
GREEN_COLOR="\033[0;32m"
RED_COLOR="\033[0;31m"
NO_COLOR="\033[0m"
CHECK_MARK="\xE2\x9C\x93"
CROSS_MARK="\xE2\x9D\x8C"
echo -n "Set container UID and GIDs to match the host system..."
if [[ "${NOPAQUE_UID}" == 0 ]]; then
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
echo "Running as root is not allowed"
exit 1
else
echo ""
fi
echo -n "- Updating docker GID ($(getent group docker | cut -d: -f3) -> ${DOCKER_GID})... "
groupmod --gid "${DOCKER_GID}" docker > /dev/null
if [[ "${?}" == "0" ]]; then
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
else
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
exit 1
fi
echo -n "- Updating nopaque GID ($(id -g nopaque) -> ${NOPAQUE_GID})... "
groupmod --gid "${NOPAQUE_GID}" nopaque > /dev/null
if [[ "${?}" == "0" ]]; then
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
else
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
exit 1
fi
echo -n "- Updating nopaque UID ($(id -u nopaque) -> ${NOPAQUE_UID})... "
usermod --uid "${NOPAQUE_UID}" nopaque > /dev/null
if [[ "${?}" == "0" ]]; then
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
else
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
exit 1
fi
echo -n "- Updating nopaque directory owner and group... "
chown -R nopaque:nopaque /home/nopaque
if [[ "${?}" == "0" ]]; then
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
else
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
exit 1
fi
exec gosu nopaque ./boot.sh ${@}