Skip to content

Instantly share code, notes, and snippets.

@cromulus
Forked from mefellows/vagrant-bootstrapper.ps1
Last active January 5, 2016 15:37
Show Gist options
  • Save cromulus/512897d541348c8d8de6 to your computer and use it in GitHub Desktop.
Save cromulus/512897d541348c8d8de6 to your computer and use it in GitHub Desktop.
Windows Vagrant with Rsync powershell bootstrap script
Write-Host -ForegroundColor green "Bootstrapping machine"
Write-Host "Setting up package management and installing required packages for Dev."
#
# Install Choco (if not already installed) + required packages
#
if ( (Get-Command "choco" -errorAction SilentlyContinue) ) {
Write-Host "Chocolatey already installed. Skipping."
} else {
Write-Host "Installing Chocolatey"
$wc=new-object net.webclient; $wp=[system.net.WebProxy]::GetDefaultProxy(); $wp.UseDefaultCredentials=$true; $wc.Proxy=$wp; iex ($wc.DownloadString('https://chocolatey.org/install.ps1'))
$env:Path = $env:Path + ";C:\ProgramData\chocolatey\bin"
[Environment]::SetEnvironmentVariable( "Path", $env:Path, [System.EnvironmentVariableTarget]::Machine )
}
Write-Host "Installing required packages."
$packages = @(
"git.commandline"
"git"
"cyg-get"
)
$packages.ForEach({ cinst $_ })
Write-Host "Packages installed"
Write-Host "Configuring Cygwin for use with SSH"
# Setup SSH / Rsync for use with Vagrant
$OLD_USER_PATH=[Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
$OLD_MACHINE_PATH=[Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::Machine)
cyg-get rsync
cyg-get openssh
$CYG_PATH = "c:\tools\cygwin\;c:\tools\cygwin\bin"
[Environment]::SetEnvironmentVariable("PATH", "${OLD_USER_PATH};${CYG_PATH}", "User")
[Environment]::SetEnvironmentVariable("PATH", "${OLD_MACHINE_PATH};${CYG_PATH}", "Machine")
# TODO: Add to Git Bash Path /c/tools/cygwin/bootstrapping
Write-Host "Cygwin configuration complete."
Write-Host "Installing Vagrant and friends... This will take a little bit of time"
cinst vagrant virtualbox virtualbox.extensionpack
Write-Host "Vagrant and friends installed, Installing required Vagrant plugins..."
vagrant plugin install vagrant-proxyconf vagrant-cachier vagrant-hostmanager
Write-Host -ForegroundColor green "OK. If there were no exceptions above then you could probably run a 'vagrant up' now!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment