1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-01 23:31:41 +01: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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 95 additions and 0 deletions

View File

@ -10,6 +10,7 @@ param (
[switch] $updatedb,
[switch] $updaterun,
[switch] $updateself,
[switch] $uninstall,
[switch] $help,
[string] $output = ""
)
@ -68,6 +69,7 @@ Available commands:
-updaterun
-updateself
-updateconf
-uninstall
-renewcert
-rebuild
-help
@ -155,6 +157,10 @@ elseif ($updateself) {
Get-Self
Write-Line "Updated self."
}
elseif ($uninstall) {
Test-Output-Dir-Exists
Invoke-Expression "& `"$scriptsDir\run.ps1`" -uninstall -outputDir `"$output`" "
}
elseif ($help) {
Show-Commands
}

View File

@ -95,6 +95,7 @@ updatedb
updaterun
updateself
updateconf
uninstall
renewcert
rebuild
help
@ -149,6 +150,10 @@ case $1 in
"updateself")
downloadSelf && echo "Updated self." && exit
;;
"uninstall")
checkOutputDirExists
$SCRIPTS_DIR/run.sh uninstall $OUTPUT
;;
"help")
listCommands
;;

View File

@ -9,6 +9,7 @@ param (
[switch] $stop,
[switch] $pull,
[switch] $updateconf,
[switch] $uninstall,
[switch] $renewcert,
[switch] $updatedb,
[switch] $update
@ -183,6 +184,38 @@ function Update([switch] $withpull) {
-keyconnectorv $keyConnectorVersion -q $setupQuiet
}
function Uninstall() {
$keepDatabase = $(Write-Host "(WARNING: UNINSTALL STARTED) Would you like to save the database files? (y/n)" -f red -nonewline) + $(Read-host)
if ($keepDatabase -eq "y") {
Write-Host "Saving database."
Compress-Archive -Path "${outputDir}\mssql" -DestinationPath ".\bitwarden_database.zip"
Write-Host "(SAVED DATABASE FILES: YES) `n(WARNING: ALL DATA WILL BE REMOVED, INCLUDING THE FOLDER $outputDir) " -f red -nonewline
$uninstallAction = $( Read-Host "Are you sure you want to uninstall Bitwarden? (y/n)" )
} else {
Write-Host "(WARNING: ALL DATA WILL BE REMOVED, INCLUDING THE FOLDER $outputDir) " -f red -nonewline
$uninstallAction = $( Read-Host "Are you sure you want to uninstall Bitwarden? (y/n)" )
}
if ($uninstallAction -eq "y") {
Write-Host "uninstalling Bitwarden..."
Docker-Compose-Down
Write-Host "Removing $outputDir"
Remove-Item -Path $outputDir -Force -Recurse
Write-Host "Bitwarden uninstall complete!"
} else {
Write-Host "Bitwarden uninstall canceled."
Exit
}
Write-Host "(!) " -f red -nonewline
$purgeAction = $( Read-Host "Would you like to purge all local Bitwarden container images? (y/n)" )
if ($purgeAction -eq "y") {
Docker-Prune
}
}
function Print-Environment {
Pull-Setup
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
@ -250,6 +283,10 @@ elseif ($update) {
Start-Sleep -s 60
Update-Database
}
elseif ($uninstall) {
Docker-Compose-Down
Uninstall
}
elseif ($rebuild) {
Docker-Compose-Down
Update

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

View File

@ -214,6 +214,8 @@ services:
volumes:
mssql_data:
labels:
com.bitwarden.product: bitwarden
{{/if}}
networks: