1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00
bitwarden-server/util/Nginx/entrypoint.sh

48 lines
1.1 KiB
Bash
Raw Normal View History

2018-03-28 03:14:52 +02:00
#!/bin/bash
2017-08-07 22:31:00 +02:00
2018-04-16 21:30:07 +02:00
# Setup
GROUPNAME="bitwarden"
2018-03-28 04:57:30 +02:00
USERNAME="bitwarden"
2018-04-16 21:30:07 +02:00
LUID=${LOCAL_UID:-0}
LGID=${LOCAL_GID:-0}
2018-04-16 21:30:07 +02:00
# Step down from host root to well-known nobody/nogroup user
2018-03-28 04:57:30 +02:00
if [ $LUID -eq 0 ]
2018-04-16 21:30:07 +02:00
then
LUID=65534
2018-04-16 21:30:07 +02:00
fi
if [ $LGID -eq 0 ]
2018-03-28 04:57:30 +02:00
then
LGID=65534
2018-03-28 04:57:30 +02:00
fi
# Create user and group
2018-04-16 21:30:07 +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-03 03:11:32 +02:00
2018-04-16 21:30:07 +02:00
# The rest...
chown -R $USERNAME:$GROUPNAME /etc/bitwarden
2021-02-11 22:11:36 +01:00
cp /etc/bitwarden/nginx/*.conf /etc/nginx/conf.d/
2018-03-27 20:55:33 +02:00
mkdir -p /etc/letsencrypt
2018-04-16 21:30:07 +02:00
chown -R $USERNAME:$GROUPNAME /etc/letsencrypt
2018-03-27 20:55:33 +02:00
mkdir -p /etc/ssl
2018-04-16 21:30:07 +02:00
chown -R $USERNAME:$GROUPNAME /etc/ssl
mkdir -p /var/run/nginx
touch /var/run/nginx/nginx.pid
chown -R $USERNAME:$GROUPNAME /var/run/nginx
2018-04-16 21:30:07 +02:00
chown -R $USERNAME:$GROUPNAME /var/cache/nginx
chown -R $USERNAME:$GROUPNAME /var/log/nginx
2018-03-27 20:55:33 +02:00
# Launch a loop to rotate nginx logs on a daily basis
2019-11-25 15:25:11 +01:00
gosu $USERNAME:$GROUPNAME /bin/sh -c "/logrotate.sh loop >/dev/null 2>&1 &"
exec gosu $USERNAME:$GROUPNAME nginx -g 'daemon off;'