Dawnline 0.1.0: AmneziaWG access server for OpenWrt
Build packages / Version (push) Waiting to run

LuCI admin (people, devices, limits, disguise, health, updates, backups)
and a personal self-service portal, built as ipk (OpenWrt 24.10) and apk
(OpenWrt 25.12) with the OpenWrt SDK. Successor of openwrt-liminal.

- install.sh: checks the router, installs AmneziaWG for its firmware,
  then the release package verified against sha256sums.txt
- CI: Prettier, types, tests, committed bundles, ShellCheck, ucode checks;
  tagged releases build both packages and publish them
- Web bundles minified with esbuild (JS and CSS)
- README with framed screenshots
This commit is contained in:
Aemeath committed 2026-10-15 03:29:30 +03:00
commit a3910f8b97
105 files changed
+22278

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Build the release packages with the OpenWrt SDK in Docker (as CI does):
# scripts/build-packages.sh [ipk|apk|all]
# Output: dist/luci-app-dawnline-<version>.{ipk,apk} and dist/sha256sums.txt
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
APP="$ROOT/package/luci-app-dawnline"
VERSION="$(sed -n 's/^PKG_VERSION:=//p' "$APP/Makefile")"
OUT="$ROOT/dist"
WHAT="${1:-all}"
IPK_SDK="${IPK_SDK:-itdoginfo/openwrt-sdk-ipk:24.10.6}"
APK_SDK="${APK_SDK:-itdoginfo/openwrt-sdk-apk:25.12.3}"
# One version everywhere: the Makefile, the ucode library and the web package.
grep -q "^export const VERSION = '$VERSION';" "$APP/root/usr/share/ucode/dawnline/util.uc" || { echo "util.uc VERSION != $VERSION" >&2; exit 1; }
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
mkdir -p "$OUT"
build() {
local type="$1" sdk="$2" tag="dawnline-build:$1"
docker build --platform linux/amd64 -f "$ROOT/build/Dockerfile" --build-arg "SDK_IMAGE=$sdk" -t "$tag" "$ROOT"
local id
id="$(docker create "$tag")"
rm -rf "$OUT/.$type" && mkdir -p "$OUT/.$type"
docker cp "$id:/builder/out/." "$OUT/.$type/"
docker rm "$id" >/dev/null
local f
f="$(find "$OUT/.$type" -type f -name "*.$type" | head -n1)"
[ -n "$f" ] || { echo "no .$type built" >&2; exit 1; }
# ipk names use underscores (luci-app-dawnline_0.1.0-r1_all.ipk): one stable name for both.
mv "$f" "$OUT/luci-app-dawnline-$VERSION.$type"
rm -rf "$OUT/.$type"
echo "$OUT/luci-app-dawnline-$VERSION.$type"
}
case "$WHAT" in
ipk) build ipk "$IPK_SDK" ;;
apk) build apk "$APK_SDK" ;;
all) build ipk "$IPK_SDK"; build apk "$APK_SDK" ;;
*) echo "usage: $0 [ipk|apk|all]" >&2; exit 2 ;;
esac
(
cd "$OUT"
set -- luci-app-dawnline-"$VERSION".ipk luci-app-dawnline-"$VERSION".apk
files=""
for f in "$@"; do [ -f "$f" ] && files="$files $f"; done
# shellcheck disable=SC2086
if command -v sha256sum >/dev/null; then sha256sum $files; else shasum -a 256 $files; fi > sha256sums.txt
)
cat "$OUT/sha256sums.txt"
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Build the web bundles and pack luci-app-dawnline as a filesystem overlay
# tarball: dist/luci-app-dawnline-<version>.tar.gz (paths relative to /).
# This is the asset the in-app updater and install.sh install.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
APP="$ROOT/package/luci-app-dawnline"
VERSION="$(sed -n "s/^export const VERSION = '\(.*\)';/\1/p" "$APP/root/usr/share/ucode/dawnline/util.uc")"
OUT="$ROOT/dist"
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
grep -q "PKG_VERSION:=$VERSION\$" "$APP/Makefile" || { echo "Makefile PKG_VERSION != $VERSION" >&2; exit 1; }
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
[ "${SKIP_WEB:-0}" = 1 ] || (cd "$ROOT/web" && npm run --silent ci)
mkdir -p "$STAGE/www" "$OUT"
cp -R "$APP/root/." "$STAGE/"
cp -R "$APP/htdocs/." "$STAGE/www/"
chmod 755 "$STAGE/usr/bin/dawnline" "$STAGE/usr/libexec/dawnline/agent" "$STAGE/usr/libexec/dawnline/updater" "$STAGE/usr/libexec/dawnline/resolver" \
"$STAGE/etc/init.d/dawnline" "$STAGE/etc/uci-defaults/90_dawnline" "$STAGE/etc/hotplug.d/iface/95-dawnline" \
"$STAGE/usr/share/dawnline/portal/www/cgi-bin/portal"
find "$STAGE" -name '.DS_Store' -delete
TAR="$OUT/luci-app-dawnline-$VERSION.tar.gz"
# Files only (no directory entries) and root ownership: extracting into /
# must never touch the mode or owner of /usr, /www or /etc.
( cd "$STAGE" && find usr www etc -type f | LC_ALL=C sort > "$STAGE/.files" )
COPYFILE_DISABLE=1 tar --format ustar --uid 0 --gid 0 --uname root --gname root \
-czf "$TAR" -C "$STAGE" -T "$STAGE/.files"
( cd "$OUT" && shasum -a 256 "$(basename "$TAR")" > "$(basename "$TAR").sha256" )
echo "$TAR"
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Compile-check every ucode file on a router without installing anything:
# the tree is unpacked under /tmp/dlc and modules are resolved from there.
# scripts/check-ucode.sh [root@host]
set -euo pipefail
HOST="${1:-root@outline.lan}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)/package/luci-app-dawnline/root"
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
# ucode resolves names at compile time: calling a function declared further
# down a file fails at runtime ("access to undeclared variable"). Catch it here.
python3 "$(dirname "$0")/lint-ucode.py" "$ROOT"
( cd "$ROOT" && COPYFILE_DISABLE=1 tar -czf "$TMP/t.tgz" usr etc )
scp -q "$TMP/t.tgz" "$HOST:/tmp/dl-check.tgz"
ssh "$HOST" sh <<'REMOTE'
rm -rf /tmp/dlc && mkdir -p /tmp/dlc && tar -xzf /tmp/dl-check.tgz -C /tmp/dlc && rm /tmp/dl-check.tgz
cd /tmp/dlc
rc=0
for f in usr/share/ucode/dawnline/*.uc; do
n=$(basename "$f" .uc)
out=$(ucode -L '/tmp/dlc/usr/share/ucode/*.uc' -e "import * as x from 'dawnline.$n';" 2>&1) || { echo "FAIL $f"; echo "$out" | head -8; rc=1; }
done
for f in usr/share/rpcd/ucode/luci.dawnline usr/libexec/dawnline/agent usr/libexec/dawnline/updater usr/bin/dawnline usr/share/dawnline/portal/www/cgi-bin/portal; do
[ -f "$f" ] || continue
out=$(ucode -L '/tmp/dlc/usr/share/ucode/*.uc' -c -o /dev/null "$f" 2>&1) || { echo "FAIL $f"; echo "$out" | head -8; rc=1; }
done
rm -rf /tmp/dlc
[ $rc = 0 ] && echo "all ucode files compile"
exit $rc
REMOTE
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Dev deploy: build the release tarball and install it on a router over SSH.
# scripts/deploy.sh [root@host]
# Backs up the configs Dawnline touches to /root/dawnline-predeploy-<ts>/ first.
set -euo pipefail
HOST="${1:-root@outline.lan}"
TAR="$("$(dirname "$0")/build-release.sh" | tail -n1)"
scp -q "$TAR" "$HOST:/tmp/luci-app-dawnline.tar.gz"
ssh "$HOST" sh <<'REMOTE'
set -e
ts="$(date +%Y%m%d-%H%M%S)"
mkdir -p "/root/dawnline-predeploy-$ts"
for c in network firewall dhcp dawnline; do
[ -f "/etc/config/$c" ] && cp "/etc/config/$c" "/root/dawnline-predeploy-$ts/$c"
done
# Keep only the five most recent pre-deploy backups.
ls -d /root/dawnline-predeploy-* 2>/dev/null | sort | head -n -5 | xargs -r rm -rf
tar -xozf /tmp/luci-app-dawnline.tar.gz -C /
rm -f /tmp/luci-app-dawnline.tar.gz
sh /etc/uci-defaults/90_dawnline && rm -f /etc/uci-defaults/90_dawnline
sleep 1
ubus list luci.dawnline >/dev/null && echo "luci.dawnline registered (backup: /root/dawnline-predeploy-$ts)"
REMOTE
+92
View File
@@ -0,0 +1,92 @@
#!/usr/bin/env python3
"""Put the README screenshots into a browser window on a dawn gradient.
Raw captures live in docs/screenshots/raw/<name>.png; the framed images are
written to docs/screenshots/<name>.png. Needs a Chromium-based browser for the
headless render (BROWSER=/path/to/chrome, default: Brave or Chrome on macOS).
Run: scripts/frame-screenshots.py
"""
import os
import shutil
import struct
import subprocess
import sys
import tempfile
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
RAW = os.path.join(ROOT, 'docs', 'screenshots', 'raw')
OUT = os.path.join(ROOT, 'docs', 'screenshots')
# name -> what the address bar shows
SHOTS = {
'overview': 'router.lan · Dawnline',
'people': 'router.lan · Dawnline · People',
'person': 'router.lan · Dawnline · Myata',
'portal': 'vpn.example.com/kamiro-telosu-bavine',
'map': 'router.lan · Dawnline · Overview',
}
PAD_X, PAD_Y, BAR = 120, 96, 40
CANDIDATES = [
os.environ.get('BROWSER', ''),
'/Applications/Brave Browser.app/Contents/MacOS/Brave Browser',
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
shutil.which('chromium') or '',
shutil.which('google-chrome') or '',
]
TEMPLATE = """<!doctype html><html><head><meta charset="utf-8"><style>
html,body{{margin:0;width:{w}px;height:{h}px;overflow:hidden}}
body{{display:flex;align-items:center;justify-content:center;
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
background:
radial-gradient({gw}px {gh}px at 50% 118%, rgba(255,140,70,.55), rgba(255,140,70,0) 70%),
radial-gradient({gw2}px {gh2}px at 50% 100%, rgba(250,90,120,.30), rgba(250,90,120,0) 70%),
linear-gradient(180deg,#070a14 0%,#0c1226 55%,#1a1430 100%)}}
.win{{width:{iw}px;border-radius:14px;overflow:hidden;background:#000;
box-shadow:0 0 0 1px rgba(255,255,255,.08),0 40px 120px rgba(0,0,0,.65),0 10px 30px rgba(0,0,0,.4)}}
.bar{{height:{bar}px;background:#15171c;display:flex;align-items:center;gap:8px;padding:0 16px;
border-bottom:1px solid rgba(255,255,255,.06);position:relative}}
.dot{{width:12px;height:12px;border-radius:50%}}
.url{{position:absolute;left:50%;transform:translateX(-50%);height:24px;padding:0 14px;border-radius:7px;
background:#0d0f13;color:#8b8f98;font-size:13px;display:flex;align-items:center;gap:6px;white-space:nowrap}}
.url svg{{width:11px;height:11px;fill:none;stroke:#8b8f98;stroke-width:2}}
img{{display:block;width:{iw}px;height:{ih}px}}
</style></head><body><div class="win"><div class="bar">
<span class="dot" style="background:#ff5f57"></span><span class="dot" style="background:#febc2e"></span><span class="dot" style="background:#28c840"></span>
<span class="url"><svg viewBox="0 0 24 24"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></svg>{url}</span>
</div><img src="file://{src}"></div></body></html>"""
def png_size(path):
with open(path, 'rb') as f:
head = f.read(24)
return struct.unpack('>II', head[16:24])
def main():
browser = next((b for b in CANDIDATES if b and os.path.exists(b)), None)
if not browser:
sys.exit('No Chromium-based browser found; set BROWSER=/path/to/chrome')
tmp = tempfile.mkdtemp()
for name, url in SHOTS.items():
src = os.path.join(RAW, f'{name}.png')
if not os.path.exists(src):
print(f'skip {name}: no raw capture')
continue
iw, ih = png_size(src)
w, h = iw + 2 * PAD_X, ih + BAR + 2 * PAD_Y
html = os.path.join(tmp, f'{name}.html')
with open(html, 'w', encoding='utf-8') as f:
f.write(TEMPLATE.format(w=w, h=h, iw=iw, ih=ih, bar=BAR, url=url, src=src,
gw=int(w * .8), gh=int(h * .5), gw2=int(w * .6), gh2=int(h * .45)))
out = os.path.join(OUT, f'{name}.png')
subprocess.run([browser, '--headless=new', '--disable-gpu', '--hide-scrollbars', '--allow-file-access-from-files',
'--force-device-scale-factor=1', f'--window-size={w},{h}', f'--screenshot={out}', f'file://{html}'],
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
print(f'{name}: {w}x{h}')
shutil.rmtree(tmp)
if __name__ == '__main__':
main()
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""Static checks for the ucode sources that need no router.
ucode resolves names where they are used: calling a function that is declared
further down the same file fails at runtime ("access to undeclared variable").
Run: scripts/lint-ucode.py [package root]
"""
import glob
import os
import re
import sys
root = sys.argv[1] if len(sys.argv) > 1 else os.path.join(os.path.dirname(__file__), '..', 'package', 'luci-app-dawnline', 'root')
files = glob.glob(f"{root}/usr/share/ucode/dawnline/*.uc") + [
f"{root}/usr/share/rpcd/ucode/luci.dawnline",
f"{root}/usr/libexec/dawnline/agent",
f"{root}/usr/libexec/dawnline/updater",
f"{root}/usr/libexec/dawnline/resolver",
f"{root}/usr/bin/dawnline",
f"{root}/usr/share/dawnline/portal/www/cgi-bin/portal",
]
bad = 0
checked = 0
for f in files:
if not os.path.exists(f):
continue
checked += 1
code = re.sub(r'//[^\n]*|/\*.*?\*/', '', open(f, encoding='utf-8').read(), flags=re.S)
defs = {m.group(1): m.start() for m in re.finditer(r'^(?:export )?function (\w+)\(', code, re.M)}
for name, pos in defs.items():
for m in re.finditer(r'(?<![\w.\'"`])' + name + r'\(', code[:pos]):
line = code[: m.start()].count('\n') + 1
print(f"{f}:{line}: {name}() is used before its definition")
bad = 1
print(f"lint-ucode: {checked} files checked" + (", problems found" if bad else ", ok"))
sys.exit(bad)