Skip to content

Instantly share code, notes, and snippets.

@mefellows
Created December 17, 2014 00:53
Show Gist options
  • Save mefellows/80b05f8af9fd9f526ec5 to your computer and use it in GitHub Desktop.
Save mefellows/80b05f8af9fd9f526ec5 to your computer and use it in GitHub Desktop.

Revisions

  1. mefellows created this gist Dec 17, 2014.
    51 changes: 51 additions & 0 deletions vagrant-bootstrapper.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    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-hostsupdater

    Write-Host "Vagrant plugins complete. Pulling down 'talent-search-web' box and importing into Vagrant..."
    vagrant box add BOX_NAME PATH_TO_BOX

    Write-Host "Vagrant box downloaded."
    Write-Host -ForegroundColor green "OK. If there were no exceptions above then you could probably run a 'vagrant up' now!"