forked from bandit145/vmware-template-builds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure-machine.ps1
26 lines (23 loc) · 1.24 KB
/
configure-machine.ps1
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
$ErrorActionPreference = "Stop"
$version = (Get-Content config.json | ConvertFrom-JSON)."packer-plugin"
choco -y install packer
Invoke-WebRequest -Uri "https://github.com/jetbrains-infra/packer-builder-vsphere/releases/download/v$version/packer-builder-vsphere-iso.exe" -OutFile "~/Downloads/packer-builder-vsphere-iso.exe"
if (!(Test-Path "~/Appdata/Roaming/packer.d/plugins")){
New-Item -Type "Directory" -Path "~/Appdata/Roaming/packer.d/plugins/"
Write-Output "Created plugins directory"
}
if((Test-Path "~/Appdata/Roaming/packer.d/plugins/packer-builder-vsphere-iso.exe")){
$hash1 = (Get-FileHash "~/Appdata/Roaming/packer.d/plugins/packer-builder-vsphere-iso.exe").hash
$hash2 = (Get-FileHash "~/Downloads/packer-builder-vsphere-iso.exe").hash
if(!$hash1 -eq $hash2){
Write-Output "Hashes did not match, packer plugin updated"
Move-Item "~/Downloads/packer-builder-vsphere-iso.exe" "~/Appdata/Roaming/packer.d/plugins/packer-builder-vsphere-iso.exe" -Force
}
else{
Write-Output "You have the current version of the plugin"
}
}
else{
Write-Output "Adding plugin"
Move-Item "~/Downloads/packer-builder-vsphere-iso.exe" "~/Appdata/Roaming/packer.d/plugins/packer-builder-vsphere-iso.exe" -Force
}