#!/usr/bin/env bash # Serve a built package under the service unit's syscall filter, as a # transient user unit, on a scratch port and state; check the home page. # The flake's smoke check can't: the nix sandbox has no systemd. # usage: probe-unit.sh set -euo pipefail out=$1 state=$(mktemp -d) trap 'systemctl --user stop diigo-cache-probe 2>/dev/null; rm -rf "$state"' EXIT mkdir "$state/cache" "$state/webapp" props=() while IFS= read -r line; do props+=(-p "$line"); done \ < <(grep '^SystemCallFilter=' "$out/lib/systemd/system/diigo-cache.service") systemd-run --user -q --collect --unit=diigo-cache-probe "${props[@]}" \ "$out/bin/diigo-cache-serve" -s http=127.0.0.1:18791 \ -d cache-state="$state/cache" -d webapp-state="$state/webapp" for _ in $(seq 30); do if curl -sf -m 2 http://127.0.0.1:18791/ | grep -q _connect; then echo "probe: ok" exit 0 fi sleep 0.3 done echo "probe: no home page; see journalctl --user -u diigo-cache-probe and journalctl -k | grep syscall=" >&2 exit 1