1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-25 17:27:45 +01:00
bitwarden-server/scripts/install.sh

79 lines
1.9 KiB
Bash
Raw Normal View History

2017-08-07 17:24:16 +02:00
#!/usr/bin/env bash
set -e
2018-03-30 16:01:01 +02:00
CYAN='\033[0;36m'
NC='\033[0m' # No Color
2017-08-20 03:45:13 +02:00
OUTPUT_DIR="../."
2017-11-09 06:18:35 +01:00
if [ $# -gt 0 ]
2017-08-19 22:17:32 +02:00
then
OUTPUT_DIR=$1
fi
2017-10-04 05:20:09 +02:00
2017-11-09 04:24:23 +01:00
COREVERSION="latest"
2017-11-09 06:18:35 +01:00
if [ $# -gt 1 ]
2017-11-09 04:24:23 +01:00
then
COREVERSION=$2
fi
WEBVERSION="latest"
2017-11-09 06:18:35 +01:00
if [ $# -gt 2 ]
2017-11-09 04:24:23 +01:00
then
WEBVERSION=$3
fi
OS="lin"
if [ "$(uname)" == "Darwin" ]
then
OS="mac"
fi
2017-10-04 05:20:09 +02:00
2018-04-16 21:30:07 +02:00
LUID="LOCAL_UID=`id -u $USER`"
LGID="LOCAL_GID=`getent group docker | cut -d: -f3`"
2017-08-11 21:05:50 +02:00
mkdir -p $OUTPUT_DIR
2017-08-08 21:48:45 +02:00
2017-08-21 17:21:40 +02:00
LETS_ENCRYPT="n"
2018-03-30 16:01:01 +02:00
echo -e -n "${CYAN}(!)${NC} Enter the domain name for your bitwarden instance (ex. bitwarden.company.com): "
read DOMAIN
echo ""
2017-08-07 17:24:16 +02:00
if [ "$DOMAIN" == "" ]
then
DOMAIN="localhost"
fi
2017-08-21 17:21:40 +02:00
if [ "$DOMAIN" != "localhost" ]
2017-08-08 21:48:45 +02:00
then
2018-03-30 16:07:16 +02:00
echo -e -n "${CYAN}(!)${NC} Do you want to use Let's Encrypt to generate a free SSL certificate? (y/n): "
2018-03-30 16:01:01 +02:00
read LETS_ENCRYPT
echo ""
2017-08-21 17:21:40 +02:00
if [ "$LETS_ENCRYPT" == "y" ]
then
2018-03-30 16:07:16 +02:00
echo -e -n "${CYAN}(!)${NC} Enter your email address (Let's Encrypt will send you certificate expiration reminders): "
2018-03-30 16:01:01 +02:00
read EMAIL
echo ""
2017-08-21 17:47:42 +02:00
mkdir -p $OUTPUT_DIR/letsencrypt
2017-08-27 04:54:10 +02:00
docker pull certbot/certbot
2017-08-21 17:21:40 +02:00
docker run -it --rm --name certbot -p 80:80 -v $OUTPUT_DIR/letsencrypt:/etc/letsencrypt/ certbot/certbot \
2017-08-21 17:47:42 +02:00
certonly --standalone --noninteractive --agree-tos --preferred-challenges http --email $EMAIL -d $DOMAIN \
--logs-dir /etc/letsencrypt/logs
2017-08-21 17:21:40 +02:00
fi
2017-08-08 21:48:45 +02:00
fi
2017-08-07 17:24:16 +02:00
2017-11-09 04:24:23 +01:00
docker pull bitwarden/setup:$COREVERSION
2018-03-27 20:55:33 +02:00
if [ $OS == "lin" ]
then
2018-04-16 21:30:07 +02:00
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden -e $LUID -e $LGID bitwarden/setup:$COREVERSION \
2018-03-27 20:55:33 +02:00
dotnet Setup.dll -install 1 -domain $DOMAIN -letsencrypt $LETS_ENCRYPT -os $OS -corev $COREVERSION -webv $WEBVERSION
else
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$COREVERSION \
dotnet Setup.dll -install 1 -domain $DOMAIN -letsencrypt $LETS_ENCRYPT -os $OS -corev $COREVERSION -webv $WEBVERSION
fi
2017-08-07 17:24:16 +02:00
2017-08-19 21:52:10 +02:00
echo ""
echo "Setup complete"
2018-03-30 16:01:01 +02:00
echo ""