mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-02-14 17:49:53 +00:00
50 lines
1.4 KiB
PowerShell
50 lines
1.4 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
|
|
$ErrorActionPreference = 'stop'
|
|
|
|
function Install-WebiHostedScript () {
|
|
Param(
|
|
[string]$Package,
|
|
[string]$ScriptName
|
|
)
|
|
$PwshName = "_${ScriptName}.ps1"
|
|
$PwshUrl = "${Env:WEBI_HOST}/packages/${Package}/${ScriptName}.ps1"
|
|
$PwshPath = "$HOME\.local\bin\${PwshName}"
|
|
$OldPath = "$HOME\.local\bin\${ScriptName}.ps1"
|
|
|
|
$BatPath = "$HOME\.local\bin\${ScriptName}.bat"
|
|
$PwshExec = "powershell -ExecutionPolicy Bypass"
|
|
$Bat = "@echo off`r`n$PwshExec %USERPROFILE%\.local\bin\${PwshName} %*"
|
|
|
|
Invoke-DownloadUrl -Force -URL $PwshUrl -Path $PwshPath
|
|
Set-Content -Path $BatPath -Value $Bat
|
|
Write-Host " Created alias ${BatPath}"
|
|
Write-Host " to run ${PwshPath}"
|
|
|
|
# fix for old installs
|
|
Remove-Item -Path $OldPath -Force -ErrorAction Ignore
|
|
}
|
|
|
|
Install-WebiHostedScript -Package "gpg-pubkey" -ScriptName "gpg-pubkey-id"
|
|
Install-WebiHostedScript -Package "gpg-pubkey" -ScriptName "gpg-pubkey"
|
|
|
|
#
|
|
# Check the gpg exists
|
|
#
|
|
IF (-Not (Get-Command -Name "gpg" -ErrorAction SilentlyContinue)) {
|
|
& "${Env:USERPROFILE}\.local\bin\webi-pwsh.ps1" gpg
|
|
$Env:Path = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
|
|
IF (-Not (Get-Command -Name "gpg" -ErrorAction SilentlyContinue)) {
|
|
Write-Output ""
|
|
Write-Output "(exited because gpg is not installed)"
|
|
Write-Output ""
|
|
Exit 1
|
|
}
|
|
}
|
|
|
|
#
|
|
# run gpg-pubkey
|
|
#
|
|
& "$Env:USERPROFILE\.local\bin\gpg-pubkey.bat"
|