createrepo-docker/createrepo.sh

21 lines
484 B
Bash
Raw Normal View History

2022-05-03 10:34:29 +00:00
#!/bin/bash
set -e
CONTAINER_RUNTIME=$(which docker)
2022-05-03 14:02:08 +00:00
2022-05-03 15:25:29 +00:00
CREATEREPO_IMAGE_FULLY_QUALIFIED=docker.io/volkerraschek/createrepo:0.17.2
2022-05-03 10:34:29 +00:00
CUSTOM_UID=$(getent passwd ${USER} | cut -d ':' -f 3)
CUSTOM_GID=$(getent passwd ${USER} | cut -d ':' -f 4)
2022-05-03 13:56:04 +00:00
# Extract last element of passed arguments
REPO_DIR=${@: -1}
2022-05-03 10:34:29 +00:00
${CONTAINER_RUNTIME} run \
--rm \
2022-05-03 13:56:04 +00:00
--volume ${REPO_DIR}:${REPO_DIR} \
--workdir ${REPO_DIR} \
2022-05-03 10:34:29 +00:00
--user ${CUSTOM_UID}:${CUSTOM_GID} \
2022-05-03 14:02:08 +00:00
${CREATEREPO_IMAGE_FULLY_QUALIFIED} ${@}