2018-03-28 03:14:52 +02:00
|
|
|
#!/bin/bash
|
2017-08-07 22:31:00 +02:00
|
|
|
|
2018-03-28 04:57:30 +02:00
|
|
|
USERNAME="bitwarden"
|
|
|
|
NOUSER=`id -u $USERNAME > /dev/null 2>&1; echo $?`
|
2018-03-27 22:38:11 +02:00
|
|
|
LUID=${LOCAL_UID:-999}
|
2018-03-28 04:57:30 +02:00
|
|
|
|
|
|
|
# Step down from host root
|
|
|
|
if [ $LUID == 0 ]
|
|
|
|
then
|
|
|
|
LUID=999
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $NOUSER == 0 ] && [ `id -u $USERNAME` != $LUID ]
|
2018-03-27 22:38:11 +02:00
|
|
|
then
|
2018-03-28 04:57:30 +02:00
|
|
|
usermod -u $LUID $USERNAME
|
2018-03-27 22:38:11 +02:00
|
|
|
elif [ $NOUSER == 1 ]
|
|
|
|
then
|
2018-03-28 04:57:30 +02:00
|
|
|
useradd -r -u $LUID -g $USERNAME $USERNAME
|
2018-03-27 22:38:11 +02:00
|
|
|
fi
|
2018-03-27 20:55:33 +02:00
|
|
|
|
2018-04-03 03:11:32 +02:00
|
|
|
if [ ! -d "/home/$USERNAME" ]
|
|
|
|
then
|
|
|
|
mkhomedir_helper $USERNAME
|
|
|
|
fi
|
|
|
|
|
2018-03-28 04:57:30 +02:00
|
|
|
chown -R $USERNAME:$USERNAME /etc/bitwarden
|
2017-08-07 22:31:00 +02:00
|
|
|
cp /etc/bitwarden/nginx/default.conf /etc/nginx/conf.d/default.conf
|
2018-03-27 20:55:33 +02:00
|
|
|
mkdir -p /etc/letsencrypt
|
2018-03-28 04:57:30 +02:00
|
|
|
chown -R $USERNAME:$USERNAME /etc/letsencrypt
|
2018-03-27 20:55:33 +02:00
|
|
|
mkdir -p /etc/ssl
|
2018-03-28 04:57:30 +02:00
|
|
|
chown -R $USERNAME:$USERNAME /etc/ssl
|
2018-03-27 20:55:33 +02:00
|
|
|
touch /var/run/nginx.pid
|
2018-03-28 04:57:30 +02:00
|
|
|
chown -R $USERNAME:$USERNAME /var/run/nginx.pid
|
|
|
|
chown -R $USERNAME:$USERNAME /var/cache/nginx
|
|
|
|
chown -R $USERNAME:$USERNAME /var/log/nginx
|
2018-03-27 20:55:33 +02:00
|
|
|
|
2018-03-28 04:57:30 +02:00
|
|
|
gosu $USERNAME:$USERNAME nginx -g 'daemon off;'
|