From 62535ae7505a134d86cbb3e274f20095671b4004 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 27 Mar 2018 16:38:11 -0400 Subject: [PATCH] upsert bitwarden user --- src/Admin/entrypoint.sh | 10 +++++++++- src/Api/entrypoint.sh | 10 +++++++++- src/Icons/entrypoint.sh | 10 +++++++++- src/Identity/entrypoint.sh | 10 +++++++++- util/Attachments/entrypoint.sh | 10 +++++++++- util/MsSql/entrypoint.sh | 10 +++++++++- util/Nginx/entrypoint.sh | 12 ++++++++++-- util/Setup/entrypoint.sh | 12 ++++++++++-- 8 files changed, 74 insertions(+), 10 deletions(-) diff --git a/src/Admin/entrypoint.sh b/src/Admin/entrypoint.sh index 5a24189f28..f15b668e99 100644 --- a/src/Admin/entrypoint.sh +++ b/src/Admin/entrypoint.sh @@ -1,6 +1,14 @@ #!/bin/sh -useradd -r -u ${LOCAL_UID:-999} -g bitwarden bitwarden +NOUSER=`id -u bitwarden > /dev/null 2>&1; echo $?` +LUID=${LOCAL_UID:-999} +if [[ $NOUSER == 0 && `id -u bitwarden` != $LUID ]] +then + usermod -u $LUID bitwarden +elif [ $NOUSER == 1 ] +then + useradd -r -u $LUID -g bitwarden bitwarden +fi chown -R bitwarden:bitwarden /app mkdir -p /etc/bitwarden/core diff --git a/src/Api/entrypoint.sh b/src/Api/entrypoint.sh index 3340be248c..cbae3eb963 100644 --- a/src/Api/entrypoint.sh +++ b/src/Api/entrypoint.sh @@ -1,6 +1,14 @@ #!/bin/sh -useradd -r -u ${LOCAL_UID:-999} -g bitwarden bitwarden +NOUSER=`id -u bitwarden > /dev/null 2>&1; echo $?` +LUID=${LOCAL_UID:-999} +if [[ $NOUSER == 0 && `id -u bitwarden` != $LUID ]] +then + usermod -u $LUID bitwarden +elif [ $NOUSER == 1 ] +then + useradd -r -u $LUID -g bitwarden bitwarden +fi touch /var/log/cron.log chown bitwarden:bitwarden /var/log/cron.log diff --git a/src/Icons/entrypoint.sh b/src/Icons/entrypoint.sh index e018a0619f..e6af146c8c 100644 --- a/src/Icons/entrypoint.sh +++ b/src/Icons/entrypoint.sh @@ -1,6 +1,14 @@ #!/bin/sh -useradd -r -u ${LOCAL_UID:-999} -g bitwarden bitwarden +NOUSER=`id -u bitwarden > /dev/null 2>&1; echo $?` +LUID=${LOCAL_UID:-999} +if [[ $NOUSER == 0 && `id -u bitwarden` != $LUID ]] +then + usermod -u $LUID bitwarden +elif [ $NOUSER == 1 ] +then + useradd -r -u $LUID -g bitwarden bitwarden +fi chown -R bitwarden:bitwarden /app chown -R bitwarden:bitwarden /etc/iconserver diff --git a/src/Identity/entrypoint.sh b/src/Identity/entrypoint.sh index bdd40c6017..7b68b28e0f 100644 --- a/src/Identity/entrypoint.sh +++ b/src/Identity/entrypoint.sh @@ -1,6 +1,14 @@ #!/bin/sh -useradd -r -u ${LOCAL_UID:-999} -g bitwarden bitwarden +NOUSER=`id -u bitwarden > /dev/null 2>&1; echo $?` +LUID=${LOCAL_UID:-999} +if [[ $NOUSER == 0 && `id -u bitwarden` != $LUID ]] +then + usermod -u $LUID bitwarden +elif [ $NOUSER == 1 ] +then + useradd -r -u $LUID -g bitwarden bitwarden +fi mkdir -p /etc/bitwarden/identity mkdir -p /etc/bitwarden/core diff --git a/util/Attachments/entrypoint.sh b/util/Attachments/entrypoint.sh index fd0805f4e6..96d45465c9 100644 --- a/util/Attachments/entrypoint.sh +++ b/util/Attachments/entrypoint.sh @@ -1,6 +1,14 @@ #!/bin/sh -useradd -r -u ${LOCAL_UID:-999} -g bitwarden bitwarden +NOUSER=`id -u bitwarden > /dev/null 2>&1; echo $?` +LUID=${LOCAL_UID:-999} +if [[ $NOUSER == 0 && `id -u bitwarden` != $LUID ]] +then + usermod -u $LUID bitwarden +elif [ $NOUSER == 1 ] +then + useradd -r -u $LUID -g bitwarden bitwarden +fi chown -R bitwarden:bitwarden /bitwarden_server mkdir -p /etc/bitwarden/core/attachments diff --git a/util/MsSql/entrypoint.sh b/util/MsSql/entrypoint.sh index 36d324f63c..e2cab95c2d 100644 --- a/util/MsSql/entrypoint.sh +++ b/util/MsSql/entrypoint.sh @@ -1,6 +1,14 @@ #!/bin/sh -useradd -r -u ${LOCAL_UID:-999} -g bitwarden bitwarden +NOUSER=`id -u bitwarden > /dev/null 2>&1; echo $?` +LUID=${LOCAL_UID:-999} +if [[ $NOUSER == 0 && `id -u bitwarden` != $LUID ]] +then + usermod -u $LUID bitwarden +elif [ $NOUSER == 1 ] +then + useradd -r -u $LUID -g bitwarden bitwarden +fi touch /var/log/cron.log chown bitwarden:bitwarden /var/log/cron.log diff --git a/util/Nginx/entrypoint.sh b/util/Nginx/entrypoint.sh index cb2c8f312d..67ea05f9de 100644 --- a/util/Nginx/entrypoint.sh +++ b/util/Nginx/entrypoint.sh @@ -1,6 +1,14 @@ #!/usr/bin/env bash -useradd -r -u ${LOCAL_UID:-999} -g bitwarden bitwarden +NOUSER=`id -u bitwarden > /dev/null 2>&1; echo $?` +LUID=${LOCAL_UID:-999} +if [[ $NOUSER == 0 && `id -u bitwarden` != $LUID ]] +then + usermod -u $LUID bitwarden +elif [ $NOUSER == 1 ] +then + useradd -r -u $LUID -g bitwarden bitwarden +fi chown -R bitwarden:bitwarden /etc/bitwarden cp /etc/bitwarden/nginx/default.conf /etc/nginx/conf.d/default.conf @@ -9,7 +17,7 @@ chown -R bitwarden:bitwarden /etc/letsencrypt mkdir -p /etc/ssl chown -R bitwarden:bitwarden /etc/ssl touch /var/run/nginx.pid -chown bitwarden:bitwarden /var/run/nginx.pid +chown -R bitwarden:bitwarden /var/run/nginx.pid chown -R bitwarden:bitwarden /var/cache/nginx gosu bitwarden:bitwarden nginx -g 'daemon off;' diff --git a/util/Setup/entrypoint.sh b/util/Setup/entrypoint.sh index e6e5761728..9a8169d245 100644 --- a/util/Setup/entrypoint.sh +++ b/util/Setup/entrypoint.sh @@ -1,6 +1,14 @@ #!/bin/bash -useradd -r -u ${LOCAL_UID:-999} -g bitwarden bitwarden +NOUSER=`id -u bitwarden > /dev/null 2>&1; echo $?` +LUID=${LOCAL_UID:-999} +if [[ $NOUSER == 0 && `id -u bitwarden` != $LUID ]] +then + usermod -u $LUID bitwarden +elif [ $NOUSER == 1 ] +then + useradd -r -u $LUID -g bitwarden bitwarden +fi chown -R bitwarden:bitwarden /app mkdir -p /bitwarden/env @@ -11,4 +19,4 @@ mkdir -p /bitwarden/identity mkdir -p /bitwarden/nginx chown -R bitwarden:bitwarden /bitwarden -exec /usr/local/bin/gosu bitwarden:bitwarden "$@" +exec gosu bitwarden:bitwarden "$@"