2018-03-27 21:15:16 -04:00
|
|
|
#!/bin/bash
|
2017-08-07 17:07:56 -04:00
|
|
|
|
2018-04-16 15:17:13 -04:00
|
|
|
# Setup
|
|
|
|
|
|
|
|
GROUPNAME="bitwarden"
|
2018-03-27 22:56:50 -04:00
|
|
|
USERNAME="bitwarden"
|
2018-04-16 15:17:13 -04:00
|
|
|
|
2018-05-29 22:46:04 +02:00
|
|
|
LUID=${LOCAL_UID:-0}
|
|
|
|
LGID=${LOCAL_GID:-0}
|
2018-04-16 15:17:13 -04:00
|
|
|
|
2018-05-29 22:46:04 +02:00
|
|
|
# Step down from host root to well-known nobody/nogroup user
|
2018-03-27 22:56:50 -04:00
|
|
|
|
2018-05-29 22:46:04 +02:00
|
|
|
if [ $LUID -eq 0 ]
|
2018-04-16 15:17:13 -04:00
|
|
|
then
|
2018-05-29 22:46:04 +02:00
|
|
|
LUID=65534
|
2018-04-16 15:17:13 -04:00
|
|
|
fi
|
2018-05-29 22:46:04 +02:00
|
|
|
if [ $LGID -eq 0 ]
|
2018-03-27 22:56:50 -04:00
|
|
|
then
|
2018-05-29 22:46:04 +02:00
|
|
|
LGID=65534
|
2018-03-27 22:56:50 -04:00
|
|
|
fi
|
|
|
|
|
2018-05-29 22:46:04 +02:00
|
|
|
# Create user and group
|
2018-04-16 15:17:13 -04:00
|
|
|
|
2018-05-29 22:46:04 +02:00
|
|
|
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
|
2018-04-02 21:12:45 -04:00
|
|
|
|
2018-04-16 15:17:13 -04:00
|
|
|
# The rest...
|
|
|
|
|
|
|
|
chown -R $USERNAME:$GROUPNAME /etc/bitwarden
|
2017-08-08 00:44:58 -04:00
|
|
|
cp /etc/bitwarden/web/app-id.json /app/app-id.json
|
2018-04-16 15:17:13 -04:00
|
|
|
chown -R $USERNAME:$GROUPNAME /app
|
|
|
|
chown -R $USERNAME:$GROUPNAME /bitwarden_server
|
2018-03-27 15:44:25 -04:00
|
|
|
|
2018-05-29 22:46:04 +02:00
|
|
|
exec gosu $USERNAME:$GROUPNAME dotnet /bitwarden_server/Server.dll \
|
2018-08-07 15:04:30 -04:00
|
|
|
/contentRoot=/app /webRoot=. /serveUnknown=false /webVault=true
|