mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 13:38:13 -05:00
[BEEEP] Bitwarden Script uninstall option (#1796)
Co-authored-by: Vince Grassia <593223+vgrassia@users.noreply.github.com>
This commit is contained in:
parent
52ddf55029
commit
156e10da0e
@ -10,6 +10,7 @@ param (
|
|||||||
[switch] $updatedb,
|
[switch] $updatedb,
|
||||||
[switch] $updaterun,
|
[switch] $updaterun,
|
||||||
[switch] $updateself,
|
[switch] $updateself,
|
||||||
|
[switch] $uninstall,
|
||||||
[switch] $help,
|
[switch] $help,
|
||||||
[string] $output = ""
|
[string] $output = ""
|
||||||
)
|
)
|
||||||
@ -68,6 +69,7 @@ Available commands:
|
|||||||
-updaterun
|
-updaterun
|
||||||
-updateself
|
-updateself
|
||||||
-updateconf
|
-updateconf
|
||||||
|
-uninstall
|
||||||
-renewcert
|
-renewcert
|
||||||
-rebuild
|
-rebuild
|
||||||
-help
|
-help
|
||||||
@ -155,6 +157,10 @@ elseif ($updateself) {
|
|||||||
Get-Self
|
Get-Self
|
||||||
Write-Line "Updated self."
|
Write-Line "Updated self."
|
||||||
}
|
}
|
||||||
|
elseif ($uninstall) {
|
||||||
|
Test-Output-Dir-Exists
|
||||||
|
Invoke-Expression "& `"$scriptsDir\run.ps1`" -uninstall -outputDir `"$output`" "
|
||||||
|
}
|
||||||
elseif ($help) {
|
elseif ($help) {
|
||||||
Show-Commands
|
Show-Commands
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ updatedb
|
|||||||
updaterun
|
updaterun
|
||||||
updateself
|
updateself
|
||||||
updateconf
|
updateconf
|
||||||
|
uninstall
|
||||||
renewcert
|
renewcert
|
||||||
rebuild
|
rebuild
|
||||||
help
|
help
|
||||||
@ -149,6 +150,10 @@ case $1 in
|
|||||||
"updateself")
|
"updateself")
|
||||||
downloadSelf && echo "Updated self." && exit
|
downloadSelf && echo "Updated self." && exit
|
||||||
;;
|
;;
|
||||||
|
"uninstall")
|
||||||
|
checkOutputDirExists
|
||||||
|
$SCRIPTS_DIR/run.sh uninstall $OUTPUT
|
||||||
|
;;
|
||||||
"help")
|
"help")
|
||||||
listCommands
|
listCommands
|
||||||
;;
|
;;
|
||||||
|
@ -9,6 +9,7 @@ param (
|
|||||||
[switch] $stop,
|
[switch] $stop,
|
||||||
[switch] $pull,
|
[switch] $pull,
|
||||||
[switch] $updateconf,
|
[switch] $updateconf,
|
||||||
|
[switch] $uninstall,
|
||||||
[switch] $renewcert,
|
[switch] $renewcert,
|
||||||
[switch] $updatedb,
|
[switch] $updatedb,
|
||||||
[switch] $update
|
[switch] $update
|
||||||
@ -183,6 +184,38 @@ function Update([switch] $withpull) {
|
|||||||
-keyconnectorv $keyConnectorVersion -q $setupQuiet
|
-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 {
|
function Print-Environment {
|
||||||
Pull-Setup
|
Pull-Setup
|
||||||
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
|
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
|
||||||
@ -250,6 +283,10 @@ elseif ($update) {
|
|||||||
Start-Sleep -s 60
|
Start-Sleep -s 60
|
||||||
Update-Database
|
Update-Database
|
||||||
}
|
}
|
||||||
|
elseif ($uninstall) {
|
||||||
|
Docker-Compose-Down
|
||||||
|
Uninstall
|
||||||
|
}
|
||||||
elseif ($rebuild) {
|
elseif ($rebuild) {
|
||||||
Docker-Compose-Down
|
Docker-Compose-Down
|
||||||
Update
|
Update
|
||||||
|
@ -4,6 +4,7 @@ set -e
|
|||||||
# Setup
|
# Setup
|
||||||
|
|
||||||
CYAN='\033[0;36m'
|
CYAN='\033[0;36m'
|
||||||
|
RED='\033[1;31m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
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
|
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() {
|
function printEnvironment() {
|
||||||
pullSetup
|
pullSetup
|
||||||
docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \
|
docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \
|
||||||
@ -285,6 +326,10 @@ case $1 in
|
|||||||
updatebw
|
updatebw
|
||||||
updateDatabase
|
updateDatabase
|
||||||
;;
|
;;
|
||||||
|
"uninstall")
|
||||||
|
dockerComposeFiles
|
||||||
|
uninstall
|
||||||
|
;;
|
||||||
"rebuild")
|
"rebuild")
|
||||||
dockerComposeDown
|
dockerComposeDown
|
||||||
update nopull
|
update nopull
|
||||||
|
@ -214,6 +214,8 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mssql_data:
|
mssql_data:
|
||||||
|
labels:
|
||||||
|
com.bitwarden.product: bitwarden
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user