-
-
Notifications
You must be signed in to change notification settings - Fork 61
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 --------- Co-authored-by: Spoked <Spoked@localhost> Co-authored-by: Spoked <[email protected]>
- Loading branch information
1 parent
750822d
commit f89b5c0
Showing
2 changed files
with
35 additions
and
37 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 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,31 +1,34 @@ | ||
#!/bin/sh | ||
|
||
# Exit immediately if a command exits with a non-zero status | ||
# set -e | ||
# Check and set default values for PUID and PGID if not provided | ||
PUID=${PUID:-1000} | ||
PGID=${PGID:-1000} | ||
|
||
# Treat unset variables as an error | ||
# set -u | ||
echo "Starting Container with $PUID:$PGID permissions..." | ||
|
||
echo "Starting Iceberg container..." | ||
# 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 | ||
|
||
# Check for required environment variables and validate configuration | ||
# NOTE: This will be used to check for rclone flags and other configuration later | ||
# required_vars=("REQUIRED_VAR1" "REQUIRED_VAR2") | ||
# for var in "${required_vars[@]}"; do | ||
# if [ -z "${!var:-}" ]; then | ||
# echo "Error: Required environment variable '$var' not set." | ||
# exit 1 | ||
# fi | ||
# done | ||
# Create the iceberg group if it doesn't exist | ||
if ! getent group $PGID > /dev/null 2>&1; then | ||
addgroup -g $PGID iceberg | ||
else | ||
iceberg_group=$(getent group $PGID | cut -d: -f1) | ||
echo "Group with GID $PGID already exists as $iceberg_group" | ||
fi | ||
|
||
PUID=${PUID:-1000} | ||
PGID=${PGID:-1000} | ||
# Create the iceberg user | ||
if ! getent passwd $PUID > /dev/null 2>&1; then | ||
adduser -D -u $PUID -G iceberg iceberg | ||
else | ||
iceberg_user=$(getent passwd $PUID | cut -d: -f1) | ||
echo "User with UID $PUID already exists as $iceberg_user" | ||
fi | ||
|
||
addgroup -g $PGID iceberg | ||
adduser -D -u $PUID -G iceberg iceberg | ||
chown -R iceberg:iceberg /iceberg | ||
chmod -R 755 /iceberg | ||
|
||
trap "echo 'Shutting down...'; exit" SIGINT SIGTERM | ||
echo "Initialization complete. Executing main process..." | ||
exec "$@" | ||
exec su iceberg -c "$@" |