From 9c0db2982f32e50d89e9ae740bee2d940bd424d9 Mon Sep 17 00:00:00 2001 From: garrettApproachableGeek Date: Wed, 18 Dec 2024 12:04:38 -0800 Subject: [PATCH 1/2] feat: exit early when their likely will not be enough disk space to install shorebird --- install.ps1 | 14 ++++++++++++++ install.sh | 12 ++++++++++++ 2 files changed, 26 insertions(+) mode change 100644 => 100755 install.ps1 diff --git a/install.ps1 b/install.ps1 old mode 100644 new mode 100755 index 48c7e99..bfd6e8c --- a/install.ps1 +++ b/install.ps1 @@ -64,6 +64,20 @@ Test-GitVersion $force = $args -contains "--force" +# Check if there is enough free space +$requiredSpace = 1100MB # 1100 MiB +$installDrive = (Split-Path -Qualifier $installDirectory).TrimEnd(':') +$freeSpace = (Get-PSDrive -Name $installDrive).Free +if ($freeSpace -lt $requiredSpace) { + if ($force) { + Write-Output "Attempting Shorebird install with less than 1100 MiB of free space." + } + else { + Write-Output "Error: Not enough free space. At least 1100 MiB is required. Use --force to install anyway." + exit 1 + } +} + if (Test-Path $installDirectory) { if ($force) { Write-Output "Existing Shorebird installation detected. Overwriting..." diff --git a/install.sh b/install.sh index a3cba7d..5501851 100755 --- a/install.sh +++ b/install.sh @@ -94,6 +94,18 @@ if [ $GIT_VERSION_COMPARISON -eq 2 ]; then exit 1 fi +# Check if there is enough free space +REQUIRED_SPACE=$((1100 * 1024)) # 1100 MiB in KiB +FREE_SPACE=$(df -k "$(dirname "$(install_dir)")" | tail -1 | awk '{print $4}') +if [ $FREE_SPACE -lt $REQUIRED_SPACE ]; then + if [ "$FORCE" = true ]; then + echo "Attempting Shorebird install with less than 1100 MiB of free space." + else + echo >&2 "Error: Not enough free space. At least 1100 MiB is required. Use --force to install anyway." + exit 1 + fi +fi + # Check if install_dir already exists if [ -d "$(install_dir)" ]; then if [ "$FORCE" = true ]; then From f861a4d12e7622db9d182c54323a1d45d1280186 Mon Sep 17 00:00:00 2001 From: garrettApproachableGeek Date: Thu, 19 Dec 2024 10:06:35 -0800 Subject: [PATCH 2/2] Broke up long line and added comments --- install.ps1 | 6 +++--- install.sh | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/install.ps1 b/install.ps1 index bfd6e8c..dc144fc 100755 --- a/install.ps1 +++ b/install.ps1 @@ -65,9 +65,9 @@ Test-GitVersion $force = $args -contains "--force" # Check if there is enough free space -$requiredSpace = 1100MB # 1100 MiB -$installDrive = (Split-Path -Qualifier $installDirectory).TrimEnd(':') -$freeSpace = (Get-PSDrive -Name $installDrive).Free +$requiredSpace = 1100MB # 1100 MiB as bytes +$installDrive = (Split-Path -Qualifier $installDirectory).TrimEnd(':') # Drive letter install directory +$freeSpace = (Get-PSDrive -Name $installDrive).Free # Free space in bytes if ($freeSpace -lt $requiredSpace) { if ($force) { Write-Output "Attempting Shorebird install with less than 1100 MiB of free space." diff --git a/install.sh b/install.sh index 5501851..1333fbe 100755 --- a/install.sh +++ b/install.sh @@ -96,7 +96,8 @@ fi # Check if there is enough free space REQUIRED_SPACE=$((1100 * 1024)) # 1100 MiB in KiB -FREE_SPACE=$(df -k "$(dirname "$(install_dir)")" | tail -1 | awk '{print $4}') +INSTALL_VOLUME="$(dirname "$(install_dir)")" # Location of the install directory +FREE_SPACE=$(df -k $INSTALL_VOLUME | tail -1 | awk '{print $4}') # Free space in KiB if [ $FREE_SPACE -lt $REQUIRED_SPACE ]; then if [ "$FORCE" = true ]; then echo "Attempting Shorebird install with less than 1100 MiB of free space."