-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: oguzkaganozt <[email protected]>
- Loading branch information
1 parent
46dc8b2
commit b38a0f7
Showing
3 changed files
with
32 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC1090,SC1091 | ||
set -e | ||
|
||
# hadolint ignore=SC1090 | ||
source "/opt/ros/$ROS_DISTRO/setup.bash" | ||
source /autoware/install/setup.bash | ||
exec "$@" | ||
# Get the user ID and group ID of the local user | ||
USER_ID=${LOCAL_UID} | ||
USER_NAME=${LOCAL_USER} | ||
GROUP_ID=${LOCAL_GID} | ||
GROUP_NAME=${LOCAL_GROUP} | ||
|
||
# Check if any of the variables are empty | ||
if [[ -z $USER_ID || -z $USER_NAME || -z $GROUP_ID || -z $GROUP_NAME ]]; then | ||
source "/opt/ros/$ROS_DISTRO/setup.bash" | ||
source /autoware/install/setup.bash | ||
exec "$@" | ||
else | ||
echo "Starting with user: $USER_NAME >> UID $USER_ID, GID: $GROUP_ID" | ||
|
||
# Create group and user with GID/UID | ||
groupadd -g "$GROUP_ID" "$GROUP_NAME" | ||
useradd -u "$USER_ID" -g "$GROUP_ID" -s /bin/bash -m -d /home/"$USER_NAME" "$USER_NAME" | ||
|
||
# Add sudo privileges to the user | ||
echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers | ||
|
||
# Source ROS2 | ||
# hadolint ignore=SC1090 | ||
source "/opt/ros/$ROS_DISTRO/setup.bash" | ||
source /autoware/install/setup.bash | ||
|
||
# Execute the command as the user | ||
exec /usr/sbin/gosu "$USER_NAME" "$@" | ||
fi |