1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

[BEEEP] Bitwarden Script uninstall option (#1796)

Co-authored-by: Vince Grassia <593223+vgrassia@users.noreply.github.com>
This commit is contained in:
Micaiah Martin
2022-02-23 14:35:36 -06:00
committed by GitHub
parent 52ddf55029
commit 156e10da0e
5 changed files with 95 additions and 0 deletions

View File

@ -4,6 +4,7 @@ set -e
# Setup
CYAN='\033[0;36m'
RED='\033[1;31m'
NC='\033[0m' # No Color
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@ -228,6 +229,46 @@ function update() {
dotnet Setup.dll -update 1 -os $OS -corev $COREVERSION -webv $WEBVERSION -keyconnectorv $KEYCONNECTORVERSION
}
function uninstall() {
echo -e -n "${RED}(WARNING: UNINSTALL STARTED) Would you like to save the database files? (y/n): ${NC}"
read KEEP_DATABASE
if [ "$KEEP_DATABASE" == "y" ]
then
echo "Saving database files."
tar -cvzf "./bitwarden_database.tar.gz" "$OUTPUT_DIR/mssql"
echo -e -n "${RED}(SAVED DATABASE FILES: YES): WARNING: ALL DATA WILL BE REMOVED, INCLUDING THE FOLDER $OUTPUT_DIR): Are you sure you want to uninstall Bitwarden? (y/n): ${NC}"
read UNINSTALL_ACTION
else
echo -e -n "${RED}WARNING: ALL DATA WILL BE REMOVED, INCLUDING THE FOLDER $OUTPUT_DIR): Are you sure you want to uninstall Bitwarden? (y/n): ${NC}"
read UNINSTALL_ACTION
fi
if [ "$UNINSTALL_ACTION" == "y" ]
then
echo "Uninstalling Bitwarden..."
dockerComposeDown
echo "Removing $OUTPUT_DIR"
rm -R $OUTPUT_DIR
echo "Removing MSSQL docker volume."
docker volume prune --force --filter="label=com.bitwarden.product=bitwarden"
echo "Bitwarden uninstall complete!"
else
echo -e -n "${CYAN}(!) Bitwarden uninstall canceled. ${NC}"
exit 1
fi
echo -e -n "${RED}(!) Would you like to purge all local Bitwarden container images? (y/n): ${NC}"
read PURGE_ACTION
if [ "$PURGE_ACTION" == "y" ]
then
dockerPrune
echo -e -n "${CYAN}Bitwarden uninstall complete! ${NC}"
fi
}
function printEnvironment() {
pullSetup
docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \
@ -285,6 +326,10 @@ case $1 in
updatebw
updateDatabase
;;
"uninstall")
dockerComposeFiles
uninstall
;;
"rebuild")
dockerComposeDown
update nopull