Skip to content

🙌 OpenHands: AI-Driven Development

Checked for enduser in Docker (#1899)

மனோஜ்குமார் பழனிச்சாமி6ef7e6eb0fc9
diff --git a/containers/app/entrypoint.sh b/containers/app/entrypoint.sh
index 5ccb355ad7..c6fb252f03 100755
--- a/containers/app/entrypoint.sh
+++ b/containers/app/entrypoint.sh
@@ -26,13 +26,17 @@ if [[ "$SANDBOX_USER_ID" -eq 0 ]]; then
"$@"
else
echo "Setting up enduser with id $SANDBOX_USER_ID"
- if ! useradd -l -m -u $SANDBOX_USER_ID -s /bin/bash enduser; then
- echo "Failed to create user enduser with id $SANDBOX_USER_ID. Moving opendevin user."
- incremented_id=$(($SANDBOX_USER_ID + 1))
- usermod -u $incremented_id opendevin
+ if id "enduser" &>/dev/null; then
+ echo "User enduser already exists. Skipping creation."
+ else
if ! useradd -l -m -u $SANDBOX_USER_ID -s /bin/bash enduser; then
- echo "Failed to create user enduser with id $SANDBOX_USER_ID for a second time. Exiting."
- exit 1
+ echo "Failed to create user enduser with id $SANDBOX_USER_ID. Moving opendevin user."
+ incremented_id=$(($SANDBOX_USER_ID + 1))
+ usermod -u $incremented_id opendevin
+ if ! useradd -l -m -u $SANDBOX_USER_ID -s /bin/bash enduser; then
+ echo "Failed to create user enduser with id $SANDBOX_USER_ID for a second time. Exiting."
+ exit 1
+ fi
fi
fi
usermod -aG app enduser