-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathDownload.ps1
More file actions
43 lines (34 loc) · 1.76 KB
/
Copy pathDownload.ps1
File metadata and controls
43 lines (34 loc) · 1.76 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
$GitHubRepositoryUri = "https://github.com/${GitHubRepositoryAuthor}/${GitHubRepositoryName}/archive/refs/heads/main.zip";
$DotfilesFolder = Join-Path -Path $HOME -ChildPath ".dotfiles";
$ZipRepositoryFile = Join-Path -Path $DotfilesFolder -ChildPath "${GitHubRepositoryName}-main.zip";
$DotfilesWorkFolder = Join-Path -Path $DotfilesFolder -ChildPath "${GitHubRepositoryName}-main" | Join-Path -ChildPath "src";
$DownloadResult = $FALSE;
# Request custom values
$ComputerName = Read-Host -Prompt "Input the new computer name here";
$GitUserName = Read-Host -Prompt "Input your Git user name here";
$GitUserEmail = Read-Host -Prompt "Input your Git user email here";
$ValidDisks = Get-PSDrive -PSProvider "FileSystem" | Select-Object -ExpandProperty "Root";
do {
Write-Host "Choose the location of your development workspace:" -ForegroundColor "Green";
Write-Host $ValidDisks -ForegroundColor "Green";
$WorkspaceDisk = Read-Host -Prompt "Please choose one of the available disks";
}
while (-not ($ValidDisks -Contains $WorkspaceDisk));
# Create Dotfiles folder
if (Test-Path $DotfilesFolder) {
Remove-Item -Path $DotfilesFolder -Recurse -Force;
}
New-Item $DotfilesFolder -ItemType directory;
# Download Dotfiles repository as Zip
Try {
Invoke-WebRequest $GitHubRepositoryUri -O $ZipRepositoryFile;
$DownloadResult = $TRUE;
}
catch [System.Net.WebException] {
Write-Host "Error connecting to GitHub, check the internet connection or the repository url." -ForegroundColor "Red";
}
if ($DownloadResult) {
Add-Type -AssemblyName System.IO.Compression.FileSystem;
[System.IO.Compression.ZipFile]::ExtractToDirectory($ZipRepositoryFile, $DotfilesFolder);
Invoke-Expression (Join-Path -Path $DotfilesWorkFolder -ChildPath "Setup.ps1");
}