Compare commits
4 Commits
a8b9e6bfe2
...
5e232430cc
Author | SHA1 | Date | |
---|---|---|---|
5e232430cc | |||
6f62732f54 | |||
f97ba86a05 | |||
e3fa06d8b3 |
@ -1,4 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
if [%1]==[/?] goto :help
|
if [%1]==[/?] goto :help
|
||||||
echo %* | find "/?" > nul
|
echo %* | find "/?" > nul
|
||||||
@ -11,7 +12,7 @@ echo Bootstrap a macOS instance with:
|
|||||||
echo
|
echo
|
||||||
echo * Windows SDK - from MSDN
|
echo * Windows SDK - from MSDN
|
||||||
echo * Chocolatey - package manager
|
echo * Chocolatey - package manager
|
||||||
echo * Git - from Chocolatey
|
echo * Cmder, including Git - from Chocolatey
|
||||||
echo * Python - from Chocolatey
|
echo * Python - from Chocolatey
|
||||||
echo * virtualenv - from pip
|
echo * virtualenv - from pip
|
||||||
echo * SSH key - from ssh-keygen
|
echo * SSH key - from ssh-keygen
|
||||||
@ -35,38 +36,121 @@ if errorlevel 1 (
|
|||||||
)
|
)
|
||||||
|
|
||||||
:: Install Windows SDK
|
:: Install Windows SDK
|
||||||
|
:windows_sdk
|
||||||
|
set choice=
|
||||||
|
set /p choice="Install Windows SDK (Y/n)?"
|
||||||
|
if "%choice%"=="" goto windows_sdk_yes
|
||||||
|
if "%choice%"=="Y" goto windows_sdk_yes
|
||||||
|
if "%choice%"=="y" goto windows_sdk_yes
|
||||||
|
if "%choice%"=="N" goto windows_sdk_no
|
||||||
|
if "%choice%"=="n" goto windows_sdk_no
|
||||||
|
echo invalid value: %choice%
|
||||||
|
goto windows_sdk
|
||||||
|
:windows_sdk_yes
|
||||||
bitsadmin.exe /transfer "Download Windows SDK" https://go.microsoft.com/fwlink/p/?linkid=845298 %~dp0\winsdksetup.exe
|
bitsadmin.exe /transfer "Download Windows SDK" https://go.microsoft.com/fwlink/p/?linkid=845298 %~dp0\winsdksetup.exe
|
||||||
if errorlevel 1 exit /B 1
|
if errorlevel 1 exit /B 1
|
||||||
echo Installing: Windows SDK
|
echo Installing Windows SDK...
|
||||||
%~dp0\winsdksetup.exe /features + /q
|
%~dp0\winsdksetup.exe /features + /q
|
||||||
if errorlevel 1 exit /B 1
|
if errorlevel 1 exit /B 1
|
||||||
del %~dp0\winsdksetup.exe
|
del %~dp0\winsdksetup.exe
|
||||||
echo Installed: Windows SDK
|
:windows_sdk_no
|
||||||
|
|
||||||
:: Install Chocolatey
|
:: Install Chocolatey
|
||||||
|
:choco
|
||||||
|
set choice=
|
||||||
|
set /p choice="Install Chocolatey (Y/n)?"
|
||||||
|
if "%choice%"=="" goto choco_yes
|
||||||
|
if "%choice%"=="Y" goto choco_yes
|
||||||
|
if "%choice%"=="y" goto choco_yes
|
||||||
|
if "%choice%"=="N" goto choco_no
|
||||||
|
if "%choice%"=="n" goto choco_no
|
||||||
|
echo invalid value: %choice%
|
||||||
|
goto choco
|
||||||
|
:choco_yes
|
||||||
@"%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"
|
@"%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
|
if errorlevel 1 exit /B 1
|
||||||
echo Installed: Chocolatey
|
:choco_no
|
||||||
|
|
||||||
:: Install Git
|
:: Install Cmder, including Git
|
||||||
|
:git
|
||||||
|
set choice=
|
||||||
|
set /p choice="Install Cmder, including Git (Y/n)?"
|
||||||
|
if "%choice%"=="" goto git_yes
|
||||||
|
if "%choice%"=="Y" goto git_yes
|
||||||
|
if "%choice%"=="y" goto git_yes
|
||||||
|
if "%choice%"=="N" goto git_no
|
||||||
|
if "%choice%"=="n" goto git_no
|
||||||
|
echo invalid value: %choice%
|
||||||
|
goto git
|
||||||
|
:git_yes
|
||||||
choco install cmder --yes
|
choco install cmder --yes
|
||||||
if errorlevel 1 exit /B 1
|
if errorlevel 1 exit /B 1
|
||||||
|
:git_no
|
||||||
|
|
||||||
:: Install Python
|
:: Install Python
|
||||||
|
:python
|
||||||
|
set choice=
|
||||||
|
set /p choice="Install Python (Y/n)?"
|
||||||
|
if "%choice%"=="" goto python_yes
|
||||||
|
if "%choice%"=="Y" goto python_yes
|
||||||
|
if "%choice%"=="y" goto python_yes
|
||||||
|
if "%choice%"=="N" goto python_no
|
||||||
|
if "%choice%"=="n" goto python_no
|
||||||
|
echo invalid value: %choice%
|
||||||
|
goto python
|
||||||
|
:python_yes
|
||||||
choco install python2 --yes
|
choco install python2 --yes
|
||||||
if errorlevel 1 exit /B 1
|
if errorlevel 1 exit /B 1
|
||||||
|
:python_no
|
||||||
|
|
||||||
:: Install virtualenv
|
:: Install virtualenv
|
||||||
|
:virtualenv
|
||||||
|
set choice=
|
||||||
|
set /p choice="Install virtualenv (Y/n)?"
|
||||||
|
if "%choice%"=="" goto virtualenv_yes
|
||||||
|
if "%choice%"=="Y" goto virtualenv_yes
|
||||||
|
if "%choice%"=="y" goto virtualenv_yes
|
||||||
|
if "%choice%"=="N" goto virtualenv_no
|
||||||
|
if "%choice%"=="n" goto virtualenv_no
|
||||||
|
echo invalid value: %choice%
|
||||||
|
goto virtualenv
|
||||||
|
:virtualenv_yes
|
||||||
"C:\Python27\Scripts\pip.exe" install virtualenv
|
"C:\Python27\Scripts\pip.exe" install virtualenv
|
||||||
if errorlevel 1 exit /B 1
|
if errorlevel 1 exit /B 1
|
||||||
|
:virtualenv_no
|
||||||
|
|
||||||
:: Generate SSH key
|
:: Generate SSH key
|
||||||
|
:ssh_key
|
||||||
|
set choice=
|
||||||
|
set /p choice="Generate SSH key (Y/n)?"
|
||||||
|
if "%choice%"=="" goto ssh_key_yes
|
||||||
|
if "%choice%"=="Y" goto ssh_key_yes
|
||||||
|
if "%choice%"=="y" goto ssh_key_yes
|
||||||
|
if "%choice%"=="N" goto ssh_key_no
|
||||||
|
if "%choice%"=="n" goto ssh_key_no
|
||||||
|
echo invalid value: %choice%
|
||||||
|
goto ssh_key
|
||||||
|
:ssh_key_yes
|
||||||
mkdir %USERPROFILE%\.ssh
|
mkdir %USERPROFILE%\.ssh
|
||||||
set /P email="SSH email: "
|
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
|
"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
|
if errorlevel 1 exit /B 1
|
||||||
|
:ssh_key_no
|
||||||
|
|
||||||
:: Set SSH keys on remote Git servers
|
:: Set SSH keys on remote Git servers
|
||||||
|
:remote_ssh_keys
|
||||||
|
:: Add git to the PATH to pip can find it
|
||||||
|
set PATH=C:\tools\cmder\vendor\git-for-windows\bin;%PATH%
|
||||||
|
set choice=
|
||||||
|
set /p choice="Set SSH keys on remote Git servers (Y/n)?"
|
||||||
|
if "%choice%"=="" goto remote_ssh_keys_yes
|
||||||
|
if "%choice%"=="Y" goto remote_ssh_keys_yes
|
||||||
|
if "%choice%"=="y" goto remote_ssh_keys_yes
|
||||||
|
if "%choice%"=="N" goto remote_ssh_keys_no
|
||||||
|
if "%choice%"=="n" goto remote_ssh_keys_no
|
||||||
|
echo invalid value: %choice%
|
||||||
|
goto remote_ssh_keys
|
||||||
|
:remote_ssh_keys_yes
|
||||||
"C:\Python27\Scripts\virtualenv.exe" %~dp0\bootstrap_env
|
"C:\Python27\Scripts\virtualenv.exe" %~dp0\bootstrap_env
|
||||||
if errorlevel 1 exit /B 1
|
if errorlevel 1 exit /B 1
|
||||||
"%~dp0\bootstrap_env\Scripts\pip.exe" install git+https://code.infektor.net/config/bootstrap.git
|
"%~dp0\bootstrap_env\Scripts\pip.exe" install git+https://code.infektor.net/config/bootstrap.git
|
||||||
@ -76,5 +160,7 @@ if errorlevel 1 exit /B 1
|
|||||||
rmdir /Q /S "%~dp0\bootstrap_env"
|
rmdir /Q /S "%~dp0\bootstrap_env"
|
||||||
echo "Completed: %0 will now be removed"
|
echo "Completed: %0 will now be removed"
|
||||||
start /b "" cmd /c del "%~f0"&exit /b
|
start /b "" cmd /c del "%~f0"&exit /b
|
||||||
|
:remote_ssh_keys_no
|
||||||
|
|
||||||
:end
|
:end
|
||||||
|
endlocal
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import print_function
|
|||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
from os import environ
|
from os import environ
|
||||||
from os.path import join
|
from os.path import join
|
||||||
from platform import node
|
from platform import node, system
|
||||||
from requests import ConnectionError, get, post
|
from requests import ConnectionError, get, post
|
||||||
from requests.auth import HTTPBasicAuth
|
from requests.auth import HTTPBasicAuth
|
||||||
from requests.compat import urlparse
|
from requests.compat import urlparse
|
||||||
@ -66,7 +66,11 @@ def get_username_password(service):
|
|||||||
|
|
||||||
def get_local_key():
|
def get_local_key():
|
||||||
"""Get local SSH key."""
|
"""Get local SSH key."""
|
||||||
with open(join(environ['HOME'], '.ssh', 'id_rsa.pub'), 'r') as key_file:
|
if system() == 'Windows':
|
||||||
|
home = environ['userprofile']
|
||||||
|
else:
|
||||||
|
home = environ['HOME']
|
||||||
|
with open(join(home, '.ssh', 'id_rsa.pub'), 'r') as key_file:
|
||||||
return key_file.read().rstrip()
|
return key_file.read().rstrip()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user