Files
server/scripts/bitwarden.sh

111 lines
2.5 KiB
Bash
Raw Normal View History

2017-08-19 17:59:04 -04:00
#!/usr/bin/env bash
set -e
cat << "EOF"
_ _ _ _
| |__ (_) |___ ____ _ _ __ __| | ___ _ __
| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \
| |_) | | |_ \ V V / (_| | | | (_| | __/ | | |
|_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|
EOF
cat << EOF
Open source password management solutions
2017-08-19 21:45:13 -04:00
Copyright 2015-$(date +'%Y'), 8bit Solutions LLC
2017-08-19 17:59:04 -04:00
https://bitwarden.com, https://github.com/bitwarden
2017-08-23 16:15:42 -04:00
===================================================
2017-08-19 17:59:04 -04:00
EOF
2017-08-23 16:29:55 -04:00
docker --version
docker-compose --version
2017-08-23 16:33:41 -04:00
echo ""
2017-08-23 16:15:42 -04:00
# Setup
2017-08-19 17:59:04 -04:00
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2017-08-23 16:22:02 -04:00
SCRIPT_NAME=`basename "$0"`
SCRIPT_PATH="$DIR/$SCRIPT_NAME"
2017-10-03 16:34:39 -04:00
OUTPUT="$DIR/bwdata"
2017-08-21 08:49:44 -04:00
if [ $# -eq 2 ]
2017-08-19 21:45:13 -04:00
then
2017-08-21 08:49:44 -04:00
OUTPUT=$2
2017-08-19 21:45:13 -04:00
fi
SCRIPTS_DIR="$OUTPUT/scripts"
2019-01-18 22:23:46 -05:00
GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/server/master"
2019-07-27 22:46:34 -04:00
COREVERSION="1.31.1"
WEBVERSION="2.11.0"
2017-08-19 21:45:13 -04:00
2017-08-23 16:15:42 -04:00
# Functions
function downloadSelf() {
2017-08-23 16:22:02 -04:00
curl -s -o $SCRIPT_PATH $GITHUB_BASE_URL/scripts/bitwarden.sh
chmod u+x $SCRIPT_PATH
2017-08-23 16:15:42 -04:00
}
function downloadRunFile() {
2017-09-18 12:11:03 -04:00
if [ ! -d "$SCRIPTS_DIR" ]
then
mkdir $SCRIPTS_DIR
fi
2017-08-23 16:15:42 -04:00
curl -s -o $SCRIPTS_DIR/run.sh $GITHUB_BASE_URL/scripts/run.sh
chmod u+x $SCRIPTS_DIR/run.sh
rm -f $SCRIPTS_DIR/install.sh
2017-08-23 16:15:42 -04:00
}
2017-09-18 12:11:03 -04:00
function checkOutputDirExists() {
if [ ! -d "$OUTPUT" ]
then
2018-05-31 21:47:06 -04:00
echo "Cannot find a Bitwarden installation at $OUTPUT."
2017-09-18 12:11:03 -04:00
exit 1
fi
}
function checkOutputDirNotExists() {
if [ -d "$OUTPUT/docker" ]
2017-09-18 12:11:03 -04:00
then
2018-05-31 21:47:06 -04:00
echo "Looks like Bitwarden is already installed at $OUTPUT."
2017-09-18 12:11:03 -04:00
exit 1
fi
}
2017-08-23 16:15:42 -04:00
# Commands
2017-08-19 21:55:34 -04:00
if [ "$1" == "install" ]
2017-08-19 17:59:04 -04:00
then
2017-09-18 12:11:03 -04:00
checkOutputDirNotExists
mkdir -p $OUTPUT
2017-11-08 23:51:24 -05:00
downloadRunFile
$SCRIPTS_DIR/run.sh install $OUTPUT $COREVERSION $WEBVERSION
2017-08-21 11:58:15 -04:00
elif [ "$1" == "start" -o "$1" == "restart" ]
2017-08-19 17:59:04 -04:00
then
2017-09-18 12:11:03 -04:00
checkOutputDirExists
2017-11-08 22:24:23 -05:00
$SCRIPTS_DIR/run.sh restart $OUTPUT $COREVERSION $WEBVERSION
2017-08-19 21:55:34 -04:00
elif [ "$1" == "update" ]
2017-08-19 17:59:04 -04:00
then
2017-09-18 12:11:03 -04:00
checkOutputDirExists
2017-11-08 22:24:23 -05:00
downloadRunFile
$SCRIPTS_DIR/run.sh update $OUTPUT $COREVERSION $WEBVERSION
2018-08-30 16:25:33 -04:00
elif [ "$1" == "rebuild" ]
then
checkOutputDirExists
$SCRIPTS_DIR/run.sh rebuild $OUTPUT $COREVERSION $WEBVERSION
2017-08-19 21:55:34 -04:00
elif [ "$1" == "updatedb" ]
2017-08-19 17:59:04 -04:00
then
2017-09-18 12:11:03 -04:00
checkOutputDirExists
2017-11-08 22:24:23 -05:00
$SCRIPTS_DIR/run.sh updatedb $OUTPUT $COREVERSION $WEBVERSION
2017-08-21 09:39:12 -04:00
elif [ "$1" == "stop" ]
then
2017-09-18 12:11:03 -04:00
checkOutputDirExists
2017-11-08 22:24:23 -05:00
$SCRIPTS_DIR/run.sh stop $OUTPUT $COREVERSION $WEBVERSION
2017-08-23 16:15:42 -04:00
elif [ "$1" == "updateself" ]
then
downloadSelf && echo "Updated self." && exit
2017-08-19 17:59:04 -04:00
else
echo "No command found."
fi