From 5187dadd5c4d120f5a89ad17fb838ea99f28585a Mon Sep 17 00:00:00 2001 From: andy5995 Date: Sat, 23 Nov 2024 21:50:22 -0600 Subject: [PATCH] Improve (and fix) entrypoint.sh --- ChangeLog.txt | 4 ++++ entrypoint.sh | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9181fea..018d9f3 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +2024-11-23 + + * Improve (and fix) entrypoint.sh + 2024-02-12 * Convert Action to a container diff --git a/entrypoint.sh b/entrypoint.sh index 2a6107b..20cff5b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,21 +1,32 @@ #!/bin/bash +set -e + echo "" -echo "linuxdeploy Build Helper Container v2.0.0" +echo "linuxdeploy Build Helper Container v2.0.1" echo "https://github.com/andy5995/linuxdeploy-build-helper-container" echo "" OLDPWD=$PWD -if [ -z "HOSTUID" ]; then +if [ -z "$HOSTUID" ]; then echo "HOSTUID is not set." exit 1 fi +if [ -z "$HOSTGID" ]; then + echo "HOSTGID is not set." + exit 1 +fi + if [ -z "$1" ]; then echo "One argument required -- the name of a script to run." exit 1 fi -usermod -u $HOSTUID builder -su builder -c "PATH=/home/builder/.local/bin:$PATH && cd $OLDPWD && $1" +usermod -u "$HOSTUID" builder +chown -R "$HOSTUID:$HOSTGID" /home/builder + +# The docs state to use '-w /workdir when running the container, but switching +# to builder here will change the directory. Using cd to change back... +su builder -l -c "cd $OLDPWD && $1"