mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
fix: Group add issue #131
This commit is contained in:
+11
-3
@@ -5,21 +5,29 @@
|
||||
|
||||
set -e
|
||||
|
||||
# If not running as root, do nothing
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "Running as non-root user ($(id -u)), skipping PUID/PGID handling"
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
|
||||
# Function to create user and switch to it
|
||||
switch_user() {
|
||||
local puid="$1"
|
||||
local pgid="$2"
|
||||
|
||||
# Create group if it doesn't exist
|
||||
if ! getent group bichon >/dev/null 2>&1; then
|
||||
# group: avoid GID conflict
|
||||
if ! getent group "$pgid" >/dev/null 2>&1; then
|
||||
groupadd -g "$pgid" bichon
|
||||
fi
|
||||
|
||||
# Create user if it doesn't exist
|
||||
# user: ensure bichon exists
|
||||
if ! getent passwd bichon >/dev/null 2>&1; then
|
||||
useradd -u "$puid" -g "$pgid" -s /bin/bash -d /data bichon
|
||||
fi
|
||||
|
||||
|
||||
# Change ownership of directories that the process needs to write to
|
||||
chown -R "$puid:$pgid" /data
|
||||
chown -R "$puid:$pgid" /opt/bichon
|
||||
|
||||
Reference in New Issue
Block a user