1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

making the bash script command sections a bit easier to read (#1085)

This commit is contained in:
Joseph Flinn 2021-01-21 11:49:40 -08:00 committed by GitHub
parent 2dc0fe3b31
commit 970712e014
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 101 additions and 95 deletions

View File

@ -103,53 +103,54 @@ EOT
# Commands
if [ "$1" == "install" ]
then
checkOutputDirNotExists
mkdir -p $OUTPUT
downloadRunFile
$SCRIPTS_DIR/run.sh install $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "start" -o "$1" == "restart" ]
then
checkOutputDirExists
$SCRIPTS_DIR/run.sh restart $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "update" ]
then
checkOutputDirExists
downloadRunFile
$SCRIPTS_DIR/run.sh update $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "rebuild" ]
then
checkOutputDirExists
$SCRIPTS_DIR/run.sh rebuild $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "updateconf" ]
then
checkOutputDirExists
$SCRIPTS_DIR/run.sh updateconf $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "updatedb" ]
then
checkOutputDirExists
$SCRIPTS_DIR/run.sh updatedb $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "stop" ]
then
checkOutputDirExists
$SCRIPTS_DIR/run.sh stop $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "renewcert" ]
then
checkOutputDirExists
$SCRIPTS_DIR/run.sh renewcert $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "updaterun" ]
then
checkOutputDirExists
downloadRunFile
elif [ "$1" == "updateself" ]
then
downloadSelf && echo "Updated self." && exit
elif [ "$1" == "help" ]
then
listCommands
else
echo "No command found."
echo
listCommands
fi
case $1 in
"install")
checkOutputDirNotExists
mkdir -p $OUTPUT
downloadRunFile
$SCRIPTS_DIR/run.sh install $OUTPUT $COREVERSION $WEBVERSION
;;
"start" | "restart")
checkOutputDirExists
$SCRIPTS_DIR/run.sh restart $OUTPUT $COREVERSION $WEBVERSION
;;
"update")
checkOutputDirExists
downloadRunFile
$SCRIPTS_DIR/run.sh update $OUTPUT $COREVERSION $WEBVERSION
;;
"rebuild")
checkOutputDirExists
$SCRIPTS_DIR/run.sh rebuild $OUTPUT $COREVERSION $WEBVERSION
;;
"updateconf")
checkOutputDirExists
$SCRIPTS_DIR/run.sh updateconf $OUTPUT $COREVERSION $WEBVERSION
;;
"updatedb")
checkOutputDirExists
$SCRIPTS_DIR/run.sh updatedb $OUTPUT $COREVERSION $WEBVERSION
;;
"stop")
checkOutputDirExists
$SCRIPTS_DIR/run.sh stop $OUTPUT $COREVERSION $WEBVERSION
;;
"renewcrt")
checkOutputDirExists
$SCRIPTS_DIR/run.sh renewcert $OUTPUT $COREVERSION $WEBVERSION
;;
"updaterun")
checkOutputDirExists
downloadRunFile
;;
"updateself")
downloadSelf && echo "Updated self." && exit
;;
"help")
listCommands
;;
*)
echo "No command found."
echo
listCommands
esac

View File

@ -172,6 +172,23 @@ function updateDatabase() {
echo "Database update complete"
}
function updatebw() {
CORE_ID=$(docker-compose ps -q admin)
WEB_ID=$(docker-compose ps -q web)
if docker inspect --format='{{.Config.Image}}:' $CORE_ID | grep -F ":$COREVERSION:" | grep -q ":[0-9.]*:$" &&
docker inspect --format='{{.Config.Image}}:' $WEB_ID | grep -F ":$WEBVERSION:" | grep -q ":[0-9.]*:$"
then
echo "Update not needed"
exit
fi
dockerComposeDown
update withpull
restart
dockerPrune
echo "Pausing 60 seconds for database to come online. Please wait..."
sleep 60
}
function update() {
if [ "$1" == "withpull" ]
then
@ -211,48 +228,36 @@ function pullSetup() {
# Commands
if [ "$1" == "install" ]
then
install
elif [ "$1" == "start" -o "$1" == "restart" ]
then
restart
elif [ "$1" == "pull" ]
then
dockerComposePull
elif [ "$1" == "stop" ]
then
dockerComposeDown
elif [ "$1" == "renewcert" ]
then
certRestart
elif [ "$1" == "updateconf" ]
then
dockerComposeDown
update withpull
elif [ "$1" == "updatedb" ]
then
updateDatabase
elif [ "$1" == "update" ]
then
dockerComposeFiles
CORE_ID=$(docker-compose ps -q admin)
WEB_ID=$(docker-compose ps -q web)
if docker inspect --format='{{.Config.Image}}:' $CORE_ID | grep -F ":$COREVERSION:" | grep -q ":[0-9.]*:$" &&
docker inspect --format='{{.Config.Image}}:' $WEB_ID | grep -F ":$WEBVERSION:" | grep -q ":[0-9.]*:$"
then
echo "Update not needed"
exit
fi
dockerComposeDown
update withpull
restart
dockerPrune
echo "Pausing 60 seconds for database to come online. Please wait..."
sleep 60
updateDatabase
elif [ "$1" == "rebuild" ]
then
dockerComposeDown
update nopull
fi
case $1 in
"install")
install
;;
"start" | "restart")
restart
;;
"pull")
dockerComposePull
;;
"stop")
dockerComposeDown
;;
"renewcert")
certRestart
;;
"updateconf")
dockerComposeDown
update withpull
;;
"updatedb")
updateDatabase
;;
"update")
dockerComposeFiles
updatebw
updateDatabase
;;
"rebuild")
dockerComposeDown
update nopull
;;
esac