powershell and curl check

Added powershell and curl checks before installation
This commit is contained in:
amd64fox
2022-02-19 06:18:20 +03:00
parent 639e7c6de4
commit af2afe9598
2 changed files with 127 additions and 63 deletions

View File

@@ -1,41 +1,73 @@
@echo off @echo off
Setlocal EnableDelayedExpansion Setlocal EnableDelayedExpansion
set "exec=powershell $PSVersionTable.PSVersion.major"
for /f %%i in ('%exec%') do set ps-v=%%i 2>nul
if %ps-v% LEQ 2 (
Echo Powershell %ps-v%is not supported
@echo.
Echo Please read the instruction "Outdated versions of PowerShell" at the following link
@echo.
Echo "https://github.com/amd64fox/SpotX#possible-problems"
@echo.
pause
exit
)
curl -V >nul 2>&1
if %errorlevel% EQU 9009 (
echo "Curl" command line utility not found
@echo.
echo Please follow the link, download and install "Curl" manually
@echo.
echo "http://www.confusedbycode.com/curl/#downloads"
@echo.
pause
exit
)
for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1') do set STATUS_CODE=%%i 2>nul for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1') do set STATUS_CODE=%%i 2>nul
if %STATUS_CODE% EQU 200 ( if %STATUS_CODE% EQU 200 (
powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1' | Invoke-Expression}" powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1' | Invoke-Expression}"
) )
if %STATUS_CODE% LSS 1 ( if %STATUS_CODE% LSS 1 (
echo No network connection echo No network connection
echo Trying to reconnect via... @echo.
TIMEOUT /T 5 echo Trying to reconnect via...
cls TIMEOUT /T 5
for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1') do set STATUS_CODE=%%i 2>nul cls
if "!STATUS_CODE!" EQU "200 " ( for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1') do set STATUS_CODE=%%i 2>nul
cls if "!STATUS_CODE!" EQU "200 " (
powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1' | Invoke-Expression}" cls
) else ( powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1' | Invoke-Expression}"
echo Error again ) else (
echo Check your internet connection echo Error again
echo Script stopped @echo.
pause echo Check your internet connection
exit @echo.
) echo Script stopped
@echo.
pause
exit
)
) )
if %STATUS_CODE% GTR 100 if not %STATUS_CODE% EQU 200 ( if %STATUS_CODE% GTR 100 if not %STATUS_CODE% EQU 200 (
echo Failed to connect to github.com echo Failed to connect to github.com
echo HTTP response code %STATUS_CODE% @echo.
echo Trying to reconnect via... echo HTTP response code %STATUS_CODE%
TIMEOUT /T 5 @echo.
cls echo Trying to reconnect via...
for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1') do set STATUS_CODE=%%i 2>nul TIMEOUT /T 5
if "!STATUS_CODE!" EQU "200 " ( cls
cls for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1') do set STATUS_CODE=%%i 2>nul
powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1' | Invoke-Expression}" if "!STATUS_CODE!" EQU "200 " (
) else ( cls
echo Error again powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1' | Invoke-Expression}"
echo Try to run after some time ) else (
echo Script stopped echo Error again
) @echo.
echo Try to run after some time
@echo.
echo Script stopped
@echo.
)
) )
pause pause
exit exit

View File

@@ -1,45 +1,77 @@
@echo off @echo off
Setlocal EnableDelayedExpansion Setlocal EnableDelayedExpansion
set "exec=powershell $PSVersionTable.PSVersion.major"
for /f %%i in ('%exec%') do set ps-v=%%i 2>nul
chcp 65001 >nul chcp 65001 >nul
if %ps-v% LEQ 2 (
echo Powershell %ps-v%не поддерживается
@echo.
echo Пожалуйста, прочитайте инструкцию "Устаревшие версии PowerShell" по следующей ссылке
@echo.
echo "https://4pda.to/forum/index.php?act=findpost&pid=104279894&anchor=outdated_versions"
@echo.
pause
exit
)
curl -V >nul 2>&1
if %errorlevel% EQU 9009 (
echo Команда "Curl" отсутствует в системе
@echo.
echo Пожалуйста, перейдите по следующей ссылке для ручной установки "Curl"
@echo.
echo "http://www.confusedbycode.com/curl/#downloads"
@echo.
pause
exit
)
for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1') do set STATUS_CODE=%%i 2>nul for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1') do set STATUS_CODE=%%i 2>nul
if %STATUS_CODE% EQU 200 ( if %STATUS_CODE% EQU 200 (
chcp 866 >nul chcp 866 >nul
powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {(Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1').Content | Invoke-Expression}" powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {(Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1').Content | Invoke-Expression}"
) )
if %STATUS_CODE% LSS 1 ( if %STATUS_CODE% LSS 1 (
echo Нет подключения к сети echo Нет подключения к сети
echo Попытка повторного подключения через ... @echo.
TIMEOUT /T 5 echo Попытка повторного подключения через ...
cls TIMEOUT /T 5
for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1') do set STATUS_CODE=%%i 2>nul cls
if "!STATUS_CODE!" EQU "200 " ( for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1') do set STATUS_CODE=%%i 2>nul
cls if "!STATUS_CODE!" EQU "200 " (
chcp 866 >nul cls
powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {(Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1').Content | Invoke-Expression}" chcp 866 >nul
) else ( powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {(Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1').Content | Invoke-Expression}"
echo Снова ошибка ) else (
echo Проверьте свое интернет соединение echo Снова ошибка
echo Скрипт остановлен @echo.
pause echo Проверьте свое интернет соединение
exit @echo.
) echo Скрипт остановлен
@echo.
pause
exit
)
) )
if %STATUS_CODE% GTR 100 if not %STATUS_CODE% EQU 200 ( if %STATUS_CODE% GTR 100 if not %STATUS_CODE% EQU 200 (
echo Не удалось подключиться к github.com echo Не удалось подключиться к github.com
echo Код ответа HTTP %STATUS_CODE% @echo.
echo Попытка повторного подключения через ... echo Код ответа HTTP %STATUS_CODE%
TIMEOUT /T 5 @echo.
cls echo Попытка повторного подключения через ...
for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1') do set STATUS_CODE=%%i 2>nul TIMEOUT /T 5
if "!STATUS_CODE!" EQU "200 " ( cls
cls for /f %%i in ('curl --write-out %%{http_code} --silent --output /dev/null --insecure https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1') do set STATUS_CODE=%%i 2>nul
chcp 866 >nul if "!STATUS_CODE!" EQU "200 " (
powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {(Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1').Content | Invoke-Expression}" cls
) else ( chcp 866 >nul
echo Снова ошибка powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {(Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1').Content | Invoke-Expression}"
echo Попробуйте запустить спустя некоторое время ) else (
echo Скрипт остановлен echo Снова ошибка
) @echo.
echo Попробуйте запустить спустя некоторое время
@echo.
echo Скрипт остановлен
@echo.
)
) )
pause pause
exit exit