#!/usr/bin/env bash # One-command smoke test for an extracted Luminary Linux bundle. # # Run it from the extracted bundle folder (or pass --bundle): # # ./SMOKE-LINUX.sh # ./SMOKE-LINUX.sh --bundle /opt/luminary # # It writes smoke-report.txt next to the bundle and prints the same lines. # Exit code 0 means every check passed. # # What it covers without a human clicking: # - distro, architecture, glibc, display, and which browser the launcher picks # - the bundle files the launcher needs, and `luminary --verify` # - a real boot through the launcher in desktop mode: /api/health local:true, # /api/auth/me 200 without a cookie, registration closed, /api/sync 200 # - the menu entry install/uninstall writing and removing a real .desktop file # - `luminary --stop` actually stopping the server # # It uses a throwaway data folder under $TMPDIR and a private XDG_DATA_HOME, so # it never touches a real catalog or your applications menu. The app window is # not opened (the launcher runs with LUMINARY_WINDOW=none); it is a visual check. set -u BUNDLE="" while [ "$#" -gt 0 ]; do case "$1" in --bundle) BUNDLE="${2:-}" shift 2 ;; --help|-h) sed -n '2,20p' "$0" | sed 's/^# \{0,1\}//' exit 0 ;; *) printf 'unknown option %s (see --help)\n' "$1" >&2 exit 2 ;; esac done [ -n "$BUNDLE" ] || BUNDLE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BUNDLE="$(readlink -f "$BUNDLE")" LINES=() FAILED=0 SKIPPED=0 say() { LINES+=("$*") printf '%s\n' "$*" } check() { local name="$1" ok="$2" detail="${3:-}" if [ "$ok" = "0" ]; then say " PASS $name${detail:+ — $detail}" else FAILED=$((FAILED + 1)) say " FAIL $name${detail:+ — $detail}" fi } skip() { SKIPPED=$((SKIPPED + 1)) say " SKIP $1${2:+ — $2}" } [ -x "$BUNDLE/runtime/bin/node" ] && NODE="$BUNDLE/runtime/bin/node" || NODE="$(command -v node 2>/dev/null || true)" if [ -z "$NODE" ]; then printf 'Luminary: no Node runtime found in the bundle or on PATH\n' >&2 exit 1 fi WORK_DIR="$(mktemp -d "${TMPDIR:-/tmp}/luminary-smoke.XXXXXX")" || exit 1 export XDG_DATA_HOME="$WORK_DIR/xdg" export LUMINARY_DATA="$WORK_DIR/data" export LUMINARY_WINDOW=none BODY="$WORK_DIR/body.json" URL="" cleanup() { if [ -x "$BUNDLE/luminary" ] && [ -f "$LUMINARY_DATA/luminary.pid" ]; then "$BUNDLE/luminary" --stop >/dev/null 2>&1 || true fi rm -rf "$WORK_DIR" } trap cleanup EXIT # http [json-body] -> status code on stdout, body in $BODY http() { "$NODE" -e ' const [method, url, payload, out] = process.argv.slice(-4); const init = { method }; if (payload) { init.headers = { "Content-Type": "application/json" }; init.body = payload; } fetch(url, init) .then(async (r) => { require("node:fs").writeFileSync(out, await r.text()); process.stdout.write(String(r.status)); }) .catch(() => process.stdout.write("0")); ' "$1" "$2" "${3:-}" "$BODY" } # jget -> value from the last response body jget() { "$NODE" -e ' const fs = require("node:fs"); let value; try { value = JSON.parse(fs.readFileSync(process.argv.slice(-2)[0], "utf8")); } catch { process.exit(0); } for (const key of process.argv.slice(-1)[0].split(".")) value = value == null ? value : value[key]; if (value !== undefined && value !== null) process.stdout.write(String(value)); ' "$BODY" "$1" } browser_name() { local name for name in google-chrome google-chrome-stable chromium chromium-browser \ microsoft-edge microsoft-edge-stable brave-browser vivaldi-stable firefox; do if command -v "$name" >/dev/null 2>&1; then printf '%s' "$name" return 0 fi done return 1 } say 'Luminary Linux smoke test' say " bundle $BUNDLE" say " time $(date -Is)" say '' say 'Environment' if [ -r /etc/os-release ]; then # shellcheck disable=SC1091 distro="$(. /etc/os-release && printf '%s' "${PRETTY_NAME:-${NAME:-unknown}}")" else distro="$(uname -s)" fi say " distro $distro" say " arch $(uname -m)" say " kernel $(uname -r)" say " glibc $(ldd --version 2>/dev/null | head -n 1 || printf 'unknown')" say " display ${DISPLAY:-none}${WAYLAND_DISPLAY:+ (wayland $WAYLAND_DISPLAY)}" if browser="$(browser_name)"; then say " browser $browser" else say ' browser none found (the launcher would fall back to the default browser)' fi say '' say 'Bundle' check 'luminary launcher present' $([ -x "$BUNDLE/luminary" ] && echo 0 || echo 1) check 'runtime/bin/node present' $([ -x "$BUNDLE/runtime/bin/node" ] && echo 0 || echo 1) "$BUNDLE/runtime/bin/node" check 'app/server/index.mjs present' $([ -f "$BUNDLE/app/server/index.mjs" ] && echo 0 || echo 1) check 'app/dist/index.html present' $([ -f "$BUNDLE/app/dist/index.html" ] && echo 0 || echo 1) check 'app/node_modules present' $([ -d "$BUNDLE/app/node_modules" ] && echo 0 || echo 1) node_version="$("$NODE" --version 2>/dev/null)" check 'node runs' $([ -n "$node_version" ] && echo 0 || echo 1) "$node_version" check 'node is 24 or newer' "$("$NODE" -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 24 ? 0 : 1)' 2>/dev/null; echo $?)" if [ -x "$BUNDLE/luminary" ]; then if "$BUNDLE/luminary" --verify >"$WORK_DIR/verify.txt" 2>&1; then check '--verify exits 0' 0 else check '--verify exits 0' 1 "$(tr '\n' ' ' <"$WORK_DIR/verify.txt")" fi else check '--verify exits 0' 1 'launcher missing' fi say '' say 'Server (desktop mode, via the launcher)' "$BUNDLE/luminary" >"$WORK_DIR/start.txt" 2>&1 start_status=$? check 'launcher start exits 0' "$start_status" "$(head -n 1 "$WORK_DIR/start.txt")" if [ -f "$LUMINARY_DATA/runtime.json" ]; then check 'runtime.json written' 0 URL="http://127.0.0.1:$("$NODE" -p "JSON.parse(require('fs').readFileSync('$LUMINARY_DATA/runtime.json','utf8')).port")" else check 'runtime.json written' 1 "$LUMINARY_DATA/runtime.json" fi if [ -n "$URL" ]; then code="$(http GET "$URL/api/health")" check 'health answers' $([ "$code" = "200" ] && echo 0 || echo 1) "HTTP $code" if [ "$code" = "200" ]; then check 'local mode advertised' $([ "$(jget local)" = "true" ] && echo 0 || echo 1) "local=$(jget local)" check 'version advertised' $([ -n "$(jget version)" ] && echo 0 || echo 1) "version=$(jget version)" check 'no setup prompt' $([ "$(jget needsSetup)" = "false" ] && echo 0 || echo 1) check 'registration closed' $([ "$(jget registrationOpen)" = "false" ] && echo 0 || echo 1) check 'libraw ready' $([ "$(jget raw.libraw)" = "true" ] && echo 0 || echo 1) check 'sharp ready' $([ "$(jget raw.sharp)" = "true" ] && echo 0 || echo 1) fi code="$(http GET "$URL/api/auth/me")" me_email="$(jget user.email)" me_role="$(jget user.role)" check 'signed in without a cookie' $([ "$code" = "200" ] && echo 0 || echo 1) "HTTP $code $me_email ($me_role)" code="$(http POST "$URL/api/auth/register" '{"email":"smoke@example.test","password":"smoke-test-password"}')" check 'registration refused' $([ "$code" = "403" ] && echo 0 || echo 1) "HTTP $code" code="$(http GET "$URL/api/sync")" check '/api/sync answers' $([ "$code" = "200" ] && echo 0 || echo 1) "HTTP $code" code="$(http GET "$URL/")" check 'UI index served' $([ "$code" = "200" ] && echo 0 || echo 1) "HTTP $code" if [ "$code" = "200" ] && grep -q 'src/assets\|assets/' "$BODY"; then check 'UI references built assets' 0 else check 'UI references built assets' 1 fi fi if "$BUNDLE/luminary" --status 2>/dev/null | grep -q 'Status: running'; then check '--status reports running' 0 else check '--status reports running' 1 fi say '' say 'Menu entry' if XDG_DATA_HOME="$WORK_DIR/xdg" "$BUNDLE/luminary" --install >/dev/null 2>&1 && [ -f "$WORK_DIR/xdg/applications/luminary.desktop" ]; then check '--install writes a .desktop file' 0 if grep -q "^Exec=\"\?$BUNDLE/luminary\"\?$" "$WORK_DIR/xdg/applications/luminary.desktop"; then check 'menu entry points at this bundle' 0 else check 'menu entry points at this bundle' 1 "$(grep '^Exec=' "$WORK_DIR/xdg/applications/luminary.desktop")" fi else check '--install writes a .desktop file' 1 fi if XDG_DATA_HOME="$WORK_DIR/xdg" "$BUNDLE/luminary" --uninstall >/dev/null 2>&1 && [ ! -f "$WORK_DIR/xdg/applications/luminary.desktop" ]; then check '--uninstall removes it' 0 else check '--uninstall removes it' 1 fi say '' say 'Stop' "$BUNDLE/luminary" --stop >/dev/null 2>&1 if [ -n "$URL" ]; then code="$(http GET "$URL/api/health")" check 'server stopped' $([ "$code" = "0" ] && echo 0 || echo 1) "HTTP $code" else check 'server stopped' 1 'server never started' fi if "$BUNDLE/luminary" --status 2>/dev/null | grep -q 'Status: stopped'; then check '--status reports stopped' 0 else check '--status reports stopped' 1 fi say '' say 'Window' skip 'app window opens' 'visual check; the launcher opened nothing during this run' say '' if [ "$FAILED" -eq 0 ]; then say 'RESULT: PASS' else say "RESULT: FAIL ($FAILED check(s))" fi report="$BUNDLE/smoke-report.txt" if ! { printf '%s\n' "${LINES[@]}" >"$report"; } 2>/dev/null; then report="$(pwd)/smoke-report.txt" printf '%s\n' "${LINES[@]}" >"$report" 2>/dev/null || true fi [ -f "$report" ] && say " report $report" [ "$FAILED" -eq 0 ] && exit 0 || exit 1