diff --git a/install.ps1 b/install.ps1 old mode 100644 new mode 100755 index 48c7e99..dc144fc --- 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 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." + } + 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..1333fbe 100755 --- a/install.sh +++ b/install.sh @@ -94,6 +94,19 @@ 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 +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." + 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