PowerShell/Scripts/install-signal-cli.ps1

48 lines
1.4 KiB
PowerShell
Raw Normal View History

2021-09-27 10:38:12 +02:00
<#
2021-07-13 21:10:02 +02:00
.SYNOPSIS
2021-10-04 21:29:23 +02:00
Installs signal-cli
2021-07-13 21:10:02 +02:00
.DESCRIPTION
2022-01-29 12:47:46 +01:00
This PowerShell script installs signal-cli from github.com/AsamK/signal-cli.
See the Web page for the correct version number.
2021-10-16 16:50:10 +02:00
.PARAMETER Version
Specifies the version to install
2021-07-13 21:10:02 +02:00
.EXAMPLE
2021-09-24 17:19:49 +02:00
PS> ./install-signal-cli 0.11.12
2021-07-13 21:10:02 +02:00
.LINK
https://github.com/fleschutz/PowerShell
2022-01-29 12:47:46 +01:00
.NOTES
2022-09-06 21:42:04 +02:00
Author: Markus Fleschutz | License: CC0
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"
2021-09-27 10:09:45 +02:00
exit 0 # success
2021-06-29 20:29:22 +02:00
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2021-06-29 20:29:22 +02:00
exit 1
}