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:15:42 +02:00
|
|
|
# Setup
|
|
|
|
|
2017-08-19 23:59:04 +02:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2021-12-14 16:25:55 +01:00
|
|
|
SCRIPT_NAME=$(basename "$0")
|
2017-08-23 22:22:02 +02:00
|
|
|
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
|
2022-02-24 16:36:59 +01:00
|
|
|
if command -v docker-compose &> /dev/null
|
|
|
|
then
|
|
|
|
dccmd='docker-compose'
|
|
|
|
else
|
|
|
|
dccmd='docker compose'
|
|
|
|
fi
|
2017-08-20 03:45:13 +02:00
|
|
|
|
|
|
|
SCRIPTS_DIR="$OUTPUT/scripts"
|
2019-01-19 04:23:46 +01:00
|
|
|
GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/server/master"
|
2021-05-17 20:51:29 +02:00
|
|
|
|
|
|
|
# Please do not create pull requests modifying the version numbers.
|
2022-02-17 22:05:30 +01:00
|
|
|
COREVERSION="1.46.2"
|
2022-02-15 21:40:47 +01:00
|
|
|
WEBVERSION="2.26.1"
|
|
|
|
KEYCONNECTORVERSION="1.0.1"
|
2017-08-20 03:45:13 +02:00
|
|
|
|
2020-12-18 18:33:12 +01:00
|
|
|
echo "bitwarden.sh version $COREVERSION"
|
|
|
|
docker --version
|
2022-02-24 16:36:59 +01:00
|
|
|
if [[ "$dccmd" == "docker compose" ]]; then
|
|
|
|
$dccmd version
|
|
|
|
else
|
|
|
|
$dccmd --version
|
|
|
|
fi
|
2020-12-18 18:33:12 +01:00
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
2017-08-23 22:15:42 +02:00
|
|
|
# Functions
|
|
|
|
|
|
|
|
function downloadSelf() {
|
2020-05-04 21:44:38 +02:00
|
|
|
if curl -s -w "http_code %{http_code}" -o $SCRIPT_PATH.1 $GITHUB_BASE_URL/scripts/bitwarden.sh | grep -q "^http_code 20[0-9]"
|
|
|
|
then
|
|
|
|
mv $SCRIPT_PATH.1 $SCRIPT_PATH
|
|
|
|
chmod u+x $SCRIPT_PATH
|
|
|
|
else
|
|
|
|
rm -f $SCRIPT_PATH.1
|
|
|
|
fi
|
2017-08-23 22:15:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2018-05-31 18:05:26 +02:00
|
|
|
rm -f $SCRIPTS_DIR/install.sh
|
2017-08-23 22:15:42 +02:00
|
|
|
}
|
|
|
|
|
2017-09-18 18:11:03 +02:00
|
|
|
function checkOutputDirExists() {
|
|
|
|
if [ ! -d "$OUTPUT" ]
|
|
|
|
then
|
2018-06-01 03:47:06 +02:00
|
|
|
echo "Cannot find a Bitwarden installation at $OUTPUT."
|
2017-09-18 18:11:03 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkOutputDirNotExists() {
|
2018-07-26 21:29:46 +02:00
|
|
|
if [ -d "$OUTPUT/docker" ]
|
2017-09-18 18:11:03 +02:00
|
|
|
then
|
2018-06-01 03:47:06 +02:00
|
|
|
echo "Looks like Bitwarden is already installed at $OUTPUT."
|
2017-09-18 18:11:03 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-10-25 02:04:09 +02:00
|
|
|
function listCommands() {
|
2019-10-25 01:56:41 +02:00
|
|
|
cat << EOT
|
|
|
|
Available commands:
|
|
|
|
|
|
|
|
install
|
2019-10-25 02:04:09 +02:00
|
|
|
start
|
|
|
|
restart
|
|
|
|
stop
|
2019-10-25 01:56:41 +02:00
|
|
|
update
|
|
|
|
updatedb
|
2020-01-13 15:47:59 +01:00
|
|
|
updaterun
|
2019-10-25 01:56:41 +02:00
|
|
|
updateself
|
2019-10-25 02:04:09 +02:00
|
|
|
updateconf
|
2022-02-23 21:35:36 +01:00
|
|
|
uninstall
|
2020-06-17 15:05:35 +02:00
|
|
|
renewcert
|
2019-10-25 02:04:09 +02:00
|
|
|
rebuild
|
|
|
|
help
|
|
|
|
|
2021-03-10 14:36:06 +01:00
|
|
|
See more at https://bitwarden.com/help/article/install-on-premise/#script-commands-reference
|
2019-10-25 01:56:41 +02:00
|
|
|
|
|
|
|
EOT
|
|
|
|
}
|
|
|
|
|
2017-08-23 22:15:42 +02:00
|
|
|
# Commands
|
|
|
|
|
2021-01-21 20:49:40 +01:00
|
|
|
case $1 in
|
|
|
|
"install")
|
|
|
|
checkOutputDirNotExists
|
|
|
|
mkdir -p $OUTPUT
|
|
|
|
downloadRunFile
|
2021-12-29 17:07:16 +01:00
|
|
|
$SCRIPTS_DIR/run.sh install $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
|
2021-01-21 20:49:40 +01:00
|
|
|
;;
|
|
|
|
"start" | "restart")
|
|
|
|
checkOutputDirExists
|
2021-12-29 17:07:16 +01:00
|
|
|
$SCRIPTS_DIR/run.sh restart $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
|
2021-01-21 20:49:40 +01:00
|
|
|
;;
|
|
|
|
"update")
|
|
|
|
checkOutputDirExists
|
|
|
|
downloadRunFile
|
2021-12-29 17:07:16 +01:00
|
|
|
$SCRIPTS_DIR/run.sh update $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
|
2021-01-21 20:49:40 +01:00
|
|
|
;;
|
|
|
|
"rebuild")
|
|
|
|
checkOutputDirExists
|
2021-12-29 17:07:16 +01:00
|
|
|
$SCRIPTS_DIR/run.sh rebuild $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
|
2021-01-21 20:49:40 +01:00
|
|
|
;;
|
|
|
|
"updateconf")
|
|
|
|
checkOutputDirExists
|
2021-12-29 17:07:16 +01:00
|
|
|
$SCRIPTS_DIR/run.sh updateconf $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
|
2021-01-21 20:49:40 +01:00
|
|
|
;;
|
|
|
|
"updatedb")
|
|
|
|
checkOutputDirExists
|
2021-12-29 17:07:16 +01:00
|
|
|
$SCRIPTS_DIR/run.sh updatedb $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
|
2021-01-21 20:49:40 +01:00
|
|
|
;;
|
|
|
|
"stop")
|
|
|
|
checkOutputDirExists
|
2021-12-29 17:07:16 +01:00
|
|
|
$SCRIPTS_DIR/run.sh stop $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
|
2021-01-21 20:49:40 +01:00
|
|
|
;;
|
2021-02-02 15:23:38 +01:00
|
|
|
"renewcert")
|
2021-01-21 20:49:40 +01:00
|
|
|
checkOutputDirExists
|
2021-12-29 17:07:16 +01:00
|
|
|
$SCRIPTS_DIR/run.sh renewcert $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
|
2021-01-21 20:49:40 +01:00
|
|
|
;;
|
|
|
|
"updaterun")
|
|
|
|
checkOutputDirExists
|
|
|
|
downloadRunFile
|
|
|
|
;;
|
|
|
|
"updateself")
|
|
|
|
downloadSelf && echo "Updated self." && exit
|
|
|
|
;;
|
2022-02-23 21:35:36 +01:00
|
|
|
"uninstall")
|
|
|
|
checkOutputDirExists
|
|
|
|
$SCRIPTS_DIR/run.sh uninstall $OUTPUT
|
|
|
|
;;
|
2021-01-21 20:49:40 +01:00
|
|
|
"help")
|
|
|
|
listCommands
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "No command found."
|
|
|
|
echo
|
|
|
|
listCommands
|
|
|
|
esac
|