Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 70 lines (61 sloc) 1.791 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

function Install-Cygwin {
  $client = New-Object Net.WebClient
  $cygwinInstaller = Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName() + ".exe")
  
  $client.DownloadFile("http://cygwin.com/setup-x86.exe", $cygwinInstaller)
  
  $packages = @(
    'libintl8',
    'libgcc1',
    'libncursesw10',
    'libiconv2',
    'libattr1',
    'csih',
    'libpcre0',
    'libmpfr4',
    'cygrunsrv',
    'diffutils',
    'libgmp3',
    'libgmp10',
    'libwrap0',
    'libkrb5_26',
    'libkafs0',
    'libgssapi3',
    'libopenssl100',
    'crypt',
    'libssp0',
    'libheimntlm0',
    'libcom_err2',
    'libheimbase1',
    'libasn1_8',
    'libwind0',
    'libhx509_5',
    'libsqlite3_0',
    'libroken18',
    'openssh'
  )

  $process = Start-Process -PassThru $cygwinInstaller --quiet-mode, --site, http://mirrors.kernel.org/sourceware/cygwin, --local-package-dir, C:\ProgramData\Cygwin, --packages, ($packages -join ",")
  Wait-Process -InputObject $process
  if ($process.ExitCode -ne 0) {
    throw "Error installing Cygwin"
  }
}

function Create-RootDirectory {
  # Our bootstrapping scripts rely on /root existing in a bash shell.
  New-Item C:\cygwin\root -Type Directory | Out-Null
}

function Rebase {
  c:\cygwin\bin\dash.exe -c '/usr/bin/rebaseall'
}

function Register-Sshd {
  Add-Type -Assembly System.Web
  $password = [Web.Security.Membership]::GeneratePassword(16, 4)
  C:\cygwin\bin\bash.exe --login -- /usr/bin/ssh-host-config --yes --user cyg_server --pwd $password
  netsh advfirewall firewall add rule name=sshd dir=in action=allow program=C:\cygwin\usr\sbin\sshd.exe localport=22 protocol=tcp
  net start sshd
}

Install-Cygwin
Rebase
Create-RootDirectory
Register-Sshd
Restart-Computer
Something went wrong with that request. Please try again.