add install instructions

This commit is contained in:
Jonas Leder 2024-08-03 23:34:15 +02:00
commit 346b8753ae
2 changed files with 30 additions and 1 deletions

View file

@ -6,4 +6,8 @@ This is a Cloud-Init Agent for Windows. It's used to deploy VServer at [Realtoxm
- IP Addresses
- Password
As windows needs the password in Cleartext, it cannot be set directly from the Cloud-Init configuration. We implemented a special IP, which compares the hashed password ( which is provided via Cloud-Init ), with the unencrypted password, saved in WHMCS. The Password can be found [here](https://git.itbyhf.xyz/ha/windows-cloudinit-pwapi)
As windows needs the password in Cleartext, it cannot be set directly from the Cloud-Init configuration. We implemented a special IP, which compares the hashed password ( which is provided via Cloud-Init ), with the unencrypted password, saved in WHMCS. The Password can be found [here](https://git.itbyhf.xyz/ha/windows-cloudinit-pwapi)
## Installation
There is a script called `install.ps1`. Copy this script to the VM and execute it using powershell. It will download the latest version and register the service. After installing place the `config.json` in the `C:\Cloud-Init` folder. Now the image is prepared and you can reset it to the OOBE mode with the unattend.xml file and the following command: `C:\Windows\system32\sysprep\sysprep.exe /generalize /oobe /shutdown /unattend:"C:\Cloud-Init\unattend.xml"`

25
install.ps1 Normal file
View file

@ -0,0 +1,25 @@
$cloudinitUrl = "https://s3.jonasled.de/share/cloudinit-windows-amd64.exe"
$nssmUrl = "https://nssm.cc/release/nssm-2.24.zip"
$workDir = 'C:\Cloud-Init'
$cloudInitTargetPath = "$workDir\cloud-init.exe"
$nssmTargetPath = "$workDir\nssm.zip"
$nssmPath = "$workDir\nssm-2.24\win64\nssm.exe"
$serviceName = "Cloud-Init"
New-Item -Path "c:\" -Name "Cloud-Init" -ItemType "directory"
Write-Host "Downloading Cloud-Init..."
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $cloudinitUrl -OutFile $cloudInitTargetPath
Write-Host "Downloading NSSM..."
Invoke-WebRequest -Uri $nssmUrl -OutFile $nssmTargetPath
Expand-Archive -LiteralPath $nssmTargetPath -DestinationPath $workDir
Remove-Item $nssmTargetPath
Start-Process -FilePath $nssmPath -ArgumentList "install $serviceName $cloudInitTargetPath" -NoNewWindow -Wait
Start-Process -FilePath $nssmPath -ArgumentList "set $serviceName AppDirectory $workDir" -NoNewWindow -Wait
Start-Process -FilePath $nssmPath -ArgumentList "set $serviceName Start SERVICE_AUTO_START" -NoNewWindow -Wait
Start-Process -FilePath $nssmPath -ArgumentList "set $serviceName AppExit Default Ignore" -NoNewWindow -Wait