diff --git a/bootstrap-Windows.cmd b/bootstrap-Windows.cmd new file mode 100644 index 0000000..fb2fdf0 --- /dev/null +++ b/bootstrap-Windows.cmd @@ -0,0 +1,80 @@ +@echo off + +if [%1]==[/?] goto :help +echo %* | find "/?" > nul +if errorlevel 1 goto :main + +:help +echo usage: %0 [/?] +echo +echo Bootstrap a macOS instance with: +echo +echo * Windows SDK - from MSDN +echo * Chocolatey - package manager +echo * Git - from Chocolatey +echo * Python - from Chocolatey +echo * virtualenv - from pip +echo * SSH key - from ssh-keygen +echo * GitHub public key - with SSH key +echo * GitLab public key - with SSH key +echo * BitBucket Cloud public key - with SSH key +echo * Gogs Cloud public key - with SSH key +echo * conduit - configuration manager +echo +echo optional arguments: +echo /? show this help message and exit +goto end + +:main + +:: Check for admin permissions +>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" +if errorlevel 1 ( + echo Administrator privilages required! + exit /B 1 +) + +:: Install Windows SDK +bitsadmin.exe /transfer "Download Windows SDK" https://go.microsoft.com/fwlink/p/?linkid=845298 %~dp0\winsdksetup.exe +if errorlevel 1 exit /B 1 +echo Installing: Windows SDK +%~dp0\winsdksetup.exe /features + /q +if errorlevel 1 exit /B 1 +del %~dp0\winsdksetup.exe +echo Installed: Windows SDK + +:: Install Chocolatey +@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" +if errorlevel 1 exit /B 1 +echo Installed: Chocolatey + +:: Install Git +choco install cmder --yes +if errorlevel 1 exit /B 1 + +:: Install Python +choco install python2 --yes +if errorlevel 1 exit /B 1 + +:: Install virtualenv +"C:\Python27\Scripts\pip.exe" install virtualenv +if errorlevel 1 exit /B 1 + +:: Generate SSH key +mkdir %USERPROFILE%\.ssh +set /P email="SSH email: " +"C:\tools\cmder\vendor\git-for-windows\usr\bin\ssh-keygen.exe" -t rsa -b 4096 -C "%email%" -N "" -f %USERPROFILE%\.ssh\id_rsa +if errorlevel 1 exit /B 1 + +:: Set SSH keys on remote Git servers +"C:\Python27\Scripts\virtualenv.exe" %~dp0\bootstrap_env +if errorlevel 1 exit /B 1 +"%~dp0\bootstrap_env\Scripts\pip.exe" install git+https://code.infektor.net/config/bootstrap.git +if errorlevel 1 exit /B 1 +"%~dp0\bootstrap_env\Scripts\python.exe" -c "import bootstrap; bootstrap.set_ssh_keys()" +if errorlevel 1 exit /B 1 +rmdir /Q /S "%~dp0\bootstrap_env" +echo "Completed: %0 will now be removed" +start /b "" cmd /c del "%~f0"&exit /b + +:end