setup-vagrant64.bat 1.38 KB
Newer Older
Benguria Elguezabal, Gorka's avatar
Benguria Elguezabal, Gorka committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
@echo off

rem we check vbox existance
if "%VBOX_MSI_INSTALL_PATH%" == "" ( 
  echo Requires Virtual Box 
  goto end
)

rem we check de powershell version if lower that 3 exit
for /f %%i in ('powershell -Command "$PSVersionTable.PSVersion.Major"') do set powershellVersion=%%i
echo powershellVersion=%powershellVersion%

if %powershellVersion% LSS 3 (
  echo Only works with powershell greater or equal to 3 
  goto end
)

rem we download the setup package
IF "%VAGRANT_VERSION%" == "" (
set VAGRANT_VERSION=2.2.3
echo Defaults VAGRANT_VERSION=%VAGRANT_VERSION%
)
echo "downloading %VAGRANT_VERSION%"

set downloadUrl=https://releases.hashicorp.com/vagrant/%VAGRANT_VERSION%/vagrant_%VAGRANT_VERSION%_x86_64.msi

mkdir downloads 2> nul

for /f %%i in ('powershell -Command "$(split-path -path "%downloadUrl%" -leaf)"') do set appFileName=%%i
echo appFileName=%appFileName%

if Not exist "downloads\%appFileName%" (
    rem file exists
	echo downloading %downloadUrl% to downloads
	rem we escape because we are inside if
	powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest %downloadUrl% -OutFile downloads\%appFileName%"
)

rem we install app
set APP_HOME_REL_PATH=vagrant64
mkdir %APP_HOME_REL_PATH% 2> nul

msiexec.exe /a "downloads\%appFileName%" /qb TARGETDIR=%CD%\%APP_HOME_REL_PATH%

:end