fix(script): set custom uid/gid via env
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Markus Pesch 2024-11-08 14:05:27 +01:00
parent cc49e734bd
commit c4ac21f206
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982

16
createrepo.sh Normal file → Executable file
View File

@ -4,17 +4,17 @@ set -e
CONTAINER_RUNTIME=$(which docker) CONTAINER_RUNTIME=$(which docker)
CREATEREPO_IMAGE_FULLY_QUALIFIED=docker.io/volkerraschek/createrepo:0.17.2 CREATEREPO_IMAGE_FULLY_QUALIFIED="docker.io/volkerraschek/createrepo:0.17.2"
CUSTOM_UID=$(getent passwd ${USER} | cut -d ':' -f 3) CUSTOM_UID="${CUSTOM_UID:-"$(getent passwd "${USER}" | cut -d ':' -f 3)"}"
CUSTOM_GID=$(getent passwd ${USER} | cut -d ':' -f 4) CUSTOM_GID="${CUSTOM_GID:-"$(getent passwd "${USER}" | cut -d ':' -f 4)"}"
# Extract last element of passed arguments # Extract last element of passed arguments
REPO_DIR=${@: -1} REPO_DIR="${*: -1}"
${CONTAINER_RUNTIME} run \ ${CONTAINER_RUNTIME} run \
--rm \ --rm \
--volume ${REPO_DIR}:${REPO_DIR} \ --volume "${REPO_DIR}:${REPO_DIR}" \
--workdir ${REPO_DIR} \ --workdir "${REPO_DIR}" \
--user ${CUSTOM_UID}:${CUSTOM_GID} \ --user "${CUSTOM_UID}:${CUSTOM_GID}" \
${CREATEREPO_IMAGE_FULLY_QUALIFIED} ${@} "${CREATEREPO_IMAGE_FULLY_QUALIFIED}" "${@}"