From 461c67b978803b6e897ed28847f4641b5613f774 Mon Sep 17 00:00:00 2001 From: Dax Games Date: Sat, 12 Nov 2016 13:24:41 -0600 Subject: [PATCH 1/4] Added proxy support to scripts - configure in floppy/_packer_config.cmd --- floppy/01-install-wget.cmd | 9 ++++++--- floppy/_download.cmd | 7 +++++-- floppy/_packer_config.cmd | 14 ++++++++++++++ floppy/bitvisessh.bat | 7 ++++++- floppy/cygwin.bat | 14 +++++++++++--- floppy/hotfix-KB2842230.bat | 7 ++++++- floppy/openssh.bat | 12 ++++++++---- floppy/upgrade-wua.bat | 6 +++++- 8 files changed, 61 insertions(+), 15 deletions(-) diff --git a/floppy/01-install-wget.cmd b/floppy/01-install-wget.cmd index c33f0f48..2b4ed73a 100644 --- a/floppy/01-install-wget.cmd +++ b/floppy/01-install-wget.cmd @@ -23,10 +23,13 @@ if exist "%filename%" goto exit0 echo ==^> Downloading "%WGET_URL%" to "%filename%" :powershell +if defined http_proxy ( + powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%WGET_URL%', '%filename%')" >nul +) else ( + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WGET_URL%', '%filename%')" >nul +) -powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WGET_URL%', '%filename%')" nul +) else ( + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%url%', '%filename%')" >nul +) if not errorlevel 1 if exist "%filename%" goto exit0 diff --git a/floppy/_packer_config.cmd b/floppy/_packer_config.cmd index a4d8406a..e1c74fae 100644 --- a/floppy/_packer_config.cmd +++ b/floppy/_packer_config.cmd @@ -1,5 +1,19 @@ @echo off +:: Uncomment the following to set proxy server config for all scripts +:: Be sure to set the proxy and no_proxy lines to your required settings +:: set http_proxy= +:: set https_proxy= +:: set proxy=10.10.10.10:80 +:: +:: if defined proxy ( +:: echo ==^> Setting HTTP Proxy.... +:: echo ==^> HTTP Proxy Set to %proxy% +:: set http_proxy=http://%proxy% +:: set https_proxy=http://%proxy% +:: set no_proxy=noproxy.domain.com,noproxy2.domain.com +:: ) + :: Uncomment the following to set a different Cygwin mirror :: Default: http://mirrors.kernel.org/sourceware/cygwin :: set CYGWIN_MIRROR_URL=http://mirrors.kernel.org/sourceware/cygwin diff --git a/floppy/bitvisessh.bat b/floppy/bitvisessh.bat index 5b54a246..68e58405 100644 --- a/floppy/bitvisessh.bat +++ b/floppy/bitvisessh.bat @@ -19,8 +19,13 @@ 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%')" nul + ) else ( + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%BITVISE_URL%', '%BITVISE_PATH%')" >nul + ) ) + if not exist "%BITVISE_PATH%" goto exit1 echo ==^> Blocking SSH port 22 on the firewall diff --git a/floppy/cygwin.bat b/floppy/cygwin.bat index 00b42400..0395e4f4 100644 --- a/floppy/cygwin.bat +++ b/floppy/cygwin.bat @@ -34,8 +34,13 @@ if exist "%SystemRoot%\_download.cmd" ( call "%SystemRoot%\_download.cmd" "%CYGWIN_URL%" "%CYGWIN_PATH%" ) else ( echo ==^> Downloading "%CYGWIN_URL%" to "%CYGWIN_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%CYGWIN_URL%', '%CYGWIN_PATH%')" nul + ) else ( + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%CYGWIN_URL%', '%CYGWIN_PATH%')" >nul + ) ) + if errorlevel 1 goto exit1 echo ==^> Blocking SSH port 22 on the firewall @@ -50,7 +55,11 @@ set /a CYGWIN_TRY=%CYGWIN_TRY%+1 echo ==^> Installing Cygwin (attempt %CYGWIN_TRY% of %CYGWIN_TRIES%) -"%CYGWIN_PATH%" -a %CYGWIN_ARCH% -q -R %CYGWIN_HOME% -P %CYGWIN_PACKAGES% -s %CYGWIN_MIRROR_URL% +if defined proxy ( + "%CYGWIN_PATH%" -a %CYGWIN_ARCH% -q -R %CYGWIN_HOME% -P %CYGWIN_PACKAGES% -s %CYGWIN_MIRROR_URL% -p %proxy% +) else ( + "%CYGWIN_PATH%" -a %CYGWIN_ARCH% -q -R %CYGWIN_HOME% -P %CYGWIN_PACKAGES% -s %CYGWIN_MIRROR_URL% +) if not errorlevel 1 goto installed_ok @@ -120,4 +129,3 @@ goto :exit verify other 2>nul :exit - diff --git a/floppy/hotfix-KB2842230.bat b/floppy/hotfix-KB2842230.bat index 6727c143..519f15b6 100644 --- a/floppy/hotfix-KB2842230.bat +++ b/floppy/hotfix-KB2842230.bat @@ -31,8 +31,13 @@ if exist "%SystemRoot%\_download.cmd" ( call "%SystemRoot%\_download.cmd" "%HOTFIX_2842230_URL%" "%HOTFIX_2842230_PATH%" ) else ( echo ==^> Downloading "%HOTFIX_2842230_URL%" to "%HOTFIX_2842230_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%HOTFIX_2842230_URL%', '%HOTFIX_2842230_PATH%')" nul + ) else ( + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%HOTFIX_2842230_URL%', '%HOTFIX_2842230_PATH%')" >nul + ) ) + if errorlevel 1 goto exit1 echo ==^> Extracting Hotfix KB2842230 diff --git a/floppy/openssh.bat b/floppy/openssh.bat index cec19dc0..cde1c711 100644 --- a/floppy/openssh.bat +++ b/floppy/openssh.bat @@ -16,12 +16,16 @@ mkdir "%OPENSSH_DIR%" pushd "%OPENSSH_DIR%" if exist "%SystemRoot%\_download.cmd" ( - call "%SystemRoot%\_download.cmd" "%OPENSSH_URL%" "%OPENSSH_PATH%" + call "%SystemRoot%\_download.cmd" "%OPENSSH_URL%" "%OPENSSH_PATH%" ) else ( - echo ==^> Downloading "%OPENSSH_URL%" to "%OPENSSH_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%OPENSSH_URL%', '%OPENSSH_PATH%')" nul + ) else ( + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%OPENSSH_URL%', '%OPENSSH_PATH%')" >nul + ) ) -if not exist "%OPENSSH_PATH%" goto exit1 + +if errorlevel 1 goto exit1 echo ==^> Blocking SSH port 22 on the firewall netsh advfirewall firewall add rule name="SSHD" dir=in action=block program="%ProgramFiles%\OpenSSH\usr\sbin\sshd.exe" enable=yes diff --git a/floppy/upgrade-wua.bat b/floppy/upgrade-wua.bat index 4ac8a74d..fab13fe3 100644 --- a/floppy/upgrade-wua.bat +++ b/floppy/upgrade-wua.bat @@ -24,7 +24,11 @@ if exist "%SystemRoot%\_download.cmd" ( call "%SystemRoot%\_download.cmd" "%WUA_URL%" "%WUA_PATH%" ) else ( echo ==^> Downloading "%WUA_URL%" to "%WUA_PATH%" - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WUA_URL%', '%WUA_PATH%')" nul + ) else ( + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WUA_URL%', '%WUA_PATH%')" >nul + ) ) if not exist "%WUA_PATH%" goto exit1 From 969064ae87f485d062aefbc576d9d43b83b8883c Mon Sep 17 00:00:00 2001 From: Dax Games Date: Sat, 12 Nov 2016 16:07:39 -0600 Subject: [PATCH 2/4] added no_proxy to powershell and the ability to disable BITS if it has issues --- floppy/01-install-wget.cmd | 6 +++++- floppy/_download.cmd | 7 ++++++- floppy/_packer_config.cmd | 3 +++ floppy/bitvisessh.bat | 2 +- floppy/cygwin.bat | 2 +- floppy/fixnetwork.ps1 | 2 +- floppy/hotfix-KB2842230.bat | 2 +- floppy/openssh.bat | 2 +- floppy/upgrade-wua.bat | 2 +- 9 files changed, 20 insertions(+), 8 deletions(-) diff --git a/floppy/01-install-wget.cmd b/floppy/01-install-wget.cmd index 2b4ed73a..064671f6 100644 --- a/floppy/01-install-wget.cmd +++ b/floppy/01-install-wget.cmd @@ -24,13 +24,17 @@ echo ==^> Downloading "%WGET_URL%" to "%filename%" :powershell if defined http_proxy ( - powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%WGET_URL%', '%filename%')" >nul + powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')) ; $wc.proxy.BypassList = (('%no_proxy%').split(',')) ; $wc.DownloadFile('%WGET_URL%', '%filename%')" >nul ) else ( powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WGET_URL%', '%filename%')" >nul ) if not errorlevel 1 if exist "%filename%" goto exit0 +if defined USE_BITS ( + if "%USE_BITS%" == "false" if not exist "%filename%" goto exit1 +) + set bitsadmin= for %%i in (bitsadmin.exe) do set bitsadmin=%%~$PATH:i diff --git a/floppy/_download.cmd b/floppy/_download.cmd index c7088ecc..b2d99d26 100644 --- a/floppy/_download.cmd +++ b/floppy/_download.cmd @@ -54,13 +54,18 @@ if not errorlevel 1 if exist "%filename%" goto exit0 :powershell if defined http_proxy ( - powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%url%', '%filename%')" >nul + REM powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%url%', '%filename%')" >nul + powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')) ; $wc.proxy.BypassList = (('%no_proxy%').split(',')) ; $wc.DownloadFile('%url%', '%filename%')" >nul ) else ( powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%url%', '%filename%')" >nul ) if not errorlevel 1 if exist "%filename%" goto exit0 +if defined USE_BITS ( + if "%USE_BITS%" == "false" if not exist "%filename%" goto exit1 +) + :bitsadmin set bitsadmin= diff --git a/floppy/_packer_config.cmd b/floppy/_packer_config.cmd index e1c74fae..9749cc5e 100644 --- a/floppy/_packer_config.cmd +++ b/floppy/_packer_config.cmd @@ -1,5 +1,8 @@ @echo off +:: Uncomment to disable trying to use BITS for file downloads +:: set USE_BITS=false + :: Uncomment the following to set proxy server config for all scripts :: Be sure to set the proxy and no_proxy lines to your required settings :: set http_proxy= diff --git a/floppy/bitvisessh.bat b/floppy/bitvisessh.bat index 68e58405..032ea8d4 100644 --- a/floppy/bitvisessh.bat +++ b/floppy/bitvisessh.bat @@ -20,7 +20,7 @@ if exist "%SystemRoot%\_download.cmd" ( ) else ( echo ==^> Downloading "%BITVISE_URL%" to "%BITVISE_PATH%" if defined http_proxy ( - powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%BITVISE_URL%', '%BITVISE_PATH%')" >nul + powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')) ; $wc.proxy.BypassList = (('%no_proxy%').split(',')); $wc.DownloadFile('%BITVISE_URL%', '%BITVISE_PATH%')" >nul ) else ( powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%BITVISE_URL%', '%BITVISE_PATH%')" >nul ) diff --git a/floppy/cygwin.bat b/floppy/cygwin.bat index 0395e4f4..3aa853c9 100644 --- a/floppy/cygwin.bat +++ b/floppy/cygwin.bat @@ -35,7 +35,7 @@ if exist "%SystemRoot%\_download.cmd" ( ) else ( echo ==^> Downloading "%CYGWIN_URL%" to "%CYGWIN_PATH%" if defined http_proxy ( - powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%CYGWIN_URL%', '%CYGWIN_PATH%')" >nul + powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')) ; $wc.proxy.BypassList = (('%no_proxy%').split(',')) ; $wc.DownloadFile('%CYGWIN_URL%', '%CYGWIN_PATH%')" >nul ) else ( powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%CYGWIN_URL%', '%CYGWIN_PATH%')" >nul ) diff --git a/floppy/fixnetwork.ps1 b/floppy/fixnetwork.ps1 index f5bfdd2e..74330797 100644 --- a/floppy/fixnetwork.ps1 +++ b/floppy/fixnetwork.ps1 @@ -20,4 +20,4 @@ $connections |foreach { Write-Host $_.GetNetwork().GetName()"category was previously set to"$_.GetNetwork().GetCategory() $_.GetNetwork().SetCategory(1) Write-Host $_.GetNetwork().GetName()"changed to category"$_.GetNetwork().GetCategory() -} \ No newline at end of file +} diff --git a/floppy/hotfix-KB2842230.bat b/floppy/hotfix-KB2842230.bat index 519f15b6..7bcb7f80 100644 --- a/floppy/hotfix-KB2842230.bat +++ b/floppy/hotfix-KB2842230.bat @@ -32,7 +32,7 @@ if exist "%SystemRoot%\_download.cmd" ( ) else ( echo ==^> Downloading "%HOTFIX_2842230_URL%" to "%HOTFIX_2842230_PATH%" if defined http_proxy ( - powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%HOTFIX_2842230_URL%', '%HOTFIX_2842230_PATH%')" >nul + powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')) ; $wc.proxy.BypassList = (('%no_proxy%').split(',')) ; $wc.DownloadFile('%HOTFIX_2842230_URL%', '%HOTFIX_2842230_PATH%')" >nul ) else ( powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%HOTFIX_2842230_URL%', '%HOTFIX_2842230_PATH%')" >nul ) diff --git a/floppy/openssh.bat b/floppy/openssh.bat index cde1c711..3288c5f5 100644 --- a/floppy/openssh.bat +++ b/floppy/openssh.bat @@ -19,7 +19,7 @@ if exist "%SystemRoot%\_download.cmd" ( call "%SystemRoot%\_download.cmd" "%OPENSSH_URL%" "%OPENSSH_PATH%" ) else ( if defined http_proxy ( - powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%OPENSSH_URL%', '%OPENSSH_PATH%')" >nul + powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')) ; $wc.proxy.BypassList = (('%no_proxy%').split(',')) ; $wc.DownloadFile('%OPENSSH_URL%', '%OPENSSH_PATH%')" >nul ) else ( powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%OPENSSH_URL%', '%OPENSSH_PATH%')" >nul ) diff --git a/floppy/upgrade-wua.bat b/floppy/upgrade-wua.bat index fab13fe3..181ff990 100644 --- a/floppy/upgrade-wua.bat +++ b/floppy/upgrade-wua.bat @@ -25,7 +25,7 @@ if exist "%SystemRoot%\_download.cmd" ( ) else ( echo ==^> Downloading "%WUA_URL%" to "%WUA_PATH%" if defined http_proxy ( - powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%WUA_URL%', '%WUA_PATH%')" >nul + powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')) ; $wc.proxy.BypassList = (('%no_proxy%').split(',')) ; $wc.DownloadFile('%WUA_URL%', '%WUA_PATH%')" >nul ) else ( powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WUA_URL%', '%WUA_PATH%')" >nul ) From 02be2e93d26e330c59a55e1505065dd4f78a8252 Mon Sep 17 00:00:00 2001 From: Dax Games Date: Sat, 12 Nov 2016 16:13:29 -0600 Subject: [PATCH 3/4] added ability to disable bits --- floppy/_packer_config.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/floppy/_packer_config.cmd b/floppy/_packer_config.cmd index 9749cc5e..29768c05 100644 --- a/floppy/_packer_config.cmd +++ b/floppy/_packer_config.cmd @@ -1,6 +1,6 @@ @echo off -:: Uncomment to disable trying to use BITS for file downloads +:: Uncomment to disable trying to use BITS for file downloads. :: set USE_BITS=false :: Uncomment the following to set proxy server config for all scripts From 913b79309a88386ec46d31bda663356e7f24c55d Mon Sep 17 00:00:00 2001 From: Dax T Games Date: Sat, 12 Nov 2016 16:19:36 -0600 Subject: [PATCH 4/4] removed comment --- floppy/_download.cmd | 1 - 1 file changed, 1 deletion(-) diff --git a/floppy/_download.cmd b/floppy/_download.cmd index b2d99d26..d693732b 100644 --- a/floppy/_download.cmd +++ b/floppy/_download.cmd @@ -54,7 +54,6 @@ if not errorlevel 1 if exist "%filename%" goto exit0 :powershell if defined http_proxy ( - REM powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')); $wc.DownloadFile('%url%', '%filename%')" >nul powershell -Command "$wc = (New-Object System.Net.WebClient); $wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')) ; $wc.proxy.BypassList = (('%no_proxy%').split(',')) ; $wc.DownloadFile('%url%', '%filename%')" >nul ) else ( powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%url%', '%filename%')" >nul