1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-20 02:48:03 -05:00
bitwarden/util/Nginx/setup-bwuser.sh
2025-06-18 14:50:42 -04:00

39 lines
649 B
Bash

#!/bin/sh
# Setup
if [ -n $1 ]; then
USERNAME=$1
else
echo "[!] setup-bwuser.sh is missing username"
exit 1
fi
if [ -n $2 ]; then
GROUPNAME=$2
else
echo "[!] setup-bwuser.sh is missing groupname"
exit 1
fi
LUID=${LOCAL_UID:-0}
LGID=${LOCAL_GID:-0}
# Step down from host root to well-known nobody/nogroup user
if [ $LUID -eq 0 ]
then
LUID=65534
fi
if [ $LGID -eq 0 ]
then
LGID=65534
fi
# Create user and group
addgroup -g "$LGID" -S "$GROUPNAME" 2>/dev/null || true
adduser -u "$LUID" -G "$GROUPNAME" -S -D -H "$USERNAME" 2>/dev/null || true
mkdir -p /home/$USERNAME
chown $USERNAME:$GROUPNAME /home/$USERNAME