Skip to content
Snippets Groups Projects
Commit 8a25cfa0 authored by Dennis Ahrens's avatar Dennis Ahrens
Browse files

Initial commit

parent d73a3960
No related branches found
No related tags found
No related merge requests found
$targetDirectory = "C:\hshgitlab"
$gitDir = "${env:programfiles}\Git\"
$sshKeygenExe = "$gitDir\usr\bin\ssh-keygen.exe"
$sshKeyName = "$targetDirectory\id_rsa"
$sshPublicKey = "$sshKeyName.pub"
<#
Check whether a program is installed.
Note that is searches in the string which you can find in Control Panel -> Programs and Features.
e.g. it will not find "python3" but "python 3"
#>
function Is-Installed($program) {
$x86 = ((Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall") |
Where-Object { $_.GetValue( "DisplayName" ) -like "*$program*" } ).Length -gt 0;
$x64 = ((Get-ChildItem "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall") |
Where-Object { $_.GetValue( "DisplayName" ) -like "*$program*" } ).Length -gt 0;
return $x86 -or $x64;
}
"Install just-install for painless installs..."
if(Is-Installed("just-install")) {
"just-install is already installed"
} else {
Start-Process -NoNewWindow msiexec.exe -Wait -ArgumentList '-I https://stable.just-install.it -quiet'
}
"Install git"
if(Is-Installed("git")) {
"git is already installed"
} else {
Start-Process -NoNewWindow just-install -Wait -ArgumentList 'python3'
}
"Make some sanity checks in the environment - verify python and git are located where we think they are..."
if (!(Test-Path $pythonExe) ) {
"python.exe is not located at: $pythonExe"
"either the installation was not successful or the path changed."
}
if (!(Test-Path $gitDir) ) {
"git installation not found at: $gitDir"
"either the installation was not successful or the path changed."
}
"Sanity successfully verified: begin to install our worker"
"Create a directory for our files at $targetDirectory"
if(!(Test-Path -Path $targetDirectory )){
New-Item -ItemType directory -Path $targetDirectory | Out-Null
}
"Generate an SSH Keypair for our server to be able to receive code from git"
"It is located at $sshKeyName(.pub)"
if (!(Test-Path $sshKeyName) ) {
Start-Process -NoNewWindow $sshKeygenExe -Wait -ArgumentList "-q -b 4096 -f $sshKeyName -N ''"
} else {
"There was already a key located at $sshKeyName, proceed with this one"
}
if (!(Test-Path $sshKeyName) ) {
"Key generation not successful"
exit
}
"You now need to tell gitlab about this ssh public key and can proceed with what you want to install"
""
cat $sshPublicKey
""
......@@ -2,3 +2,9 @@
Use this repository to bootstrap git on your windows box.
It also automatically creates a key pair that can be used to connect to a git server.
Be careful, this executes code directly on your machine. You are expected to read the script before you execute it.
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://lab.it.hs-hannover.de/powershell/bootstrap-git/raw/master/Install.ps1'))
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment