Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

docs(air-gapped): extract to a private temp dir and hand off by digest-named path

xerj-org744c1822a489
diff --git a/docs/recipes/air-gapped-deployment.md b/docs/recipes/air-gapped-deployment.md
index 1c87ff8f1..2c2839b51 100644
--- a/docs/recipes/air-gapped-deployment.md
+++ b/docs/recipes/air-gapped-deployment.md
@@ -106,8 +106,6 @@ ASSET="${STAGE}.tar.gz"
set -eu
cd /opt/xerj-staging/release
- rm -rf "$STAGE" "$STAGE.verified"
-
want="$(sha256sum "$ASSET" | cut -d ' ' -f 1)"
if [[ ! "$want" =~ ^[0-9a-f]{64}$ ]]; then
echo "could not compute a digest for $ASSET" >&2
@@ -116,9 +114,14 @@ ASSET="${STAGE}.tar.gz"
LC_ALL=C grep -qxF -e "$want $ASSET" -e "$want *$ASSET" \
< <(tr -d '\r' < "$ASSET.sha256")
- tar -xzf "$ASSET"
- test -x "$STAGE/xerj"
- mv "$STAGE" "$STAGE.verified"
+ work="$(mktemp -d ./.xerj-verify.XXXXXX)"
+ trap 'rm -rf "$work"' EXIT
+ tar -xzf "$ASSET" -C "$work"
+ test -x "$work/$STAGE/xerj"
+
+ rm -rf "$STAGE.verified.$want"
+ mv -T "$work/$STAGE" "$STAGE.verified.$want"
+ echo "verified $ASSET -> $STAGE.verified.$want"
)
```
@@ -168,14 +171,16 @@ model directory is created for the lexical deployment.
```bash
set -eu
-: "${VERSION:?run section 1 in this shell first, or set VERSION to the verified release}"
+: "${STAGE:?run section 1 in this shell first}"
+: "${ASSET:?run section 1 in this shell first}"
if ! getent passwd xerj >/dev/null; then
sudo useradd --system --user-group --home-dir /var/lib/xerj --shell /sbin/nologin xerj
fi
sudo install -d -m 0755 /opt/xerj/bin /etc/xerj
sudo install -d -o xerj -g xerj -m 0750 /var/lib/xerj
sudo install -m 0755 \
- "/opt/xerj-staging/release/xerj-${VERSION}-x86_64-unknown-linux-musl.verified/xerj" \
+ "/opt/xerj-staging/release/${STAGE}.verified.$(cd /opt/xerj-staging/release \
+ && sha256sum "$ASSET" | cut -d ' ' -f 1)/xerj" \
/opt/xerj/bin/xerj
```
diff --git a/landing/docs/recipes/air-gapped-deployment.html b/landing/docs/recipes/air-gapped-deployment.html
index 8dd8ce7ea..009f60819 100644
--- a/landing/docs/recipes/air-gapped-deployment.html
+++ b/landing/docs/recipes/air-gapped-deployment.html
@@ -109,8 +109,6 @@ ASSET="${STAGE}.tar.gz"
set -eu
cd /opt/xerj-staging/release
- rm -rf "$STAGE" "$STAGE.verified"
-
want="$(sha256sum "$ASSET" | cut -d ' ' -f 1)"
if [[ ! "$want" =~ ^[0-9a-f]{64}$ ]]; then
echo "could not compute a digest for $ASSET" &gt;&amp;2
@@ -119,9 +117,14 @@ ASSET="${STAGE}.tar.gz"
LC_ALL=C grep -qxF -e "$want $ASSET" -e "$want *$ASSET" \
&lt; &lt;(tr -d '\r' &lt; "$ASSET.sha256")
- tar -xzf "$ASSET"
- test -x "$STAGE/xerj"
- mv "$STAGE" "$STAGE.verified"
+ work="$(mktemp -d ./.xerj-verify.XXXXXX)"
+ trap 'rm -rf "$work"' EXIT
+ tar -xzf "$ASSET" -C "$work"
+ test -x "$work/$STAGE/xerj"
+
+ rm -rf "$STAGE.verified.$want"
+ mv -T "$work/$STAGE" "$STAGE.verified.$want"
+ echo "verified $ASSET -&gt; $STAGE.verified.$want"
)</pre>
<p>Three details are load-bearing, and each replaces something that looked right and was not. <strong>The digest is computed here and the file is searched for it, not the other way round</strong> &mdash; <code class="inline">sha256sum -c</code> reads the filename out of the <code class="inline">.sha256</code>, a file that crossed the airgap on the same medium as the archive, skips <code class="inline">#</code> comments silently, and exits <code class="inline">0</code> if any one line verified, so a decoy digest plus a comment naming the archive passes while the archive is never hashed. Filtering that file first does not fix it: <code class="inline">awk '$2 == asset'</code> compares one token while <code class="inline">sha256sum</code> takes the whole rest of the line as the filename, so a line naming <code class="inline">$ASSET decoy</code> satisfies the filter and hashes a decoy. Building the expected line in the shell and demanding it with <code class="inline">grep -qxF</code> removes the disagreement. The two patterns accept GNU text mode and <code class="inline">-b</code> binary mode; <code class="inline">tr -d '\r'</code> accepts a checksum file written on Windows. <strong><code class="inline">set -eu</code> is inside the subshell</strong> &mdash; at the top of the block it kills the operator&rsquo;s login shell on a bad digest, and the natural recovery is to re-paste without it, which is the fail-open form. <strong>Section 2 installs from <code class="inline">$STAGE.verified</code></strong>, which <code class="inline">mv</code> creates only after the digest, the extraction and <code class="inline">test -x</code> have all succeeded &mdash; so the block is safe even when its exit status is ignored, because on any failure there is nothing at the install path. That last part is only true because <code class="inline">rm -rf</code> runs <strong>first</strong>: placed after the digest check it is unreachable on exactly the failure that matters, and a <code class="inline">$STAGE.verified</code> left by an earlier run &mdash; or planted by anyone who can write to the staging directory &mdash; would survive and be installed.</p>
@@ -129,14 +132,16 @@ ASSET="${STAGE}.tar.gz"
<p>Create the service account first, then install only the staged binary. No model directory is needed for lexical mode:</p>
<pre class="code">set -eu
-: "${VERSION:?run section 1 in this shell first, or set VERSION to the verified release}"
+: "${STAGE:?run section 1 in this shell first}"
+: "${ASSET:?run section 1 in this shell first}"
if ! getent passwd xerj &gt;/dev/null; then
sudo useradd --system --user-group --home-dir /var/lib/xerj --shell /sbin/nologin xerj
fi
sudo install -d -m 0755 /opt/xerj/bin /etc/xerj
sudo install -d -o xerj -g xerj -m 0750 /var/lib/xerj
sudo install -m 0755 \
- "/opt/xerj-staging/release/xerj-${VERSION}-x86_64-unknown-linux-musl.verified/xerj" \
+ "/opt/xerj-staging/release/${STAGE}.verified.$(cd /opt/xerj-staging/release \
+ &amp;&amp; sha256sum "$ASSET" | cut -d ' ' -f 1)/xerj" \
/opt/xerj/bin/xerj</pre>
<p>Create <code class="inline">/etc/xerj/xerj.toml</code> with the complete base configuration. Explicit lexical mode and an empty endpoint keep this path model-free:</p>
<pre class="code">[server]