diff --git a/run.ps1 b/run.ps1 index e41e2bd..75c140f 100644 --- a/run.ps1 +++ b/run.ps1 @@ -70,8 +70,7 @@ function Install() { "--email ${email} -d ${domain} --logs-dir /etc/letsencrypt/logs" Invoke-Expression ($certbotExp -f $qFlag) - # check if the certbot image should be removed from the system - certbotCleanup + Cleanup-Certbot } } @@ -155,8 +154,7 @@ function Update-Lets-Encrypt { "renew{0} --logs-dir /etc/letsencrypt/logs" -f $qFlag Invoke-Expression $certbotExp - # check if the certbot image should be removed from the system - certbotCleanup + Cleanup-Certbot } } @@ -168,8 +166,7 @@ function Force-Update-Lets-Encrypt { "renew{0} --logs-dir /etc/letsencrypt/logs --force-renew" -f $qFlag Invoke-Expression $certbotExp - # check if the certbot image should be removed from the system - certbotCleanup + Cleanup-Certbot } } @@ -212,7 +209,6 @@ function Uninstall() { $uninstallAction = $( Read-Host "Are you sure you want to uninstall Bitwarden? (y/n)" ) } - if ($uninstallAction -eq "y") { Write-Host "uninstalling Bitwarden..." Docker-Compose-Down @@ -225,14 +221,13 @@ function Uninstall() { } 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 + $purgeAction = $( Read-Host "Would you like to purge all local Bitwarden container images? (y/n)" ) - # check if the certbot image should be removed from the system - certbotCleanup - } + if ($purgeAction -eq "y") { + Docker-Prune + } + + Cleanup-Certbot } function Print-Environment { @@ -269,14 +264,12 @@ function Write-Line($str) { } } -function certbotCleanup { - # check if the certbot image is being used by any containers +function Cleanup-Certbot { + # Check if the certbot image is being used by any containers if ([string]::IsNullOrEmpty((docker ps -a --filter ancestor=certbot/certbot --quiet))) { - # prompt the user Write-Host "(!) " -f red -nonewline $response = $( Read-Host "The [certbot/certbot] container image used by this script is no longer associated with any containers. Would you like to purge it? (y/N)" ) - # remove the image if that's what the user chooses if ($response.ToLower() -eq 'y') { docker image rm certbot/certbot }