PowerShell/Scripts/install-signal-cli.ps1

45 lines
1.4 KiB
PowerShell
Raw Normal View History

2021-06-29 20:29:22 +02:00
<#
2021-07-13 21:10:02 +02:00
.SYNOPSIS
install-signal-cli.ps1 [<version>]
.DESCRIPTION
Installs signal-cli from github.com/AsamK/signal-cli. See the Web page for the correct version number.
.EXAMPLE
PS> .\install-signal-cli.ps1 0.11.12
2021-08-29 17:50:03 +02:00
.NOTES
Author: Markus Fleschutz · License: CC0
2021-07-13 21:10:02 +02:00
.LINK
https://github.com/fleschutz/PowerShell
2021-06-29 20:29:22 +02:00
#>
2021-07-15 15:51:22 +02:00
param([string]$Version = "")
2021-06-29 20:29:22 +02:00
try {
2021-07-15 15:51:22 +02:00
if ($Version -eq "") { $Version = read-host "Enter version to install (see https://github.com/AsamK/signal-cli)" }
2021-06-29 20:29:22 +02:00
$StopWatch = [system.diagnostics.stopwatch]::startNew()
set-location /tmp
& wget --version
if ($lastExitCode -ne "0") { throw "Can't execute 'wget' - make sure wget is installed and available" }
& wget "https://github.com/AsamK/signal-cli/releases/download/v$Version/signal-cli-$($Version).tar.gz"
if ($lastExitCode -ne "0") { throw "'wget' failed" }
sudo tar xf "signal-cli-$Version.tar.gz" -C /opt
if ($lastExitCode -ne "0") { throw "'sudo tar xf' failed" }
2021-06-29 20:35:17 +02:00
sudo ln -sf "/opt/signal-cli-$Version/bin/signal-cli" /usr/local/bin/
2021-06-29 20:29:22 +02:00
if ($lastExitCode -ne "0") { throw "'sudo ln -sf' failed" }
2021-06-29 20:35:17 +02:00
rm "signal-cli-$Version.tar.gz"
if ($lastExitCode -ne "0") { throw "'rm' failed" }
2021-06-29 20:29:22 +02:00
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ installed signal-cli $Version to /opt and /usr/local/bin in $Elapsed sec"
exit 0
} catch {
2021-09-16 20:19:10 +02:00
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
2021-06-29 20:29:22 +02:00
exit 1
}