Select Git revision
SharedRessources.java
-
NET-D3v3l0p3r authoredNET-D3v3l0p3r authored
Install.ps1 2.33 KiB
$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
""