This commit is contained in:
@@ -10,7 +10,9 @@ param(
|
|||||||
# Opt-in to non-interactive configure; by default we print the command for you to run manually.
|
# Opt-in to non-interactive configure; by default we print the command for you to run manually.
|
||||||
[switch]$ForceConfigure,
|
[switch]$ForceConfigure,
|
||||||
# When -Attach, run in the foreground to see logs (good for first-time troubleshooting)
|
# When -Attach, run in the foreground to see logs (good for first-time troubleshooting)
|
||||||
[switch]$Attach
|
[switch]$Attach,
|
||||||
|
# Run one job then exit (great for CI tag pushes)
|
||||||
|
[switch]$Once
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
@@ -50,11 +52,13 @@ if (-not (Test-Path $configFile)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Attach) {
|
if ($Attach -or $Once) {
|
||||||
Write-Host "Starting act_runner (attached)... Ctrl+C to stop"
|
Write-Host "Starting act_runner $(if ($Once) {'(once mode)'} else {'(attached)'})... $(if (-not $Once) {'Ctrl+C to stop'})"
|
||||||
$configParent = Split-Path -Parent $configFile
|
$configParent = Split-Path -Parent $configFile
|
||||||
Push-Location $configParent
|
Push-Location $configParent
|
||||||
& $RunnerPath daemon --config $configFile
|
$daemonArgs = @('daemon', '--config', $configFile)
|
||||||
|
if ($Once) { $daemonArgs += '--once' }
|
||||||
|
& $RunnerPath @daemonArgs
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+2
-56
@@ -15,23 +15,7 @@ param(
|
|||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
try { $PSStyle.OutputRendering = 'Host' } catch {}
|
try { $PSStyle.OutputRendering = 'Host' } catch {}
|
||||||
|
|
||||||
function Invoke-Ext {
|
. "$PSScriptRoot/lib.ps1"
|
||||||
param($Exe, $Arguments, $Label)
|
|
||||||
$displayArgs = $Arguments.Clone()
|
|
||||||
for ($i = 0; $i -lt $displayArgs.Count; $i++) {
|
|
||||||
if ($displayArgs[$i] -eq '-pw' -and ($i + 1) -lt $displayArgs.Count) {
|
|
||||||
$displayArgs[$i + 1] = '****'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Write-Host ("[{0}] {1} {2}" -f $Label, $Exe, ($displayArgs -join ' ')) -ForegroundColor Cyan
|
|
||||||
|
|
||||||
$out = & $Exe @Arguments 2>&1
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
|
||||||
Write-Error ("{0} failed ({1}):`n{2}" -f $Label, $LASTEXITCODE, ($out -join "`n"))
|
|
||||||
throw ("{0} failed ({1})" -f $Label, $LASTEXITCODE)
|
|
||||||
}
|
|
||||||
return $out
|
|
||||||
}
|
|
||||||
|
|
||||||
function Get-DeployScript {
|
function Get-DeployScript {
|
||||||
param($DeployPreferred, $DeployTmp, $RemoteTmp, $RemotePath, $RestartFlag)
|
param($DeployPreferred, $DeployTmp, $RemoteTmp, $RemotePath, $RestartFlag)
|
||||||
@@ -43,45 +27,7 @@ if [ ! -x "`$DEPLOY" ] && [ -f $DeployTmp ]; then
|
|||||||
DEPLOY=$DeployTmp
|
DEPLOY=$DeployTmp
|
||||||
fi
|
fi
|
||||||
sh "`$DEPLOY" $RemoteTmp $RemotePath $RestartFlag
|
sh "`$DEPLOY" $RemoteTmp $RemotePath $RestartFlag
|
||||||
"@ # -replace "`r", "" -replace "`r`n", "`n"
|
"@
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function Invoke-Scp {
|
|
||||||
param($Local, $Dest, $Pass, $HostKey, [switch]$Quiet, [switch]$Recurse)
|
|
||||||
if ($pscp = Get-Command pscp.exe -ErrorAction SilentlyContinue) {
|
|
||||||
$arguments = @('-scp')
|
|
||||||
if ($Quiet) { $arguments += '-q' }
|
|
||||||
if ($Recurse) { $arguments += '-r' }
|
|
||||||
if ($HostKey) { $arguments += @('-batch', '-hostkey', $HostKey) }
|
|
||||||
if ($Pass) { $arguments += @('-pw', $Pass) }
|
|
||||||
$arguments += @($Local, $Dest)
|
|
||||||
Invoke-Ext -Exe $pscp.Path -Arguments $arguments -Label 'scp'
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$arguments = @('-O')
|
|
||||||
if ($Quiet) { $arguments += '-q' }
|
|
||||||
if ($Recurse) { $arguments += '-r' }
|
|
||||||
$arguments += @($Local, $Dest)
|
|
||||||
Invoke-Ext -Exe 'scp' -Arguments $arguments -Label 'scp'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Invoke-Ssh {
|
|
||||||
param($Cmd, $User, $Remote, $Pass, [switch]$Quiet)
|
|
||||||
$Cmd = $Cmd -replace "`r`n", "`n" -replace "`r", ""
|
|
||||||
if ($plink = Get-Command plink.exe -ErrorAction SilentlyContinue) {
|
|
||||||
$arguments = @('-batch', '-ssh')
|
|
||||||
if ($Pass) { $arguments += @('-pw', $Pass) }
|
|
||||||
$arguments += "$User@$Remote", $Cmd
|
|
||||||
Invoke-Ext -Exe $plink.Path -Arguments $arguments -Label 'ssh'
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$arguments = @()
|
|
||||||
if ($Quiet) { $arguments += '-q' }
|
|
||||||
$arguments += "$User@$Remote", $Cmd
|
|
||||||
Invoke-Ext -Exe 'ssh' -Arguments $arguments -Label 'ssh'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#---- Main Flow ----
|
#---- Main Flow ----
|
||||||
|
|||||||
@@ -9,23 +9,22 @@
|
|||||||
|
|
||||||
START=50 # Run before Tailscale (typically START~80)
|
START=50 # Run before Tailscale (typically START~80)
|
||||||
|
|
||||||
start() {
|
do_update() {
|
||||||
LOGFILE=/var/log/update_tailscale.log
|
|
||||||
MAX_RETRIES=10
|
MAX_RETRIES=10
|
||||||
RETRY_COUNT=0
|
RETRY_COUNT=0
|
||||||
|
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
|
||||||
# shellcheck disable=SC2016
|
if /etc/ldlda_help/update_tailscale.sh; then
|
||||||
sh -c '
|
echo "[update_tailscale] Success at $(date)"
|
||||||
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
|
return 0
|
||||||
if fn; then
|
fi
|
||||||
echo "[update_tailscale] Success at $(date)" >>"$LOGFILE"
|
RETRY_COUNT=$((RETRY_COUNT + 1))
|
||||||
exit 0
|
echo "[update_tailscale] Retry $RETRY_COUNT at $(date)"
|
||||||
fi
|
sleep 5
|
||||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
done
|
||||||
echo "[update_tailscale] Retry $RETRY_COUNT at $(date)" >>"$LOGFILE"
|
echo "[update_tailscale] Too many retries. Exiting at $(date)"
|
||||||
sleep 5
|
return 1
|
||||||
done
|
}
|
||||||
echo "[update_tailscale] Too many retries. Exiting at $(date)" >>"$LOGFILE"
|
|
||||||
exit 1
|
start() {
|
||||||
' >>"$LOGFILE" 2>&1 &
|
do_update >> /var/log/update_tailscale.log 2>&1 &
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
START=66
|
START=66
|
||||||
|
|
||||||
start() {
|
# does this work now fam
|
||||||
LOGFILE=/var/log/update_wakey.log
|
# exposal to wg is separate; so weon care
|
||||||
|
do_update() {
|
||||||
MAX_RETRIES=10
|
MAX_RETRIES=10
|
||||||
RETRY_COUNT=0
|
RETRY_COUNT=0
|
||||||
|
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
|
||||||
# shellcheck disable=SC2016
|
if /etc/ldlda_help/update_wakey.sh; then
|
||||||
sh -c '
|
echo "[update_wakey] Success at $(date)"
|
||||||
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
|
return 0
|
||||||
if /etc/ldlda_help/update_wakey.sh; then
|
fi
|
||||||
echo "[update_wakey] Success at $(date)" >>"$LOGFILE"
|
RETRY_COUNT=$((RETRY_COUNT + 1))
|
||||||
exit 0
|
echo "[update_wakey] Retry $RETRY_COUNT at $(date)"
|
||||||
fi
|
sleep 5
|
||||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
done
|
||||||
echo "[update_wakey] Retry $RETRY_COUNT at $(date)" >>"$LOGFILE"
|
echo "[update_wakey] Too many retries. Exiting at $(date)"
|
||||||
sleep 5
|
return 1
|
||||||
done
|
}
|
||||||
echo "[update_wakey] Too many retries. Exiting at $(date)" >>"$LOGFILE"
|
|
||||||
exit 1
|
start() {
|
||||||
' >>"$LOGFILE" 2>&1 &
|
do_update >>/var/log/update_wakey.log 2>&1 &
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
# Shared functions for wakey scripts
|
||||||
|
|
||||||
|
function Invoke-Ext {
|
||||||
|
param($Exe, $Arguments, $Label)
|
||||||
|
$displayArgs = $Arguments.Clone()
|
||||||
|
for ($i = 0; $i -lt $displayArgs.Count; $i++) {
|
||||||
|
if ($displayArgs[$i] -eq '-pw' -and ($i + 1) -lt $displayArgs.Count) {
|
||||||
|
$displayArgs[$i + 1] = '****'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host ("[{0}] {1} {2}" -f $Label, $Exe, ($displayArgs -join ' ')) -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$out = & $Exe @Arguments 2>&1
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Error ("{0} failed ({1}):`n{2}" -f $Label, $LASTEXITCODE, ($out -join "`n"))
|
||||||
|
throw ("{0} failed ({1})" -f $Label, $LASTEXITCODE)
|
||||||
|
}
|
||||||
|
return $out
|
||||||
|
}
|
||||||
|
|
||||||
|
function Invoke-Scp {
|
||||||
|
param($Local, $Dest, $Pass, $HostKey, [switch]$Quiet, [switch]$Recurse)
|
||||||
|
if ($pscp = Get-Command pscp.exe -ErrorAction SilentlyContinue) {
|
||||||
|
$arguments = @('-scp')
|
||||||
|
if ($Quiet) { $arguments += '-q' }
|
||||||
|
if ($Recurse) { $arguments += '-r' }
|
||||||
|
if ($HostKey) { $arguments += @('-batch', '-hostkey', $HostKey) }
|
||||||
|
if ($Pass) { $arguments += @('-pw', $Pass) }
|
||||||
|
$arguments += @($Local, $Dest)
|
||||||
|
Invoke-Ext -Exe $pscp.Path -Arguments $arguments -Label 'scp'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$arguments = @('-O')
|
||||||
|
if ($Quiet) { $arguments += '-q' }
|
||||||
|
if ($Recurse) { $arguments += '-r' }
|
||||||
|
$arguments += @($Local, $Dest)
|
||||||
|
Invoke-Ext -Exe 'scp' -Arguments $arguments -Label 'scp'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Invoke-Ssh {
|
||||||
|
param($Cmd, $User, $Remote, $Pass, [switch]$Quiet)
|
||||||
|
$Cmd = $Cmd -replace "`r`n", "`n" -replace "`r", ""
|
||||||
|
if ($plink = Get-Command plink.exe -ErrorAction SilentlyContinue) {
|
||||||
|
$arguments = @('-batch', '-ssh')
|
||||||
|
if ($Pass) { $arguments += @('-pw', $Pass) }
|
||||||
|
$dest = if ($User) { "$User@$Remote" } else { $Remote }
|
||||||
|
$arguments += $dest, $Cmd
|
||||||
|
Invoke-Ext -Exe $plink.Path -Arguments $arguments -Label 'ssh'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$arguments = @()
|
||||||
|
if ($Quiet) { $arguments += '-q' }
|
||||||
|
$dest = if ($User) { "$User@$Remote" } else { $Remote }
|
||||||
|
$arguments += $dest, $Cmd
|
||||||
|
Invoke-Ext -Exe 'ssh' -Arguments $arguments -Label 'ssh'
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
-11
@@ -16,6 +16,7 @@ param(
|
|||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
# If no version provided, deduce from Cargo.toml
|
# If no version provided, deduce from Cargo.toml
|
||||||
|
$versionProvided = [bool]$Version
|
||||||
if (-not $Version) {
|
if (-not $Version) {
|
||||||
$cargoToml = Get-Content Cargo.toml -Raw
|
$cargoToml = Get-Content Cargo.toml -Raw
|
||||||
if ($cargoToml -match 'version\s*=\s*"([^"]+)"') {
|
if ($cargoToml -match 'version\s*=\s*"([^"]+)"') {
|
||||||
@@ -28,7 +29,8 @@ if (-not $Version) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Version) {
|
# Only write version if it was explicitly provided (not deduced)
|
||||||
|
if ($versionProvided) {
|
||||||
$pattern = '(?m)^version\s*=\s*"[^"]+"'
|
$pattern = '(?m)^version\s*=\s*"[^"]+"'
|
||||||
$replacement = ('version = "{0}"' -f $Version)
|
$replacement = ('version = "{0}"' -f $Version)
|
||||||
(Get-Content Cargo.toml -Raw) -replace $pattern, $replacement | Set-Content Cargo.toml -Encoding UTF8 -NoNewline
|
(Get-Content Cargo.toml -Raw) -replace $pattern, $replacement | Set-Content Cargo.toml -Encoding UTF8 -NoNewline
|
||||||
@@ -54,17 +56,17 @@ if ($Publish) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($Tag -and $Version) {
|
if ($Tag -and $Version) {
|
||||||
# If you git push a tag, this will trigger the act_runner and the release workflow on your self-hosted runner (see .gitea/workflows/release.yml)
|
|
||||||
$actRunnerScript = Join-Path $PSScriptRoot 'act_runner.ps1'
|
|
||||||
if (Test-Path $actRunnerScript) {
|
|
||||||
Write-Host "Ensuring act_runner is running..."
|
|
||||||
& $actRunnerScript
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Warning "act_runner.ps1 not found at $actRunnerScript. Skipping runner start."
|
|
||||||
}
|
|
||||||
git tag -f "v$Version"
|
git tag -f "v$Version"
|
||||||
git push -f origin "v$Version"
|
git push -f origin "v$Version"
|
||||||
|
Write-Host "Pushed tag: v$Version"
|
||||||
|
|
||||||
Write-Host "Pushed tag: $Version."
|
# Run act_runner in --once mode to process the release job
|
||||||
|
$actRunnerScript = Join-Path $PSScriptRoot 'act_runner.ps1'
|
||||||
|
if (Test-Path $actRunnerScript) {
|
||||||
|
Write-Host "Starting act_runner (once mode) to process release job..."
|
||||||
|
& $actRunnerScript -Once
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning "act_runner.ps1 not found at $actRunnerScript. Skipping runner."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ param(
|
|||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
. "$PSScriptRoot/lib.ps1"
|
||||||
|
|
||||||
# Build tests and capture output
|
# Build tests and capture output
|
||||||
Write-Host "Building tests for $Package..." -ForegroundColor Cyan
|
Write-Host "Building tests for $Package..." -ForegroundColor Cyan
|
||||||
|
|
||||||
@@ -47,7 +49,7 @@ foreach ($testBinary in $testBinaries) {
|
|||||||
Write-Host "`nTesting: $($testBinary.Name)" -ForegroundColor Cyan
|
Write-Host "`nTesting: $($testBinary.Name)" -ForegroundColor Cyan
|
||||||
|
|
||||||
# Copy to target
|
# Copy to target
|
||||||
pscp.exe -batch -scp -pw $password $testBinary.FullName ${RemoteHost}:$RemoteTestPath | Out-Null
|
Invoke-Scp -Local $testBinary.FullName -Dest "${RemoteHost}:$RemoteTestPath" -Pass $password -Quiet
|
||||||
|
|
||||||
# Run on target
|
# Run on target
|
||||||
$testArgs = "$(if ($Verbose) {"--nocapture --show-output"})"
|
$testArgs = "$(if ($Verbose) {"--nocapture --show-output"})"
|
||||||
@@ -55,7 +57,7 @@ foreach ($testBinary in $testBinaries) {
|
|||||||
$testArgs = "$TestName $testArgs"
|
$testArgs = "$TestName $testArgs"
|
||||||
}
|
}
|
||||||
|
|
||||||
plink -batch -ssh $RemoteHost -pw $password "chmod +x $RemoteTestPath && $RemoteTestPath $testArgs"
|
Invoke-Ssh -Cmd "chmod +x $RemoteTestPath && $RemoteTestPath $testArgs" -Remote $RemoteHost -Pass $password
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "`nDone!" -ForegroundColor Green
|
Write-Host "`nDone!" -ForegroundColor Green
|
||||||
|
|||||||
Reference in New Issue
Block a user