diff --git a/scripts/bitwarden.sh b/scripts/bitwarden.sh index 2c9da3d32..037dc7f43 100755 --- a/scripts/bitwarden.sh +++ b/scripts/bitwarden.sh @@ -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 diff --git a/scripts/run.sh b/scripts/run.sh index 0fdca4524..566ca25c5 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -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