Browse Source

Replaced command that pruned non-setup BW imagess because combining positive and negative filters with `docker prune` seems to be broken in Docker Desktop.

Added switch to purge function to allow all BW images to be purged (dont exclude setup image) during uninstall.
Added verbiage to clarify purge behavior.
pull/440/head
gitclonebrian 2 weeks ago
parent
commit
996a6f5cb4
  1. 16
      run.ps1
  2. 15
      run.sh

16
run.ps1

@ -140,9 +140,15 @@ function Create-Dir($str) { @@ -140,9 +140,15 @@ function Create-Dir($str) {
}
}
function Docker-Prune {
docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" `
--filter="label!=com.bitwarden.project=setup"
function Docker-Prune([switch] $all) {
if ($all) {
docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden"
}
else {
docker image ls --format "{{.Repository}}:{{.Tag}}" --filter="label=com.bitwarden.product=bitwarden" |
Where-Object { $_ -notmatch '/bitwarden/setup' } |
ForEach-Object { docker image rm $_ }
}
}
function Update-Lets-Encrypt {
@ -217,10 +223,10 @@ function Uninstall() { @@ -217,10 +223,10 @@ function Uninstall() {
}
Write-Host "(!) " -f red -nonewline
$purgeAction = $( Read-Host "Would you like to purge all local Bitwarden container images? (y/n)" )
$purgeAction = $( Read-Host "Would you like to purge all local Bitwarden container images (this will not remove third-party images such as certbot)? (y/n)" )
if ($purgeAction -eq "y") {
Docker-Prune
Docker-Prune -all
}
}

15
run.sh

@ -163,8 +163,15 @@ function createDir() { @@ -163,8 +163,15 @@ function createDir() {
}
function dockerPrune() {
docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" \
--filter="label!=com.bitwarden.project=setup"
if [ "$1" == 'all' ]
then
docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden"
else
for image in $(docker image ls --format "{{.Repository}}:{{.Tag}}" --filter="label=com.bitwarden.product=bitwarden" | grep -v '/bitwarden/setup'); do
docker image rm "$image"
done
fi
}
function updateLetsEncrypt() {
@ -274,11 +281,11 @@ function uninstall() { @@ -274,11 +281,11 @@ function uninstall() {
exit 1
fi
echo -e -n "${RED}(!) Would you like to purge all local Bitwarden container images? (y/n): ${NC}"
echo -e -n "${RED}(!) Would you like to purge all local Bitwarden container images (this will not remove third-party images such as certbot)? (y/n): ${NC}"
read PURGE_ACTION
if [ "$PURGE_ACTION" == "y" ]
then
dockerPrune
dockerPrune all
echo -e -n "${CYAN}Bitwarden uninstall complete! ${NC}"
fi
}

Loading…
Cancel
Save