Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions GatherUserInput.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ function Run {
Write-Host ""
Read-HostAndSaveToEnv -Description "Git user name (eg. John Doe)" -EnvironmentKey WIN10_DEV_BOX_GIT_USER_NAME
Read-HostAndSaveToEnv -Description "Git email (eg. john.doe@example.com)" -EnvironmentKey WIN10_DEV_BOX_GIT_EMAIL
#Read-HostAndSaveToEnv -Description "Wireguard config path (eg. C:\wg0.conf)" -EnvironmentKey WIN10_DEV_BOX_WIREGUARD_CONFIG_PATH
#if(!(Test-Path "$([Environment]::GetEnvironmentVariable("WIN10_DEV_BOX_WIREGUARD_CONFIG_PATH", "User"))")) {
# throw "Wireguard config path does not point to a file that exists!"
#}
#Read-HostAndSaveToEnv -Description "Gitlab base url (eg. http://gitlab.example.com)" -EnvironmentKey WIN10_DEV_BOX_GITLAB_BASE_URL
#Read-HostAndSaveToEnv -Description "Gitlab api token with 'read api' access (eg. qyfymyD3syW_KqVPXhMH)" -EnvironmentKey WIN10_DEV_BOX_GITLAB_TOKEN
#Read-HostAndSaveToEnv -Description "Gitlab group to clone (eg. 12)" -EnvironmentKey WIN10_DEV_BOX_GITLAB_GROUP_ID
Read-HostAndSaveToEnv -Description "Wireguard config path (eg. C:\wg0.conf)" -EnvironmentKey WIN10_DEV_BOX_WIREGUARD_CONFIG_PATH
if(!(Test-Path "$([Environment]::GetEnvironmentVariable("WIN10_DEV_BOX_WIREGUARD_CONFIG_PATH", "User"))")) {
throw "Wireguard config path does not point to a file that exists!"
}
Read-HostAndSaveToEnv -Description "Gitlab base url (eg. http://gitlab.example.com)" -EnvironmentKey WIN10_DEV_BOX_GITLAB_BASE_URL
Read-HostAndSaveToEnv -Description "Gitlab api token with 'api' access (eg. qyfymyD3syW_KqVPXhMH)" -EnvironmentKey WIN10_DEV_BOX_GITLAB_TOKEN
Read-HostAndSaveToEnv -Description "Gitlab group to clone (eg. 12)" -EnvironmentKey WIN10_DEV_BOX_GITLAB_GROUP_ID
Write-Host "Done! Do you want to launch a One Click install of SetupDeveloperMachine.ps1 i Microsoft Edge? [y/N]" -ForegroundColor green
Write-Host "> " -NoNewline
$LaunchOneClickInstall = Read-Host
Expand Down
31 changes: 29 additions & 2 deletions SetupDeveloperMachine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ function Run {
RunWindowsUpdate
AddBoxstarterDoneRestorePoint
SetGitUser
#InstallAndConfigureWireguard
#CloneAllGitlabRepositories
InstallAndConfigureWireguard
ConfigureGitlabSSH
CloneAllGitlabRepositories
OpenManualInstructions
}

Expand Down Expand Up @@ -284,6 +285,32 @@ function InstallAndConfigureWireguard {
}
}

function ConfigureGitlabSSH {
$GitlabBaseUrl = [Environment]::GetEnvironmentVariable("WIN10_DEV_BOX_GITLAB_BASE_URL", "User")
$GitlabToken = [Environment]::GetEnvironmentVariable("WIN10_DEV_BOX_GITLAB_TOKEN", "User")
if ($GitlabBaseUrl -and $GitlabToken) {
$KeyLocation = "$env:USERPROFILE/.ssh/id_ed25519"
Write-Host "Creating Gitlab SSH key.."
if (!(Test-Path $KeyLocation)) {
ssh-keygen -t ed25519 -f $KeyLocation -q -C $env:computername -N """"
Write-Host "..gitlab SSH key created"
} else {
Write-Host "..gitlab SSH key already created"
}

Write-Host "Uploading Gitlab SSH key.."
$PublicKey = Get-Content "$($KeyLocation).pub"
$CurrentKeys = Invoke-WebRequest "$GitlabBaseUrl/api/v4/user/keys?&private_token=$GitlabToken" | ConvertFrom-Json
if($CurrentKeys | Where-Object {$_.key.Split(" ")[1] -eq $PublicKey.Split(" ")[1]}) {
Write-Host "..key already uploaded"
} else {
$PostParams = @{title="Boxstarter $env:computername";key=$PublicKey}
Invoke-WebRequest -Uri "$GitlabBaseUrl/api/v4/user/keys?private_token=$GitlabToken" -Method POST -Body $PostParams
Write-Host "..key uploaded"
}
}
}

function CloneAllGitlabRepositories {
$GitlabBaseUrl = [Environment]::GetEnvironmentVariable("WIN10_DEV_BOX_GITLAB_BASE_URL", "User")
$GitlabToken = [Environment]::GetEnvironmentVariable("WIN10_DEV_BOX_GITLAB_TOKEN", "User")
Expand Down