mirror of
https://github.com/bitwarden/server.git
synced 2024-12-27 17:47:37 +01:00
40 lines
728 B
Bash
40 lines
728 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# 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
|
||
|
|
||
|
groupadd -o -g $LGID $GROUPNAME >/dev/null 2>&1 ||
|
||
|
groupmod -o -g $LGID $GROUPNAME >/dev/null 2>&1
|
||
|
useradd -o -u $LUID -g $GROUPNAME -s /bin/false $USERNAME >/dev/null 2>&1 ||
|
||
|
usermod -o -u $LUID -g $GROUPNAME -s /bin/false $USERNAME >/dev/null 2>&1
|
||
|
mkhomedir_helper $USERNAME
|