-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove entrypoint as its causing issues. set default puid/pgid. * handle user management better * Use existing user/group if they already exist --------- Co-authored-by: Spoked <Spoked@localhost>
- Loading branch information
1 parent
f89b5c0
commit ee59e95
Showing
1 changed file
with
17 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,27 @@ | ||
#!/bin/sh | ||
|
||
# Check and set default values for PUID and PGID if not provided | ||
PUID=${PUID:-1000} | ||
PGID=${PGID:-1000} | ||
echo "Starting Container with ${PUID}:${PGID} permissions..." | ||
|
||
echo "Starting Container with $PUID:$PGID permissions..." | ||
|
||
# Check if the iceberg user or group exists, and delete if they do | ||
if getent passwd iceberg > /dev/null 2>&1; then | ||
deluser iceberg | ||
fi | ||
if getent group iceberg > /dev/null 2>&1; then | ||
delgroup iceberg | ||
fi | ||
|
||
# Create the iceberg group if it doesn't exist | ||
if ! getent group $PGID > /dev/null 2>&1; then | ||
# Create group if it doesn't exist or reuse the existing group | ||
if ! getent group $PGID > /dev/null; then | ||
addgroup -g $PGID iceberg | ||
else | ||
iceberg_group=$(getent group $PGID | cut -d: -f1) | ||
echo "Group with GID $PGID already exists as $iceberg_group" | ||
existing_group=$(getent group $PGID | cut -d: -f1) | ||
echo "Group with GID $PGID already exists as $existing_group" | ||
iceberg_group=$existing_group | ||
fi | ||
|
||
# Create the iceberg user | ||
if ! getent passwd $PUID > /dev/null 2>&1; then | ||
adduser -D -u $PUID -G iceberg iceberg | ||
# Create user if it doesn't exist or reuse the existing user | ||
if ! getent passwd $PUID > /dev/null; then | ||
adduser -D -u $PUID -G ${iceberg_group:-iceberg} iceberg | ||
else | ||
iceberg_user=$(getent passwd $PUID | cut -d: -f1) | ||
echo "User with UID $PUID already exists as $iceberg_user" | ||
existing_user=$(getent passwd $PUID | cut -d: -f1) | ||
echo "User with UID $PUID already exists as $existing_user" | ||
iceberg_user=$existing_user | ||
fi | ||
|
||
chown -R iceberg:iceberg /iceberg | ||
exec su iceberg -c "$@" | ||
# Change ownership of relevant directories | ||
chown -R ${PUID}:${PGID} /iceberg | ||
|
||
echo "Initialization complete. Executing main process..." | ||
exec su -s /bin/sh -c "$@" ${iceberg_user:-iceberg} |