-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.ps1
48 lines (38 loc) · 1.92 KB
/
install.ps1
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
$ErrorActionPreference = "Stop"
if (-not (Get-Command "bash.exe" -ErrorAction SilentlyContinue)) {
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
if ([Environment]::Is64BitProcess) {
$output = 'setup-x86_64.exe'
$cygpath = 'C:\cygwin64\bin'
} else {
$output = 'setup-x86.exe'
$cygpath = 'C:\cygwin\bin'
}
$directory = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
New-Item -ItemType directory -Path "$directory"
Set-Location -Path "$directory"
echo "Working in $directory"
$url = "https://cygwin.com/$output"
echo "Downloading Cygwin installer"
(New-Object System.Net.WebClient).DownloadFile($url, "$directory\$output")
echo "Installing Cygwin"
Start-Process powershell "-Command $directory\\$output -q -W --site http://cygwin.mirror.constant.com" -Verb runAs -PassThru -Wait
Remove-Item -ErrorAction Ignore -Force -Recurse "$directory"
$currentPath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
if (($currentPath).ToLower().Contains("c:\cygwin")) {
echo "Cygwin is already on the path"
} else {
echo "Adding Cygwin to the path"
[Environment]::SetEnvironmentVariable('Path', "$currentPath;$cygpath", 'Machine');
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'User')
}
echo "Using windows home directories"
bash -c "if ! grep -q '^db_home:' /etc/nsswitch.conf; then echo 'db_home: windows' >> /etc/nsswitch.conf; fi"
}
echo "Installing forklift"
if (-not (Test-Path env:INSTALL_URL)) { $env:INSTALL_URL = 'https://raw.githubusercontent.com/g2forge/forklift/master/install' }
bash -l -c "bash <`(curl -L $env:INSTALL_URL`) $args"
rm $PSCommandPath