The start of greatness is hella rocky

This commit is contained in:
lda
2026-04-06 23:46:07 +07:00 Unverified
parent 93a88741f9
commit 65111d7895
20 changed files with 2225 additions and 37 deletions
+15 -7
View File
@@ -4,13 +4,13 @@ This folder has small helpers for build, CI, and router install. Keep it simple;
## Quick start (recommended)
1. Start your Gitea runner on this Windows PC (if not already running):
1. Start your Fedora/WSL Gitea runner (recommended release path):
```powershell
./scripts/act_runner.ps1
./scripts/act_runner_wsl.ps1 -Action start -Attach
```
If first-time, it prints the exact register command. Run it once, check labels include `windows:host,self-hosted`, then rerun the script.
If first-time, use the runbook in [`WSL_RUNNER.md`](./WSL_RUNNER.md) to update and register the Fedora runner first.
2. Publish, tag, and push (recommended):
@@ -18,7 +18,7 @@ This folder has small helpers for build, CI, and router install. Keep it simple;
./scripts/publish.ps1 -Tag
```
This will bump the version (if you specify one), build, ensure the runner is started, tag, and push. To also publish to the registry, add `-Publish`.
This will bump the version (if you specify one), build locally, tag, push, and start the Fedora/WSL runner in `--once` mode by default. To also publish to the registry, add `-Publish`.
3. Install on the router
@@ -38,6 +38,8 @@ This folder has small helpers for build, CI, and router install. Keep it simple;
## Scripts overview
- `act_runner.ps1` — Start/seed the local Gitea runner. Use `-Attach` to see logs, `-ForceConfigure` to register non-interactively.
- `act_runner_wsl.ps1` — Windows PowerShell wrapper that controls the Fedora/WSL runner.
- `act_runner_fedora.sh` — Linux/Fedora helper used inside WSL for update/register/start/stop/status.
- `dev_push.ps1` — Fast dev loop: build + upload to router. Usage:
- `./scripts/dev_push.ps1 -Pass <password> [-HostName <ip>] [-RemotePath </root/.bin/wakey>] [-Restart] [-Quiet]`
- Uploads to `<RemotePath>.tmp` then atomically moves into place; `-Restart` restarts the service; `-Quiet` silences MOTD.
@@ -92,10 +94,16 @@ Implementation notes:
## CI (Gitea)
- Defined in `.gitea/workflows/release.yml`.
- Runs on your `self-hosted, windows` runner.
- Steps: cross build → package rootfs → upload artifact (v3) → publish a release and attach tgz.
- Release job now targets your Fedora/WSL runner labels: `self-hosted`, `linux`, `fedora`, `wsl`, `release`.
- Steps: Linux-native build of `wakey` + `wakey-agent` → package rootfs → upload artifact (v3) → publish a release and attach tgz.
- Requires `secrets.GITEA_TOKEN` in the repo to publish the release.
## Runner migration
- Fedora/WSL is now the intended release-builder path.
- The Windows runner can stay registered in parallel during migration and fallback.
- The detailed operator runbook is in [`WSL_RUNNER.md`](./WSL_RUNNER.md).
## Local build/install (manual path)
```powershell
@@ -121,4 +129,4 @@ Or you can use the script:
./scripts/dev_push.ps1 -Pass <password>
```
Thats it. Keep the flow: start runner → tag push → install.
Thats it. Keep the flow: start Fedora/WSL runner → tag push → install.
+131
View File
@@ -0,0 +1,131 @@
# Fedora / WSL Gitea Runner
This repo now expects Linux/router release builds to run on a Fedora 43 runner
inside WSL, not on the Windows host runner.
The goal is simple:
- build `wakey` and `wakey-agent` in a Linux-native environment
- stop fighting Windows-host ARM/musl/TLS toolchain issues
- keep PowerShell on Windows as the operator front door
## Runner layout
Recommended WSL location:
```text
/mnt/c/Users/Admin/Documents/realshit/wakey/ar_data/wsl_runner
```
This matches the default used by `act_runner_wsl.ps1` and
`act_runner_fedora.sh`, so WSL runner config is isolated at
`ar_data/wsl_runner/config.yaml` in this repo.
Recommended labels:
```text
self-hosted,linux,fedora,wsl,release:host
```
The Windows runner can stay registered during migration as fallback.
## Fedora setup
Install the basics in Fedora 43:
```bash
sudo dnf install -y git curl tar gzip findutils python3
sudo dnf install -y powershell
```
Install Rust and the router target:
```bash
rustup target add armv7-unknown-linux-musleabihf
```
Install the native cross toolchain pieces you need for Linux/ARM router builds.
The exact package names can vary over time, so confirm the current Fedora names
for:
- ARM Linux GCC
- musl development/toolchain support
- OpenSSL/ring/TLS build prerequisites if needed by your dependency graph
## Runner lifecycle
From Windows PowerShell, using the WSL wrapper:
```powershell
./scripts/act_runner_wsl.ps1 -Action update
./scripts/act_runner_wsl.ps1 -Action register -ServerUrl https://git.ldlda.com/ -Token <runner-token>
./scripts/act_runner_wsl.ps1 -Action start -Attach
./scripts/act_runner_wsl.ps1 -Action start -Once
./scripts/act_runner_wsl.ps1 -Action status
./scripts/act_runner_wsl.ps1 -Action stop
```
Path control (binary and config are independent):
```powershell
./scripts/act_runner_wsl.ps1 -Action status `
-RunnerBin /home/lda/gitea-runner/act_runner `
-ConfigPath /mnt/c/Users/Admin/Documents/realshit/wakey/ar_data/wsl_runner/config.yaml
```
If your distro name is not `FedoraLinux-43`, set it explicitly:
```powershell
./scripts/act_runner_wsl.ps1 -Distro FedoraLinux-43 -Action status
```
Or set:
```powershell
$env:WAKEY_WSL_DISTRO = "FedoraLinux-43"
```
Inside Fedora directly, you can also use:
```bash
./scripts/act_runner_fedora.sh update
./scripts/act_runner_fedora.sh register --server-url https://git.ldlda.com/ --token <runner-token>
./scripts/act_runner_fedora.sh start --attach
./scripts/act_runner_fedora.sh start --once
./scripts/act_runner_fedora.sh status
./scripts/act_runner_fedora.sh stop
```
## Release flow
The release workflow is expected to run on the Fedora/WSL runner labels:
```text
self-hosted + linux + fedora + wsl + release
```
It builds:
- `wakey`
- `wakey-agent`
and packages both into the rootfs tarball.
From Windows, the intended operator flow remains:
```powershell
./scripts/publish.ps1 -Tag
```
That script should trigger the WSL runner in `--once` mode by default.
## Rollback
If the Fedora runner path is broken:
1. stop using the WSL runner labels in the workflow
2. temporarily point the workflow back to the Windows runner labels
3. use the existing Windows runner as fallback while fixing the Fedora path
Do not delete the Windows runner until the Fedora path has already produced at
least one successful full release and one successful router install.
+4 -4
View File
@@ -1,12 +1,12 @@
# Starts the Gitea act_runner if not already running.
# Usage: ./scripts/act_runner.ps1 -Config "C:/Users/Admin/Documents/gitea/runner.yaml" -RunnerPath "C:/Users/Admin/Documents/gitea/act_runner.exe" -ServerUrl "https://git.ldlda.com/" -Token "<reg token>" -Labels "self-hosted,windows"
# Starts the Windows-host Gitea act_runner if not already running.
# Usage: ./scripts/act_runner.ps1 -Config "C:/Users/Admin/Documents/gitea/runner.yaml" -RunnerPath "C:/Users/Admin/Documents/gitea/act_runner.exe" -ServerUrl "https://git.ldlda.com/" -Token "<reg token>" -Labels "self-hosted,windows:host"
param(
[string]$RunnerPath = "$HOME/Documents/gitea/act_runner.exe",
# Config is a FILE path (e.g., runner.yaml). Parent folder will be created if missing.
[string]$Config = (Join-Path (Split-Path -Parent $PSScriptRoot) 'ar_data/config.yaml'),
[string]$ServerUrl,
[string]$Token,
[string]$Labels = "windows:host,self-hosted",
[string]$Labels = "self-hosted,windows:host",
# Opt-in to non-interactive configure; by default we print the command for you to run manually.
[switch]$ForceConfigure,
# When -Attach, run in the foreground to see logs (good for first-time troubleshooting)
@@ -46,7 +46,7 @@ if (-not (Test-Path $configFile)) {
Pop-Location
}
else {
Write-Host "Config not found. Run this manually once (note labels embed host executor on Windows):"
Write-Host "Config not found. Run this manually once (Windows-host runner labels):"
Write-Host "`t$RunnerPath register --no-interactive --config `"$configFile`" --instance `"$ServerUrl`" --token `"$Token`" --labels `"$Labels`""
exit 2
}
+190
View File
@@ -0,0 +1,190 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
RUNNER_BIN="${RUNNER_BIN:-/home/lda/gitea-runner/act_runner}"
CONFIG_PATH="${CONFIG_PATH:-$REPO_ROOT/ar_data/wsl_runner/config.yaml}"
RUNNER_HOME="${RUNNER_HOME:-$(dirname "$CONFIG_PATH")}"
SERVER_URL="${SERVER_URL:-}"
TOKEN="${TOKEN:-}"
LABELS="${LABELS:-self-hosted,linux,fedora,wsl,release:host}"
usage() {
cat <<'EOF'
Usage:
act_runner_fedora.sh update
act_runner_fedora.sh register --server-url URL --token TOKEN [--labels LABELS]
act_runner_fedora.sh start [--attach] [--once]
act_runner_fedora.sh stop
act_runner_fedora.sh status
Environment overrides:
RUNNER_HOME, RUNNER_BIN, CONFIG_PATH, SERVER_URL, TOKEN, LABELS
Path overrides:
--runner-home DIR
--runner-bin PATH
--config-path PATH
EOF
}
ensure_dirs() {
mkdir -p "$RUNNER_HOME" "$(dirname "$RUNNER_BIN")"
}
update_runner() {
ensure_dirs
local api="https://gitea.com/api/v1/repos/gitea/act_runner/releases/latest"
local release
release="$(curl -fsSL "$api")"
local asset_url
asset_url="$(
python3 - "$(printf '%s' "$release")" <<'PY'
import json, sys
data = json.loads(sys.argv[1])
for asset in data["assets"]:
if asset["name"].endswith("linux-amd64"):
print(asset["browser_download_url"])
break
else:
raise SystemExit("no linux-amd64 act_runner asset found")
PY
)"
local tmp="$RUNNER_HOME/act_runner.tmp"
curl -fsSL "$asset_url" -o "$tmp"
chmod +x "$tmp"
mv -f "$tmp" "$RUNNER_BIN"
echo "Updated act_runner -> $RUNNER_BIN"
}
register_runner() {
ensure_dirs
if [[ -z "$SERVER_URL" || -z "$TOKEN" ]]; then
echo "register requires SERVER_URL and TOKEN (or --server-url/--token)" >&2
exit 2
fi
"$RUNNER_BIN" register \
--no-interactive \
--config "$CONFIG_PATH" \
--instance "$SERVER_URL" \
--token "$TOKEN" \
--labels "$LABELS"
}
start_runner() {
local mode="${1:-daemon}"
ensure_dirs
if [[ ! -f "$CONFIG_PATH" ]]; then
echo "Runner config not found at $CONFIG_PATH" >&2
exit 2
fi
case "$mode" in
attach)
exec "$RUNNER_BIN" daemon --config "$CONFIG_PATH"
;;
once)
exec "$RUNNER_BIN" daemon --config "$CONFIG_PATH" --once
;;
daemon)
nohup "$RUNNER_BIN" daemon --config "$CONFIG_PATH" >/tmp/act_runner.log 2>&1 &
echo "Started act_runner in background"
;;
*)
echo "Unknown start mode: $mode" >&2
exit 2
;;
esac
}
stop_runner() {
pkill -f "$RUNNER_BIN" || true
}
status_runner() {
if pgrep -f "$RUNNER_BIN" >/dev/null; then
echo "act_runner is running"
else
echo "act_runner is not running"
fi
}
ACTION="${1:-}"
shift || true
while [[ $# -gt 0 ]]; do
case "$1" in
--server-url)
SERVER_URL="$2"
shift 2
;;
--token)
TOKEN="$2"
shift 2
;;
--labels)
LABELS="$2"
shift 2
;;
--runner-home)
RUNNER_HOME="$2"
if [[ "${RUNNER_BIN:-}" == "/home/lda/gitea-runner/act_runner" ]]; then
RUNNER_BIN="$RUNNER_HOME/act_runner"
fi
if [[ "${CONFIG_PATH:-}" == "$REPO_ROOT/ar_data/wsl_runner/config.yaml" ]]; then
CONFIG_PATH="$RUNNER_HOME/config.yaml"
fi
shift 2
;;
--runner-bin)
RUNNER_BIN="$2"
shift 2
;;
--config-path)
CONFIG_PATH="$2"
RUNNER_HOME="$(dirname "$CONFIG_PATH")"
shift 2
;;
--attach)
START_MODE="attach"
shift
;;
--once)
START_MODE="once"
shift
;;
*)
echo "Unknown argument: $1" >&2
usage
exit 2
;;
esac
done
case "$ACTION" in
update)
update_runner
;;
register)
register_runner
;;
start)
start_runner "${START_MODE:-daemon}"
;;
stop)
stop_runner
;;
status)
status_runner
;;
*)
usage
exit 2
;;
esac
+60
View File
@@ -0,0 +1,60 @@
param(
[ValidateSet("update", "register", "start", "stop", "status")]
[string]$Action = "start",
[string]$Distro = $(if ($env:WAKEY_WSL_DISTRO) { $env:WAKEY_WSL_DISTRO } else { "FedoraLinux-43" }),
[string]$RunnerHome,
[string]$RunnerBin = "/home/lda/gitea-runner/act_runner",
[string]$ConfigPath,
[string]$ServerUrl,
[string]$Token,
[string]$Labels = "self-hosted,linux,fedora,wsl,release:host",
[switch]$Attach,
[switch]$Once
)
$ErrorActionPreference = "Stop"
. "$PSScriptRoot/lib.ps1"
$scriptWin = Join-Path $PSScriptRoot "act_runner_fedora.sh"
if (-not (Test-Path $scriptWin)) {
throw "Missing Fedora runner helper: $scriptWin"
}
$scriptLinux = (& wsl.exe -d $Distro -e wslpath -a "$scriptWin").Trim()
if (-not $scriptLinux) {
throw "Failed to resolve WSL path for $scriptWin"
}
if (-not $RunnerHome) {
$repoRootWin = Split-Path -Parent $PSScriptRoot
$defaultRunnerHomeWin = Join-Path $repoRootWin "ar_data/wsl_runner"
$RunnerHome = (& wsl.exe -d $Distro -e wslpath -a "$defaultRunnerHomeWin").Trim()
if (-not $RunnerHome) {
throw "Failed to resolve WSL runner home for $defaultRunnerHomeWin"
}
}
if (-not $ConfigPath) {
$repoRootWin = Split-Path -Parent $PSScriptRoot
$defaultConfigWin = Join-Path $repoRootWin "ar_data/wsl_runner/config.yaml"
$ConfigPath = (& wsl.exe -d $Distro -e wslpath -a "$defaultConfigWin").Trim()
if (-not $ConfigPath) {
throw "Failed to resolve WSL config path for $defaultConfigWin"
}
}
$parts = @("bash", (Quote-ShArg $scriptLinux), (Quote-ShArg $Action), "--runner-home", (Quote-ShArg $RunnerHome))
$parts += @("--runner-bin", (Quote-ShArg $RunnerBin), "--config-path", (Quote-ShArg $ConfigPath))
if ($ServerUrl) { $parts += @("--server-url", (Quote-ShArg $ServerUrl)) }
if ($Token) { $parts += @("--token", (Quote-ShArg $Token)) }
if ($Labels) { $parts += @("--labels", (Quote-ShArg $Labels)) }
if ($Attach) { $parts += "--attach" }
if ($Once) { $parts += "--once" }
$cmd = $parts -join " "
Write-Host $cmd
& wsl.exe -d $Distro -e bash -lc $cmd
if ($LASTEXITCODE -ne 0) {
throw "WSL runner action failed ($LASTEXITCODE)"
}
+17 -5
View File
@@ -1,12 +1,16 @@
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidDefaultValueSwitchParameter', "",
Justification = 'Default true is intentional for fast dev loop')]
param(
[ValidateSet("cargo", "cross")]
[string]$Cargo = "cargo",
[string]$Pass,
[string]$HostName = "192.168.100.1",
[string]$User = "root",
[string]$RemotePath = "/root/.bin/wakey",
[string]$AgentRemotePath = "/root/.bin/wakey-agent",
[string]$Target = "armv7-unknown-linux-musleabihf",
[string]$BinName = "wakey",
[string]$AgentBinName = "wakey-agent",
[string]$HostKey,
[switch]$Restart = $true,
[switch]$Quiet = $true
@@ -37,21 +41,26 @@ $repoRoot = Split-Path -Parent $PSScriptRoot
Push-Location $repoRoot
try {
Write-Host "[build] cargo build --release --target $Target" -ForegroundColor Cyan
cargo build --release --target $Target
if ($LASTEXITCODE -ne 0) { throw "cargo build failed ($LASTEXITCODE)" }
Write-Host "[build] $Cargo build --release --target $Target -p wakey -p wakey-agent" -ForegroundColor Cyan
. "$Cargo" build --release --target $Target -p wakey -p wakey-agent
if ($LASTEXITCODE -ne 0) { throw "$Cargo build failed ($LASTEXITCODE)" }
$localBin = Join-Path $repoRoot "target/$Target/release/$BinName"
$localAgentBin = Join-Path $repoRoot "target/$Target/release/$AgentBinName"
if (-not (Test-Path $localBin)) { throw "binary not found: $localBin" }
if (-not (Test-Path $localAgentBin)) { throw "binary not found: $localAgentBin" }
$remoteTmp = "$RemotePath.tmp"
$agentRemoteTmp = "$AgentRemotePath.tmp"
$destTmp = "$User@${HostName}:$remoteTmp"
$agentDestTmp = "$User@${HostName}:$agentRemoteTmp"
$localDeploy = Join-Path $repoRoot 'scripts/remote_deploy_wakey.sh'
$deployTmp = '/var/tmp/remote_deploy_wakey.sh'
$deployPreferred = '/root/.bin/remote_deploy_wakey.sh'
# Push main binary
# Push binaries
Invoke-Scp -Local $localBin -Dest $destTmp -Pass $Pass -HostKey $HostKey -Quiet:$Quiet
Invoke-Scp -Local $localAgentBin -Dest $agentDestTmp -Pass $Pass -HostKey $HostKey -Quiet:$Quiet
# Push static assets
$localStatic = Join-Path $repoRoot "static"
@@ -74,7 +83,10 @@ try {
# Build and run remote deploy command
$restartFlag = $(if ($Restart) { '1' } else { '0' })
$script = Get-DeployScript $deployPreferred $deployTmp $remoteTmp $RemotePath $restartFlag
$script = @"
$(Get-DeployScript $deployPreferred $deployTmp $remoteTmp $RemotePath 0)
$(Get-DeployScript $deployPreferred $deployTmp $agentRemoteTmp $AgentRemotePath $restartFlag)
"@
$remoteCmd = "sh -lc '$($script -replace "`r",'')'"
if ($Quiet) { $remoteCmd += " >/dev/null 2>&1" }
+2
View File
@@ -5,10 +5,12 @@ START=99
USE_PROCD=1
NAME=wakey
# BIN=/root/.bin/wakey-agent
BIN=/root/.bin/wakey
start_service() {
procd_open_instance
# procd_set_param command "$BIN" serve
procd_set_param command "$BIN" http --host :: --port 12012
procd_set_param respawn 5 1 0
procd_set_param stdout 1
+9
View File
@@ -1,6 +1,7 @@
# Build a rootfs tarball suitable for `wget -O- ... | tar -xz -C /` on OpenWrt.
# It lays out files as absolute-root paths inside the archive:
# root/.bin/wakey
# root/.bin/wakey-agent
# etc/init.d/wakey
# Usage: ./scripts/package_rootfs.ps1 -Version 0.1.0 -Target armv7-unknown-linux-musleabihf -OutDir dist
param(
@@ -17,7 +18,9 @@ $dist = Join-Path $root $OutDir
New-Item -ItemType Directory -Force -Path $dist | Out-Null
$binName = if ($Target -like "*-windows-*") { "wakey.exe" } else { "wakey" }
$agentBinName = if ($Target -like "*-windows-*") { "wakey-agent.exe" } else { "wakey-agent" }
$binSrc = Join-Path $root "target/$Target/release/$binName"
$agentBinSrc = Join-Path $root "target/$Target/release/$agentBinName"
$staging = Join-Path $dist ("rootfs-" + [System.Guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Force -Path $staging | Out-Null
@@ -35,6 +38,12 @@ if (-not $NoBin) {
else {
throw "Missing binary: $binSrc (build it first or pass -NoBin)"
}
if (Test-Path $agentBinSrc) {
Copy-Item $agentBinSrc (Join-Path $rootDir "wakey-agent") -Force
}
else {
throw "Missing binary: $agentBinSrc (build it first or pass -NoBin)"
}
}
# Normalize kill script line endings and copy
$killSrc = Join-Path $root 'scripts/kill_wakey.sh'
+28 -9
View File
@@ -10,7 +10,10 @@ param(
[string]$Version,
[switch]$Tag,
[switch]$Publish,
[string]$Registry
[string]$Registry,
[ValidateSet('wsl', 'windows', 'none')]
[string]$RunnerMode = 'wsl',
[string]$WslDistro = $(if ($env:WAKEY_WSL_DISTRO) { $env:WAKEY_WSL_DISTRO } else { 'FedoraLinux' })
)
$ErrorActionPreference = 'Stop'
@@ -60,13 +63,29 @@ if ($Tag -and $Version) {
git push -f origin "v$Version"
Write-Host "Pushed tag: v$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."
switch ($RunnerMode) {
'wsl' {
$runnerScript = Join-Path $PSScriptRoot 'act_runner_wsl.ps1'
if (Test-Path $runnerScript) {
Write-Host "Starting Fedora/WSL act_runner (once mode) to process release job..."
& $runnerScript -Distro $WslDistro -Action start -Once
}
else {
Write-Warning "act_runner_wsl.ps1 not found at $runnerScript. Skipping runner."
}
}
'windows' {
$runnerScript = Join-Path $PSScriptRoot 'act_runner.ps1'
if (Test-Path $runnerScript) {
Write-Host "Starting Windows act_runner (once mode) to process release job..."
& $runnerScript -Once
}
else {
Write-Warning "act_runner.ps1 not found at $runnerScript. Skipping runner."
}
}
'none' {
Write-Host "RunnerMode=none; not starting a local runner helper."
}
}
}