Last active
March 23, 2020 17:20
-
-
Save MCOfficer/96f02a3e91c043d25ed74b3d26cb2d61 to your computer and use it in GitHub Desktop.
InstallNightly - Automate the Installation of Endless Sky Windows Nightlies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Echo off | |
setlocal | |
set GIT=mingit\cmd\git.exe | |
set NIGHTLY_URL=https://ci.mcofficer.me/job/endless-sky-win64/lastSuccessfulBuild/artifact/EndlessSky.exe | |
echo Switching working directory | |
cd %~dp0 | |
echo Checking if MinGit is available... | |
cmd /c %GIT% --version | |
if errorlevel 1 ( | |
echo. | |
echo Couldn't find MinGit, did you remove the mingit folder? | |
echo. | |
) else ( | |
echo. | |
echo Found MinGit, attempting to fetch latest datafiles... | |
%GIT% pull | |
echo. | |
) | |
echo Checking if Net.System.WebClient is available... | |
powershell /Command "$c = New-Object System.Net.WebClient; if ($c) { exit 42 }" | |
if %errorlevel% equ 42 ( | |
echo Yes | |
set DL_NIGHTLY=powershell /Command "(New-Object Net.WebClient).DownloadFile('%NIGHTLY_URL%', '%~dp0EndlessSky.exe')" | |
) else ( | |
echo Not found - falling back to bitsadmin, downloads may take a while | |
set DL_NIGHTLY=bitsadmin /transfer "EndlessSky" "%~dp0EndlessSky.exe" | |
) | |
echo. | |
echo Downloading Endless Sky Nightly... | |
%DL_NIGHTLY% > dl.log | |
echo ...Done | |
timeout /T 1 /nobreak > nul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
set LOG=installnightly.log | |
set WGET_URL=https://eternallybored.org/misc/wget/1.19.4/64/wget.exe | |
set UNZIP_URL=http://stahlworks.com/dev/unzip.exe | |
set MINGIT_URL=https://github.com/git-for-windows/git/releases/download/v2.20.1.windows.1/MinGit-2.20.1-64-bit.zip | |
set ES_GIT_URL=https://github.com/endless-sky/endless-sky.git | |
set LIBS_URL=https://mcofficer.me/download/endless-sky/requiredLibs.zip | |
set NIGHTLY_URL=https://ci.mcofficer.me/job/endless-sky-win64/lastSuccessfulBuild/artifact/EndlessSky.exe | |
set UPDATE_SCRIPT_URL=https://gist.githubusercontent.com/MCOfficer/96f02a3e91c043d25ed74b3d26cb2d61/raw/ESUpdate.bat | |
echo. | |
echo #=============================# | |
echo # # | |
echo # M*C*O's Nightly Installer # | |
echo # # | |
echo #=============================# | |
echo. | |
echo Welcome! | |
echo I (this Script) will automatically download the latest Endless Sky Nightly build. | |
echo A stable internet connection is required to download roughly 200MB of data. | |
echo. | |
echo At the end of the installation, you will be prompted to hit enter. If this window closes beforehand, something went wrong - please contact my author. | |
echo. | |
set /P INPUT=Press Enter to proceed | |
echo. | |
choice /m "Do you want to select an installation directory? This can cause issues for some Users. If the Script failed before without letting you choose a directory, move it to your preferred directory, then run it and choose No." | |
if %errorlevel% equ 2 ( | |
set INSTALLDIR=%~dp0 | |
goto DIRCHOSEN | |
) | |
:CHOOSEDIR | |
echo Checking if System.Windows.Forms.FolderBrowserDialog is available... | |
powershell /Command "[System.Reflection.Assembly]::LoadWithPartialName('System.windows.forms'); if (New-Object System.Windows.Forms.FolderBrowserDialog) { exit 42 }" > null | |
set INSTALLDIR= | |
if %errorlevel% equ 42 ( | |
echo Yes | |
::Thanks rojo, bodand & Igle :) | |
set "ps=[System.Reflection.Assembly]::LoadWithPartialName('System.windows.forms'); $d = New-Object System.Windows.Forms.FolderBrowserDialog; $d.ShowDialog(); echo $d.SelectedPath" | |
for /f "delims=" %%I in ('powershell /NoProfile /Command "%ps%"') do set "INSTALLDIR=%%I" | |
if "%INSTALLDIR%"=="" ( | |
echo Failed to open FolderBrowserDialog! | |
) else ( | |
GOTO DIRCHOSEN | |
) | |
) else ( | |
echo Not found | |
) | |
echo. | |
echo Since I can't let you choose a folder, I will install Endless Sky to my current location. If you prefer a different directory, just move me to whereever you please and run me again. | |
set INSTALLDIR=%~dp0 | |
:DIRCHOSEN | |
echo. | |
echo I will install Endless Sky to the following directory: | |
echo %INSTALLDIR% | |
echo Please note that I will install directly to that directory - I will NOT create a folder for Endless Sky IN that directory. You most likely want it to be empty, ideally a new folder. | |
echo. | |
set /P INPUT=Press Enter to confirm | |
echo. | |
echo. | |
echo Switching to %INSTALLDIR% | |
echo. | |
cd %INSTALLDIR% | |
DEL %LOG% > nul 2>&1 | |
md tools >> %LOG% 2>&1 | |
:INSTALL | |
echo Checking if Net.System.WebClient is available... | |
powershell /Command "if (New-Object System.Net.WebClient) { exit 42 }" > nul | |
if %errorlevel% equ 42 ( | |
echo Yes | |
set DL_WGET=powershell /Command "(New-Object Net.WebClient).DownloadFile('%WGET_URL%', 'tools\wget.exe')" | |
) else ( | |
echo Not found - falling back to bisadmin, WGet-Download may take a while | |
echo. | |
set DL_WGET=bitsadmin /transfer "WGet-Win" %WGET_URL% "%INSTALLDIR%\tools\wget.exe" | |
) | |
echo. | |
echo Downloading WGet... | |
%DL_WGET% >> %LOG% 2>&1 | |
set WGET=tools\wget.exe -v | |
echo Great, now we have a proper download manager! | |
echo. | |
echo Downloading Unzip... | |
%WGET% %UNZIP_URL% -O tools\unzip.exe >> %LOG% 2>&1 | |
set UZ=tools\unzip.exe -o | |
echo. | |
echo Downloading MinGit... | |
%WGET% %MINGIT_URL% -O mingit.zip >> %LOG% 2>&1 | |
echo Extracting... | |
%UZ% mingit.zip -d mingit >> %LOG% 2>&1 | |
DEL mingit.zip | |
set MINGIT=mingit\cmd\git.exe | |
echo. | |
echo Cloning Endless Sky... | |
%MINGIT% clone --no-checkout %ES_GIT_URL% tmp >> %LOG% 2>&1 | |
robocopy /MOV /S /E tmp\.git .git >> %LOG% 2>&1 | |
rd /Q /S tmp >> %LOG% 2>&1 | |
%MINGIT% reset --hard HEAD >> %LOG% 2>&1 | |
echo. | |
echo Downloading required Libraries... | |
%WGET% %LIBS_URL% -O libs.zip >> %LOG% 2>&1 | |
echo Extracting... | |
%UZ% libs.zip >> %LOG% 2>&1 | |
DEL libs.zip | |
echo. | |
echo Downloading Nightly... | |
%WGET% %NIGHTLY_URL% -O EndlessSky.exe >> %LOG% 2>&1 | |
echo. | |
echo Downloading Update Script... | |
%WGET% %UPDATE_SCRIPT_URL% -O Update.bat >> %LOG% 2>&1 | |
echo. | |
echo Removing installation tools | |
rd /S /Q tools >> %LOG% 2>&1 | |
echo. | |
echo. | |
echo All Done! | |
echo You can update this installation by running "Update.bat". | |
:EXIT | |
echo. | |
echo. | |
set /P INPUT=Press Enter to exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment