1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00
bitwarden-server/scripts/bitwarden.sh

87 lines
2.1 KiB
Bash
Raw Normal View History

2017-08-19 23:59:04 +02:00
#!/usr/bin/env bash
set -e
cat << "EOF"
_ _ _ _
| |__ (_) |___ ____ _ _ __ __| | ___ _ __
| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \
| |_) | | |_ \ V V / (_| | | | (_| | __/ | | |
|_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|
EOF
cat << EOF
Open source password management solutions
2017-08-20 03:45:13 +02:00
Copyright 2015-$(date +'%Y'), 8bit Solutions LLC
2017-08-19 23:59:04 +02:00
https://bitwarden.com, https://github.com/bitwarden
EOF
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2017-08-20 03:45:13 +02:00
OUTPUT="$DIR/bitwarden"
2017-08-21 14:49:44 +02:00
if [ $# -eq 2 ]
2017-08-20 03:45:13 +02:00
then
2017-08-21 14:49:44 +02:00
OUTPUT=$2
2017-08-20 03:45:13 +02:00
fi
if [ ! -d "$OUTPUT" ]
then
mkdir $OUTPUT
fi
2017-08-21 14:49:44 +02:00
OS="linux"
if [ "$(uname)" == "Darwin" ]
then
OS="macwin"
fi
2017-08-20 03:45:13 +02:00
SCRIPTS_DIR="$OUTPUT/scripts"
2017-08-20 04:40:21 +02:00
DOCKER_DIR="$OUTPUT/docker"
2017-08-19 23:59:04 +02:00
GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/core/master"
2017-08-20 03:45:13 +02:00
if [ ! -d "$SCRIPTS_DIR" ]
2017-08-19 23:59:04 +02:00
then
2017-08-20 03:45:13 +02:00
mkdir $SCRIPTS_DIR
2017-08-19 23:59:04 +02:00
fi
2017-08-20 03:45:13 +02:00
function downloadRunFiles() {
2017-08-20 04:57:06 +02:00
curl -s -o $SCRIPTS_DIR/run.sh $GITHUB_BASE_URL/scripts/run.sh
2017-08-20 03:47:15 +02:00
chmod u+x $SCRIPTS_DIR/run.sh
2017-08-19 23:59:04 +02:00
curl -s -o $DOCKER_DIR/docker-compose.yml $GITHUB_BASE_URL/docker/docker-compose.yml
2017-08-20 03:45:13 +02:00
curl -s -o $DOCKER_DIR/docker-compose.$OS.yml $GITHUB_BASE_URL/docker/docker-compose.$OS.yml
2017-08-19 23:59:04 +02:00
curl -s -o $DOCKER_DIR/global.env $GITHUB_BASE_URL/docker/global.env
curl -s -o $DOCKER_DIR/mssql.env $GITHUB_BASE_URL/docker/mssql.env
}
2017-08-20 03:55:34 +02:00
if [ "$1" == "install" ]
2017-08-19 23:59:04 +02:00
then
2017-08-20 03:45:13 +02:00
curl -s -o $SCRIPTS_DIR/install.sh $GITHUB_BASE_URL/scripts/install.sh
chmod u+x $SCRIPTS_DIR/install.sh
$SCRIPTS_DIR/install.sh $OUTPUT
2017-08-20 03:55:34 +02:00
elif [ "$1" == "run" -o "$1" == "restart" ]
2017-08-19 23:59:04 +02:00
then
2017-08-20 03:45:13 +02:00
if [ ! -d "$DOCKER_DIR" ]
then
mkdir $DOCKER_DIR
downloadRunFiles
fi
2017-08-21 14:49:44 +02:00
$SCRIPTS_DIR/run.sh $DOCKER_DIR
2017-08-20 03:55:34 +02:00
elif [ "$1" == "update" ]
2017-08-19 23:59:04 +02:00
then
2017-08-20 03:45:13 +02:00
if [ -d "$DOCKER_DIR" ]
then
rm -rf $DOCKER_DIR
fi
mkdir $DOCKER_DIR
downloadRunFiles
2017-08-21 14:49:44 +02:00
$SCRIPTS_DIR/run.sh $DOCKER_DIR
2017-08-20 03:55:34 +02:00
elif [ "$1" == "updatedb" ]
2017-08-19 23:59:04 +02:00
then
2017-08-20 03:45:13 +02:00
curl -s -o $SCRIPTS_DIR/update-db.sh $GITHUB_BASE_URL/scripts/update-db.sh
chmod u+x $SCRIPTS_DIR/update-db.sh
$SCRIPTS_DIR/update-db.sh $OUTPUT
2017-08-19 23:59:04 +02:00
else
echo "No command found."
fi