$ErrorActionPreference = 'Stop'; $toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" $appDir = "$([Environment]::GetFolderPath('ProgramFiles'))\Yggdrasil" $confDir = "$([Environment]::GetFolderPath('CommonApplicationData'))\Yggdrasil" $startMenuDir = "$([Environment]::GetFolderPath('CommonStartMenu'))\Programs\Yggdrasil" $url = 'https://ci.appveyor.com/api/buildjobs/55fx2dl3atc2s77t/artifacts/yggdrasil-0.3.13-x86.msi' $url64 = 'https://ci.appveyor.com/api/buildjobs/55fx2dl3atc2s77t/artifacts/yggdrasil-0.3.13-x64.msi' $checksum = 'eeb47dadc33c3018c3d8a74615999fe1da9a5305e299b6143f7a301f06ffe145' $checksum64 = 'fc9619d09a1a4972a90fc1b2fdcf2d09a0336213c3ccf7f7b3f51233e3f2ba9c' $packageArgs = @{ packageName = $env:ChocolateyPackageName fileType = 'msi' url = $url url64bit = $url64 checksum = $checksum checksumType = 'sha256' checksum64 = $checksum64 checksumType64 = 'sha256' softwareName = 'Yggdrasil Network*' silentArgs = '/quiet' validExitCodes = @(0) } # Backup old configuration if (Test-Path "$confDir\yggdrasil.conf" -PathType Leaf) { $date = Get-Date -format "yyyyMMdd" Write-Host "Backing up configuration file to yggdrasil.conf.$date" Copy-Item $confDir\yggdrasil.conf -Destination $confDir\yggdrasil.conf.$date } Install-ChocolateyPackage @packageArgs Install-BinFile "yggdrasil" "$appDir\yggdrasil.exe" Install-BinFile "yggdrasilctl" "$appDir\yggdrasilctl.exe" # Creating shortcuts in Start Menu if (-not (Test-Path -Path $startMenuDir)) { New-Item -Path $startMenuDir -ItemType Directory } Install-ChocolateyShortcut -shortcutFilePath "$startMenuDir\Start service.lnk" ` -targetPath "$toolsDir\service-start.bat" -workDirectory "$appDir" -description "Start yggdrasil service" -RunAsAdmin Install-ChocolateyShortcut -shortcutFilePath "$startMenuDir\Restart service.lnk" ` -targetPath "$toolsDir\service-restart.bat" -workDirectory "$appDir" -description "Restart yggdrasil service" -RunAsAdmin Install-ChocolateyShortcut -shortcutFilePath "$startMenuDir\Stop service.lnk" ` -targetPath "$toolsDir\service-stop.bat" -workDirectory "$appDir" -description "Stop yggdrasil service" -RunAsAdmin