diff --git a/.gitignore b/.gitignore index 6edeac1c..cfd67a28 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ floppy/_packer_config_*.cmd *.*.json floppy/*.*.* script/*.*.* - diff --git a/README.md b/README.md index 53a284ce..bf9f8320 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # Packer templates for Windows ### Overview @@ -146,6 +147,19 @@ You can add additional `floppy/_packer_config_*.cmd` files. These files will be `floppy/_packer_config*.cmd` will be executed in alpabetical order during initial install and at the beginning of each shell provisioner script if the script supports loading them. +#### Proxy Configuration using `floppy/_packer_config_proxy.cmd` + +Create a file called `floppy/_packer_config_proxy.cmd` with the below contents: + +``` +set http_proxy_user=[proxy_user] +set http_proxy_password=[proxy_password] +set ftp_proxy=http://[proxy_host]:[proxy_port] +set http_proxy=http://[proxy_host]:[proxy_port] +set https_proxy=http://[proxy_host]:[proxy_port] +set no_proxy=127.0.0.1,localhost,[no_proxy_hosts] +``` + ### Acknowledgments [Parallels](http://www.parallels.com/) provides a Business Edition license of diff --git a/floppy/01-install-wget.cmd b/floppy/01-install-wget.cmd index 4087ed2a..6a45ab4a 100644 --- a/floppy/01-install-wget.cmd +++ b/floppy/01-install-wget.cmd @@ -10,24 +10,12 @@ if not defined WGET_URL set WGET_URL=https://eternallybored.org/misc/wget/curren for %%i in ("%WGET_URL%") do set filename=%SystemRoot%\%%~nxi -if not exist "%~dp0\_download.cmd" goto _download_cmd_not_found - copy /y "%~dp0\_download.cmd" "%SystemRoot%\" call "%~dp0\_download.cmd" "%WGET_URL%" "%filename%" if exist "%filename%" goto exit0 -:_download_cmd_not_found - -echo ==^> Downloading "%WGET_URL%" to "%filename%" - -:powershell - -powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WGET_URL%', '%filename%')" ERROR: _download.cmd called without URL parameter. & goto exit1 @@ -31,8 +31,8 @@ echo ==^> Copying "%found%" to "%filename%", skipping download. copy /y "%found%" "%filename%" && goto exit0 :download - -echo ==^> Downloading "%url%" to "%filename%" +REM IT IS JUST CLEANER WITH THIS WGET IS REALLY PICKY. POWERSHELL - NOT SO MUCH +if defined http_proxy goto powershell set wget= @@ -46,15 +46,37 @@ if defined wget goto wget if not exist "%wget%" goto powershell +echo ==^> Downloading "%url%" to "%filename%" using "%wget%"... + if not defined PACKER_DEBUG set WGET_OPTS=--no-verbose +if defined http_proxy ( + if defined http_proxy_user if defined http_proxy_password ( + set WGET_OPTS=%WGET_OPTS% --proxy-user='%http_proxy_user%' --proxy-passwd='%http_proxy_password%' + ) +) + "%wget%" --no-check-certificate %WGET_OPTS% -O "%filename%" "%url%" if not errorlevel 1 if exist "%filename%" goto exit0 :powershell +echo ==^> Downloading "%url%" to "%filename%" using "Powershell"... -powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%url%', '%filename%')" nul if not errorlevel 1 if exist "%filename%" goto exit0 @@ -70,7 +92,9 @@ for %%i in (bitsadmin.exe) do set bitsadmin=%%~$PATH:i if not defined bitsadmin set bitsadmin=%SystemRoot%\System32\bitsadmin.exe -if not exist "%bitsadmin%" goto powershell +if not exist "%bitsadmin%" goto exit 1 + +echo ==^> Downloading "%url%" to "%filename%" using "BITS"... for %%i in ("%filename%") do set jobname=%%~nxi diff --git a/floppy/bitvisessh.bat b/floppy/bitvisessh.bat index 5b54a246..b0b0bef0 100644 --- a/floppy/bitvisessh.bat +++ b/floppy/bitvisessh.bat @@ -17,9 +17,6 @@ pushd "%BITVISE_DIR%" if exist "%SystemRoot%\_download.cmd" ( call "%SystemRoot%\_download.cmd" "%BITVISE_URL%" "%BITVISE_PATH%" -) else ( - echo ==^> Downloading "%BITVISE_URL%" to "%BITVISE_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%BITVISE_URL%', '%BITVISE_PATH%')" Downloading "%CYGWIN_URL%" to "%CYGWIN_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%CYGWIN_URL%', '%CYGWIN_PATH%')" Downloading "%HOTFIX_2842230_URL%" to "%HOTFIX_2842230_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%HOTFIX_2842230_URL%', '%HOTFIX_2842230_PATH%')" Downloading "%OPENSSH_URL%" to "%OPENSSH_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%OPENSSH_URL%', '%OPENSSH_PATH%')" Downloading "%WUA_URL%" to "%WUA_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WUA_URL%', '%WUA_PATH%')" Downloading "%HANDLE_URL%" to "%HANDLE_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%HANDLE_URL%', '%HANDLE_PATH%')" Using Chef Omnitruck API URL: !url! -powershell -command "(New-Object System.Net.WebClient).DownloadFile('!url!', '!filename!')" +call "%SystemRoot%\_download.cmd" !url! !filename! if not exist "%TEMP%\omnitruck.txt" ( echo Unable to download metadata for %OMNITRUCK_PRODUCT% %OMNITRUCK_VERSION% on the %OMNITRUCK_CHANNEL% channel for %OMNITRUCK_PLATFORM% %OMNITRUCK_MACHINE_ARCH% @@ -136,9 +136,6 @@ pushd "%CHEF_DIR%" if exist "%SystemRoot%\_download.cmd" ( call "%SystemRoot%\_download.cmd" "%CHEF_URL%" "%CHEF_PATH%" -) else ( - echo ==^> Downloading %CHEF_URL% to %CHEF_PATH% - powershell -Command "(New-Object System.Net.WebClient).DownloadFile(\"%CHEF_URL%\", '%CHEF_PATH%')" Downloading %PUPPET_URL% to %PUPPET_PATH% - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%PUPPET_URL%', '%PUPPET_PATH%')" Downloading %SALT_URL% to %SALT_DOWNLOAD% -powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SALT_URL%', '%SALT_DOWNLOAD%')" Patching bootstrap-salt.ps1 at %SALT_DOWNLOAD% @@ -301,7 +296,7 @@ if "%CM_VERSION%" == "latest" ( set SALT_PATH=%SALT_DIR%\Salt-Minion-Setup.exe echo ==^> Downloading %SALT_URL% to %SALT_PATH% -powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SALT_URL%', '%SALT_PATH%')" Installing Salt minion %CM_VERSION%-%SALT_PYTHONVERSION% with %SALT_PATH% diff --git a/script/sdelete.bat b/script/sdelete.bat index 26dc7e21..6943ea6c 100644 --- a/script/sdelete.bat +++ b/script/sdelete.bat @@ -14,9 +14,6 @@ pushd "%SDELETE_DIR%" if exist "%SystemRoot%\_download.cmd" ( call "%SystemRoot%\_download.cmd" "%SDELETE_URL%" "%SDELETE_PATH%" -) else ( - echo ==^> Downloading "%SDELETE_URL%" to "%SDELETE_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SDELETE_URL%', '%SDELETE_PATH%')" Downloading "%SEVENZIP_URL%" to "%SEVENZIP_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SEVENZIP_URL%', '%SEVENZIP_PATH%')" Downloading "%ULTRADEFRAG_URL%" to "%ULTRADEFRAG_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%ULTRADEFRAG_URL%', '%ULTRADEFRAG_PATH%')" Downloading "%VAGRANT_PUB_URL%" to "%VAGRANT_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%VAGRANT_PUB_URL%', '%VAGRANT_PATH%')" Creating "%SEVENZIP_DIR%" mkdir "%SEVENZIP_DIR%" cd /d "%SEVENZIP_DIR%" -if exist "%SystemRoot%\_download.cmd" ( - call "%SystemRoot%\_download.cmd" "%SEVENZIP_URL%" "%SEVENZIP_PATH%" -) else ( - echo ==^> Downloading "%SEVENZIP_URL%" to "%SEVENZIP_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SEVENZIP_URL%', '%SEVENZIP_PATH%')" Installing "%SEVENZIP_PATH%" msiexec /qb /i "%SEVENZIP_PATH%" @@ -126,12 +121,8 @@ if defined VMWARE_TOOLS_ISO_PATH for %%i in (%VMWARE_TOOLS_ISO_PATH%) do set _VM if %_VMWARE_TOOLS_SIZE% EQU 0 set VMWARE_TOOLS_ISO_PATH= if defined VMWARE_TOOLS_ISO_PATH goto install_vmware_tools_from_iso -if exist "%SystemRoot%\_download.cmd" ( - call "%SystemRoot%\_download.cmd" "%VMWARE_TOOLS_TAR_URL%" "%VMWARE_TOOLS_TAR_PATH%" -) else ( - echo ==^> Downloading "%VMWARE_TOOLS_TAR_URL%" to "%VMWARE_TOOLS_TAR_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%VMWARE_TOOLS_TAR_URL%', '%VMWARE_TOOLS_TAR_PATH%')" Downloading "%VBOX_ISO_URL%" to "%VBOX_ISO_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%VBOX_ISO_URL%', '%VBOX_ISO_PATH%')"