diff --git a/run.ps1 b/run.ps1 index b56e658..43a837d 100644 --- a/run.ps1 +++ b/run.ps1 @@ -40,7 +40,7 @@ if ("${env:BITWARDEN_CERTBOT_HTTPS_PORT}" -ne "") { function Install() { [string]$letsEncrypt = "n" Write-Host "(!) " -f cyan -nonewline - [string]$domain = $( Read-Host "Enter the domain name for your Bitwarden instance (ex. bitwarden.example.com)" ) + [string]$domain = $( Read-Host "Enter the domain name for your Bitwarden instance (ex. bitwarden.example.com) [localhost]" ) echo "" if ($domain -eq "") { @@ -49,10 +49,10 @@ function Install() { if ($domain -ne "localhost") { Write-Host "(!) " -f cyan -nonewline - $letsEncrypt = $( Read-Host "Do you want to use Let's Encrypt to generate a free SSL certificate? (y/n)" ) + $letsEncrypt = $( Read-Host "Do you want to use Let's Encrypt to generate a free SSL certificate? (y/N)" ) echo "" - if ($letsEncrypt -eq "y") { + if ($letsEncrypt.ToLower() -eq "y") { Write-Host "(!) " -f cyan -nonewline [string]$email = $( Read-Host ("Enter your email address (Let's Encrypt will send you certificate " + "expiration reminders)") ) @@ -72,7 +72,7 @@ function Install() { } Write-Host "(!) " -f cyan -nonewline - [string]$database = $( Read-Host "Enter the database name for your Bitwarden instance (ex. vault): ") + [string]$database = $( Read-Host "Enter the database name for your Bitwarden instance [vault]: ") echo "" if ($database -eq "") { @@ -185,35 +185,37 @@ function Update([switch] $withpull) { } 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") { + $keepDatabase = $(Write-Host "(WARNING: UNINSTALL STARTED) Would you like to save the database files? (y/N)" -f red -nonewline) + $(Read-host) + if ($keepDatabase.ToLower() -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 { + $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)" ) + $uninstallAction = $( Read-Host "Are you sure you want to uninstall Bitwarden? (y/N)" ) } - if ($uninstallAction -eq "y") { + if ($uninstallAction.ToLower() -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 { + } + 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)" ) + $purgeAction = $( Read-Host "Would you like to purge all local Bitwarden container images? (y/N)" ) - if ($purgeAction -eq "y") { - Docker-Prune - } + if ($purgeAction.ToLower() -eq "y") { + Docker-Prune + } } function Print-Environment { diff --git a/run.sh b/run.sh index 6baf86e..dd8413c 100755 --- a/run.sh +++ b/run.sh @@ -60,7 +60,7 @@ fi function install() { LETS_ENCRYPT="n" - echo -e -n "${CYAN}(!)${NC} Enter the domain name for your Bitwarden instance (ex. bitwarden.example.com): " + echo -e -n "${CYAN}(!)${NC} Enter the domain name for your Bitwarden instance (ex. bitwarden.example.com) [localhost]: " read DOMAIN echo "" @@ -71,11 +71,11 @@ function install() { if [ "$DOMAIN" != "localhost" ] then - echo -e -n "${CYAN}(!)${NC} Do you want to use Let's Encrypt to generate a free SSL certificate? (y/n): " + echo -e -n "${CYAN}(!)${NC} Do you want to use Let's Encrypt to generate a free SSL certificate? (y/N): " read LETS_ENCRYPT echo "" - if [ "$LETS_ENCRYPT" == "y" ] + if [[ "$LETS_ENCRYPT" == "y" || "$LETS_ENCRYPT" == "Y" ]] then echo -e -n "${CYAN}(!)${NC} Enter your email address (Let's Encrypt will send you certificate expiration reminders): " read EMAIL @@ -89,7 +89,7 @@ function install() { fi fi - echo -e -n "${CYAN}(!)${NC} Enter the database name for your Bitwarden instance (ex. vault): " + echo -e -n "${CYAN}(!)${NC} Enter the database name for your Bitwarden instance [vault]: " read DATABASE echo "" @@ -236,22 +236,22 @@ function update() { } function uninstall() { - echo -e -n "${RED}(WARNING: UNINSTALL STARTED) Would you like to save the database files? (y/n): ${NC}" + 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" ] + if [[ "$KEEP_DATABASE" == "y" || "$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}" + 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}" + 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" ] + if [[ "$UNINSTALL_ACTION" == "y" || "$UNINSTALL_ACTION" == "Y" ]] then echo "Uninstalling Bitwarden..." dockerComposeDown @@ -265,9 +265,9 @@ 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? (y/N): ${NC}" read PURGE_ACTION - if [ "$PURGE_ACTION" == "y" ] + if [[ "$PURGE_ACTION" == "y" || "$PURGE_ACTION" == "Y" ]] then dockerPrune echo -e -n "${CYAN}Bitwarden uninstall complete! ${NC}"