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
|
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
|
# Function to create user and switch to it
|
||||||
switch_user() {
|
switch_user() {
|
||||||
local puid="$1"
|
local puid="$1"
|
||||||
local pgid="$2"
|
local pgid="$2"
|
||||||
|
|
||||||
# Create group if it doesn't exist
|
# group: avoid GID conflict
|
||||||
if ! getent group bichon >/dev/null 2>&1; then
|
if ! getent group "$pgid" >/dev/null 2>&1; then
|
||||||
groupadd -g "$pgid" bichon
|
groupadd -g "$pgid" bichon
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create user if it doesn't exist
|
# user: ensure bichon exists
|
||||||
if ! getent passwd bichon >/dev/null 2>&1; then
|
if ! getent passwd bichon >/dev/null 2>&1; then
|
||||||
useradd -u "$puid" -g "$pgid" -s /bin/bash -d /data bichon
|
useradd -u "$puid" -g "$pgid" -s /bin/bash -d /data bichon
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Change ownership of directories that the process needs to write to
|
# Change ownership of directories that the process needs to write to
|
||||||
chown -R "$puid:$pgid" /data
|
chown -R "$puid:$pgid" /data
|
||||||
chown -R "$puid:$pgid" /opt/bichon
|
chown -R "$puid:$pgid" /opt/bichon
|
||||||
|
|||||||
Reference in New Issue
Block a user