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
|
|
|
|
|
2017-08-23 22:15:42 +02:00
|
|
|
===================================================
|
|
|
|
|
2017-08-19 23:59:04 +02:00
|
|
|
EOF
|
|
|
|
|
2017-08-23 22:29:55 +02:00
|
|
|
docker --version
|
|
|
|
docker-compose --version
|
|
|
|
|
2017-08-23 22:33:41 +02:00
|
|
|
echo ""
|
|
|
|
|
2017-08-23 22:15:42 +02:00
|
|
|
# Setup
|
|
|
|
|
2017-08-19 23:59:04 +02:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2017-08-23 22:22:02 +02:00
|
|
|
SCRIPT_NAME=`basename "$0"`
|
|
|
|
SCRIPT_PATH="$DIR/$SCRIPT_NAME"
|
2017-10-03 22:34:39 +02:00
|
|
|
OUTPUT="$DIR/bwdata"
|
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
|
|
|
|
|
|
|
|
SCRIPTS_DIR="$OUTPUT/scripts"
|
2017-08-19 23:59:04 +02:00
|
|
|
GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/core/master"
|
2018-04-03 03:35:08 +02:00
|
|
|
COREVERSION="1.18.1"
|
|
|
|
WEBVERSION="1.25.1"
|
2017-08-20 03:45:13 +02:00
|
|
|
|
2017-08-23 22:15:42 +02:00
|
|
|
# Functions
|
|
|
|
|
|
|
|
function downloadSelf() {
|
2017-08-23 22:22:02 +02:00
|
|
|
curl -s -o $SCRIPT_PATH $GITHUB_BASE_URL/scripts/bitwarden.sh
|
|
|
|
chmod u+x $SCRIPT_PATH
|
2017-08-23 22:15:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function downloadInstall() {
|
2017-09-18 18:11:03 +02:00
|
|
|
if [ ! -d "$SCRIPTS_DIR" ]
|
|
|
|
then
|
|
|
|
mkdir $SCRIPTS_DIR
|
|
|
|
fi
|
2017-08-23 22:15:42 +02:00
|
|
|
curl -s -o $SCRIPTS_DIR/install.sh $GITHUB_BASE_URL/scripts/install.sh
|
|
|
|
chmod u+x $SCRIPTS_DIR/install.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
function downloadRunFile() {
|
2017-09-18 18:11:03 +02:00
|
|
|
if [ ! -d "$SCRIPTS_DIR" ]
|
|
|
|
then
|
|
|
|
mkdir $SCRIPTS_DIR
|
|
|
|
fi
|
2017-08-23 22:15:42 +02:00
|
|
|
curl -s -o $SCRIPTS_DIR/run.sh $GITHUB_BASE_URL/scripts/run.sh
|
|
|
|
chmod u+x $SCRIPTS_DIR/run.sh
|
|
|
|
}
|
|
|
|
|
2017-09-18 18:11:03 +02:00
|
|
|
function checkOutputDirExists() {
|
|
|
|
if [ ! -d "$OUTPUT" ]
|
|
|
|
then
|
|
|
|
echo "Cannot find a bitwarden installation at $OUTPUT."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkOutputDirNotExists() {
|
|
|
|
if [ -d "$OUTPUT" ]
|
|
|
|
then
|
|
|
|
echo "Looks like bitwarden is already installed at $OUTPUT."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-08-23 22:15:42 +02:00
|
|
|
# Commands
|
|
|
|
|
2017-08-20 03:55:34 +02:00
|
|
|
if [ "$1" == "install" ]
|
2017-08-19 23:59:04 +02:00
|
|
|
then
|
2017-09-18 18:11:03 +02:00
|
|
|
checkOutputDirNotExists
|
|
|
|
mkdir $OUTPUT
|
2017-08-23 22:15:42 +02:00
|
|
|
downloadInstall
|
2017-11-09 05:51:24 +01:00
|
|
|
downloadRunFile
|
2017-11-09 04:24:23 +01:00
|
|
|
$SCRIPTS_DIR/install.sh $OUTPUT $COREVERSION $WEBVERSION
|
2017-08-21 17:58:15 +02:00
|
|
|
elif [ "$1" == "start" -o "$1" == "restart" ]
|
2017-08-19 23:59:04 +02:00
|
|
|
then
|
2017-09-18 18:11:03 +02:00
|
|
|
checkOutputDirExists
|
2017-11-09 04:24:23 +01:00
|
|
|
$SCRIPTS_DIR/run.sh restart $OUTPUT $COREVERSION $WEBVERSION
|
2017-08-20 03:55:34 +02:00
|
|
|
elif [ "$1" == "update" ]
|
2017-08-19 23:59:04 +02:00
|
|
|
then
|
2017-09-18 18:11:03 +02:00
|
|
|
checkOutputDirExists
|
2017-11-09 04:24:23 +01:00
|
|
|
downloadRunFile
|
|
|
|
$SCRIPTS_DIR/run.sh update $OUTPUT $COREVERSION $WEBVERSION
|
2017-08-20 03:55:34 +02:00
|
|
|
elif [ "$1" == "updatedb" ]
|
2017-08-19 23:59:04 +02:00
|
|
|
then
|
2017-09-18 18:11:03 +02:00
|
|
|
checkOutputDirExists
|
2017-11-09 04:24:23 +01:00
|
|
|
$SCRIPTS_DIR/run.sh updatedb $OUTPUT $COREVERSION $WEBVERSION
|
2017-08-21 15:39:12 +02:00
|
|
|
elif [ "$1" == "stop" ]
|
|
|
|
then
|
2017-09-18 18:11:03 +02:00
|
|
|
checkOutputDirExists
|
2017-11-09 04:24:23 +01:00
|
|
|
$SCRIPTS_DIR/run.sh stop $OUTPUT $COREVERSION $WEBVERSION
|
2017-08-23 22:15:42 +02:00
|
|
|
elif [ "$1" == "updateself" ]
|
|
|
|
then
|
|
|
|
downloadSelf
|
|
|
|
echo "Updated self."
|
2017-08-19 23:59:04 +02:00
|
|
|
else
|
|
|
|
echo "No command found."
|
|
|
|
fi
|