run-docker.sh: if $TERMUX_DOCKER_USE_SUDO is set, run docker
with sudo
Not all system configurations have user being added into `docker` group.
This commit is contained in:
parent
9d92a7360c
commit
bc20ba7e70
@ -15,6 +15,12 @@ fi
|
|||||||
|
|
||||||
USER=builder
|
USER=builder
|
||||||
|
|
||||||
|
if [ -n "${TERMUX_DOCKER_USE_SUDO-}" ]; then
|
||||||
|
SUDO="sudo"
|
||||||
|
else
|
||||||
|
SUDO=""
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Running container '$CONTAINER_NAME' from image '$TERMUX_BUILDER_IMAGE_NAME'..."
|
echo "Running container '$CONTAINER_NAME' from image '$TERMUX_BUILDER_IMAGE_NAME'..."
|
||||||
|
|
||||||
if [ "${GITHUB_EVENT_PATH-x}" != "x" ]; then
|
if [ "${GITHUB_EVENT_PATH-x}" != "x" ]; then
|
||||||
@ -24,9 +30,9 @@ else
|
|||||||
DOCKER_TTY=" --tty"
|
DOCKER_TTY=" --tty"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker start $CONTAINER_NAME >/dev/null 2>&1 || {
|
$SUDO docker start $CONTAINER_NAME >/dev/null 2>&1 || {
|
||||||
echo "Creating new container..."
|
echo "Creating new container..."
|
||||||
docker run \
|
$SUDO docker run \
|
||||||
--detach \
|
--detach \
|
||||||
--name $CONTAINER_NAME \
|
--name $CONTAINER_NAME \
|
||||||
--volume $REPOROOT:$CONTAINER_HOME_DIR/termux-packages \
|
--volume $REPOROOT:$CONTAINER_HOME_DIR/termux-packages \
|
||||||
@ -35,16 +41,16 @@ docker start $CONTAINER_NAME >/dev/null 2>&1 || {
|
|||||||
if [ "$UNAME" != Darwin ]; then
|
if [ "$UNAME" != Darwin ]; then
|
||||||
if [ $(id -u) -ne 1000 -a $(id -u) -ne 0 ]; then
|
if [ $(id -u) -ne 1000 -a $(id -u) -ne 0 ]; then
|
||||||
echo "Changed builder uid/gid... (this may take a while)"
|
echo "Changed builder uid/gid... (this may take a while)"
|
||||||
docker exec $DOCKER_TTY $CONTAINER_NAME sudo chown -R $(id -u) $CONTAINER_HOME_DIR
|
$SUDO docker exec $DOCKER_TTY $CONTAINER_NAME sudo chown -R $(id -u) $CONTAINER_HOME_DIR
|
||||||
docker exec $DOCKER_TTY $CONTAINER_NAME sudo chown -R $(id -u) /data
|
$SUDO docker exec $DOCKER_TTY $CONTAINER_NAME sudo chown -R $(id -u) /data
|
||||||
docker exec $DOCKER_TTY $CONTAINER_NAME sudo usermod -u $(id -u) builder
|
$SUDO docker exec $DOCKER_TTY $CONTAINER_NAME sudo usermod -u $(id -u) builder
|
||||||
docker exec $DOCKER_TTY $CONTAINER_NAME sudo groupmod -g $(id -g) builder
|
$SUDO docker exec $DOCKER_TTY $CONTAINER_NAME sudo groupmod -g $(id -g) builder
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$#" -eq "0" ]; then
|
if [ "$#" -eq "0" ]; then
|
||||||
docker exec --interactive $DOCKER_TTY $CONTAINER_NAME bash
|
$SUDO docker exec --interactive $DOCKER_TTY $CONTAINER_NAME bash
|
||||||
else
|
else
|
||||||
docker exec --interactive $DOCKER_TTY $CONTAINER_NAME "$@"
|
$SUDO docker exec --interactive $DOCKER_TTY $CONTAINER_NAME "$@"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user