fix: Group add issue #131

This commit is contained in:
rustmailer
2026-01-23 12:21:14 +08:00
parent ddd93ff4ab
commit 451b5338f1
+11 -3
View File
@@ -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