more bullshit IN!
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Version,
|
||||
[Parameter(Mandatory = $true)][string]$Target,
|
||||
[string]$OutDir = "dist"
|
||||
[string]$OutDir = "dist",
|
||||
[switch]$NoBin
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
@@ -17,7 +18,6 @@ New-Item -ItemType Directory -Force -Path $dist | Out-Null
|
||||
|
||||
$binName = if ($Target -like "*-windows-*") { "wakey.exe" } else { "wakey" }
|
||||
$binSrc = Join-Path $root "target/$Target/release/$binName"
|
||||
if (-not (Test-Path $binSrc)) { throw "Missing binary: $binSrc (build it first)" }
|
||||
|
||||
$staging = Join-Path $dist ("rootfs-" + [System.Guid]::NewGuid().ToString("N"))
|
||||
New-Item -ItemType Directory -Force -Path $staging | Out-Null
|
||||
@@ -28,13 +28,37 @@ $etcDir = Join-Path $staging "etc/init.d"
|
||||
New-Item -ItemType Directory -Force -Path $rootDir | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $etcDir | Out-Null
|
||||
|
||||
Copy-Item $binSrc (Join-Path $rootDir "wakey") -Force
|
||||
Copy-Item (Join-Path $root 'scripts/kill.sh') (Join-Path $rootDir "kill_wakey.sh") -Force
|
||||
if (-not $NoBin) {
|
||||
if (Test-Path $binSrc) {
|
||||
Copy-Item $binSrc (Join-Path $rootDir "wakey") -Force
|
||||
}
|
||||
else {
|
||||
throw "Missing binary: $binSrc (build it first or pass -NoBin)"
|
||||
}
|
||||
}
|
||||
# Normalize kill script line endings and copy
|
||||
$killSrc = Join-Path $root 'scripts/kill_wakey.sh'
|
||||
if (Test-Path $killSrc) {
|
||||
$killContent = Get-Content -Raw -LiteralPath $killSrc
|
||||
$killContent = $killContent -replace "`r`n", "`n"
|
||||
Set-Content -NoNewline -LiteralPath (Join-Path $rootDir "kill_wakey.sh") -Value $killContent -Encoding UTF8
|
||||
}
|
||||
|
||||
# Normalize remote deploy script and copy (optional helper)
|
||||
$deploySrc = Join-Path $root 'scripts/remote_deploy_wakey.sh'
|
||||
if (Test-Path $deploySrc) {
|
||||
$deployContent = Get-Content -Raw -LiteralPath $deploySrc
|
||||
$deployContent = $deployContent -replace "`r`n", "`n"
|
||||
Set-Content -NoNewline -LiteralPath (Join-Path $rootDir "remote_deploy_wakey.sh") -Value $deployContent -Encoding UTF8
|
||||
}
|
||||
|
||||
# Copy all OpenWrt init scripts present in repo
|
||||
Get-ChildItem (Join-Path $root 'scripts/init/openwrt') -File | ForEach-Object {
|
||||
$dest = Join-Path $etcDir $_.Name
|
||||
Copy-Item $_.FullName $dest -Force
|
||||
$content = Get-Content -Raw -LiteralPath $_.FullName
|
||||
# normalize to LF line endings
|
||||
$content = $content -replace "`r`n", "`n"
|
||||
Set-Content -NoNewline -LiteralPath $dest -Value $content -Encoding UTF8
|
||||
}
|
||||
|
||||
# Copy helper scripts intended for /etc/ldlda_help
|
||||
@@ -43,7 +67,10 @@ if (Test-Path $helpSrc) {
|
||||
$etcHelpDir = Join-Path $staging 'etc/ldlda_help'
|
||||
New-Item -ItemType Directory -Force -Path $etcHelpDir | Out-Null
|
||||
Get-ChildItem $helpSrc -File | ForEach-Object {
|
||||
Copy-Item $_.FullName (Join-Path $etcHelpDir $_.Name) -Force
|
||||
$d = Join-Path $etcHelpDir $_.Name
|
||||
$c = Get-Content -Raw -LiteralPath $_.FullName
|
||||
$c = $c -replace "`r`n", "`n"
|
||||
Set-Content -NoNewline -LiteralPath $d -Value $c -Encoding UTF8
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,5 +92,9 @@ Remove-Item -Recurse -Force $staging
|
||||
Write-Host "Rootfs package: " (Join-Path $dist $pkgName)
|
||||
Write-Host "On router: wget -O- <URL/$pkgName> | tar -xz -C /"
|
||||
Write-Host "Then: chmod +x /etc/init.d/wakey && /etc/init.d/wakey enable && /etc/init.d/wakey start"
|
||||
if ($NoBin) {
|
||||
Write-Host "Note: -NoBin used, binary not included. Only scripts/configs were packaged." -ForegroundColor Yellow
|
||||
}
|
||||
Write-Host "Helper scripts: /etc/ldlda_help/* (e.g., update_wakey.sh, update_tailscale.sh). Mark executable if needed: chmod +x /etc/ldlda_help/*.sh"
|
||||
Write-Host "Kill helper: /root/.bin/kill_wakey.sh (make it executable: chmod +x /root/.bin/kill_wakey.sh)"
|
||||
<# if (Test-Path $deploySrc) { #> Write-Host "Deploy helper: /root/.bin/remote_deploy_wakey.sh (chmod +x /root/.bin/remote_deploy_wakey.sh)" # }
|
||||
|
||||
Reference in New Issue
Block a user