mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-23 18:38:19 +02:00
Added install-h2static.ps1
This commit is contained in:
parent
a3331f5172
commit
32927260bd
41
scripts/install-h2static.ps1
Executable file
41
scripts/install-h2static.ps1
Executable file
@ -0,0 +1,41 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Installs h2static
|
||||
.DESCRIPTION
|
||||
This PowerShell script installs the tiny static Web server 'h2static'.
|
||||
.EXAMPLE
|
||||
PS> ./install-h2static.ps1
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([int]$port = 8070, [string]$pathToMedia = "/media/")
|
||||
|
||||
try {
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
if (-not($IsLinux)) { throw "Sorry, only Linux installation currently supported" }
|
||||
|
||||
"⏳ (1/4) Installing h2static from Snap Store..."
|
||||
& sudo snap install h2static
|
||||
|
||||
$pathToMedia = Resolve-Path $pathToMedia
|
||||
"⏳ (2/4) Configuring serve-path = $pathToMedia ..."
|
||||
& sudo snap set h2static serve-path=$pathToMedia
|
||||
& sudo snap connect h2static:removable-media
|
||||
|
||||
"⏳ (3/4) Configuring disable-index = false..."
|
||||
& sudo snap set h2static disable-index=false
|
||||
|
||||
"⏳ (4/4) Configuring listening-port = :$port..."
|
||||
& sudo snap set h2static listen=:$port
|
||||
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ h2static installed in $($elapsed)s, Web server runs at :$port, execute 'snap info h2static' for details."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"Sorry: $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user