2019-11-22 04:04:12 +03:00
|
|
|
|
$ErrorActionPreference = 'Stop';
|
|
|
|
|
|
|
|
|
|
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
|
|
|
|
|
$appDir = "$([Environment]::GetFolderPath('ProgramFiles'))\Yggdrasil"
|
2019-12-20 13:03:48 +03:00
|
|
|
|
$confDir = "$([Environment]::GetFolderPath('CommonApplicationData'))\Yggdrasil"
|
2019-11-22 04:04:12 +03:00
|
|
|
|
$startMenuDir = "$([Environment]::GetFolderPath('CommonStartMenu'))\Programs\Yggdrasil"
|
|
|
|
|
|
2021-07-24 12:52:51 +03:00
|
|
|
|
$url = 'https://github.com/yggdrasil-network/yggdrasil-go/releases/download/v0.4.0/yggdrasil-0.4-x86.msi'
|
|
|
|
|
$url64 = 'https://github.com/yggdrasil-network/yggdrasil-go/releases/download/v0.4.0/yggdrasil-0.4-x64.msi'
|
|
|
|
|
$checksum = '7ed72fc468b59cb0e02b9d8f9fd9d019327ace99df9974e2a47b250b93a257ec'
|
|
|
|
|
$checksum64 = 'a17f88d1c7ab34199d82b44a972a3f55351a52a63b0a32fb0d2232ea35791b9a'
|
2019-11-22 04:04:12 +03:00
|
|
|
|
|
|
|
|
|
$packageArgs = @{
|
2019-12-20 13:03:48 +03:00
|
|
|
|
packageName = $env:ChocolateyPackageName
|
|
|
|
|
fileType = 'msi'
|
|
|
|
|
|
2019-11-22 04:04:12 +03:00
|
|
|
|
url = $url
|
|
|
|
|
url64bit = $url64
|
|
|
|
|
|
2019-12-20 13:03:48 +03:00
|
|
|
|
checksum = $checksum
|
2019-11-22 04:04:12 +03:00
|
|
|
|
checksumType = 'sha256'
|
2019-12-20 13:03:48 +03:00
|
|
|
|
checksum64 = $checksum64
|
2019-11-22 04:04:12 +03:00
|
|
|
|
checksumType64 = 'sha256'
|
|
|
|
|
|
2019-12-20 13:03:48 +03:00
|
|
|
|
softwareName = 'Yggdrasil Network*'
|
|
|
|
|
silentArgs = '/quiet'
|
|
|
|
|
validExitCodes = @(0)
|
2019-11-22 04:04:12 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-20 13:03:48 +03:00
|
|
|
|
# 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
|
2019-11-22 04:04:12 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-20 13:03:48 +03:00
|
|
|
|
Install-ChocolateyPackage @packageArgs
|
2019-11-22 04:04:12 +03:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-10 02:35:00 +03:00
|
|
|
|
# Get PowerShell executable path
|
|
|
|
|
$psPath = (Get-Command powershell.exe).Path
|
|
|
|
|
|
2019-12-20 13:03:48 +03:00
|
|
|
|
Install-ChocolateyShortcut -shortcutFilePath "$startMenuDir\Start service.lnk" `
|
2020-03-10 02:35:00 +03:00
|
|
|
|
-targetPath $psPath -Arguments "Start-Service -name 'Yggdrasil'" `
|
|
|
|
|
-workDirectory "$appDir" -description "Start yggdrasil service" -IconLocation "$toolsDir\yggdrasil.ico" -RunAsAdmin
|
2019-11-22 04:04:12 +03:00
|
|
|
|
Install-ChocolateyShortcut -shortcutFilePath "$startMenuDir\Restart service.lnk" `
|
2020-03-10 02:35:00 +03:00
|
|
|
|
-targetPath $psPath -Arguments "Restart-Service -name 'Yggdrasil'" `
|
|
|
|
|
-workDirectory "$appDir" -description "Restart yggdrasil service" -IconLocation "$toolsDir\yggdrasil.ico" -RunAsAdmin
|
2019-12-20 13:03:48 +03:00
|
|
|
|
Install-ChocolateyShortcut -shortcutFilePath "$startMenuDir\Stop service.lnk" `
|
2020-03-10 02:35:00 +03:00
|
|
|
|
-targetPath $psPath -Arguments "Stop-Service -name 'Yggdrasil'" `
|
|
|
|
|
-workDirectory "$appDir" -description "Stop yggdrasil service" -IconLocation "$toolsDir\yggdrasil.ico" -RunAsAdmin
|