discord: unit can run from a pinned copy; check --offline; status reads the effective tree (row 114, #1608)
Candidate manifest 68c60a79914692f3f6d4923f7bcff41de109ccca33bf6fba687fb88efa24bcac from Rocko's round 1 packet (a94a943c9), on BASE72c9ac36c. No manifest path changed between BASE and the landing target. Filbert approved round 1 in 28497 with no findings; the TOOLS.md paragraph break is a doc-only follow-up (decision 137). Sage reran the full gate at the landing target with the candidate applied and Docker live. Nothing is installed or restarted; the live switch is Mos's step after the SetSpark freeze lifts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -209,6 +209,62 @@ env -u USER scripts/discord-service.sh install --dir "$SANDBOX/units-nouser" --n
|
||||
&& grep -qF "enable-linger $(id -un)" "$SANDBOX/install.nouser"
|
||||
check "service install with USER unset finishes and names the account for lingering" $?
|
||||
|
||||
# --- pinned copy service, fixture paths only ---
|
||||
COPY_ID="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
COPIES="$SANDBOX/copies"
|
||||
COPY="$COPIES/$COPY_ID"
|
||||
mkdir -p "$COPY/packages/discord/src" "$COPY/node_modules/.bin"
|
||||
printf '// fixture\n' > "$COPY/packages/discord/src/cli.mjs"
|
||||
printf '#!/bin/sh\nexit 0\n' > "$COPY/node_modules/.bin/pi"
|
||||
chmod 755 "$COPY/node_modules/.bin/pi"
|
||||
scripts/discord-service.sh render --copy "$COPY_ID" --copies "$COPIES" >"$SANDBOX/unit.copy" 2>&1 \
|
||||
&& grep -qxF "WorkingDirectory=$COPY" "$SANDBOX/unit.copy" \
|
||||
&& grep -qxF "ExecStart=$(command -v node) $COPY/packages/discord/src/cli.mjs run %i --supervised --repo $COPY" "$SANDBOX/unit.copy" \
|
||||
&& ! sed -n '/^WorkingDirectory=/p;/^ExecStart=/p' "$SANDBOX/unit.copy" | grep -qF "$REPO_DIR"
|
||||
check "pinned render runs copy CLI with copy cwd/repo and no checkout executable" $?
|
||||
scripts/discord-service.sh install --copy "$COPY_ID" --copies "$COPIES" --dir "$SANDBOX/pinned-units" --no-reload >"$SANDBOX/pinned-install" 2>&1 \
|
||||
&& cmp -s "$SANDBOX/pinned-units/[email protected]" "$SANDBOX/unit.copy"
|
||||
check "pinned install writes the rendered unit in a temporary unit directory" $?
|
||||
for kind in short missing cli pi; do
|
||||
id="$COPY_ID"
|
||||
case "$kind" in short) id=short;; missing) id=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;; cli) rm "$COPY/packages/discord/src/cli.mjs";; pi) printf '// fixture\n' > "$COPY/packages/discord/src/cli.mjs";rm "$COPY/node_modules/.bin/pi";; esac
|
||||
scripts/discord-service.sh install --copy "$id" --copies "$COPIES" --dir "$SANDBOX/refused-$kind" --no-reload >"$SANDBOX/refused-$kind.log" 2>&1
|
||||
rc=$?
|
||||
[ "$rc" -eq 1 ] && [ ! -e "$SANDBOX/refused-$kind/[email protected]" ]
|
||||
check "pinned install refuses $kind prerequisite and writes no unit" $?
|
||||
done
|
||||
printf '#!/bin/sh\nexit 0\n' > "$COPY/node_modules/.bin/pi"
|
||||
mkdir -p "$SANDBOX/fake-bin"
|
||||
cat >"$SANDBOX/fake-bin/systemctl" <<EOF_STATUS
|
||||
#!/bin/sh
|
||||
case "\$*" in *show*) echo 'WorkingDirectory=$COPY';; *)echo inactive;; esac
|
||||
EOF_STATUS
|
||||
chmod 755 "$SANDBOX/fake-bin/systemctl"
|
||||
HOME="$SANDBOX/home" XDG_CONFIG_HOME="$SANDBOX/config-home" PATH="$SANDBOX/fake-bin:$PATH" scripts/discord-service.sh status fixture >"$SANDBOX/status.copy" 2>&1 \
|
||||
&& grep -qF "copy: $COPY_ID" "$SANDBOX/status.copy" \
|
||||
&& grep -qF "tree: $COPY" "$SANDBOX/status.copy"
|
||||
check "status names the copy from fake systemctl effective cwd" $?
|
||||
grep -qF "checkout: $REPO_DIR" "$SANDBOX/install.1" && grep -qF -- '--copy' "$SANDBOX/install.1"
|
||||
check "checkout install explicitly recommends --copy" $?
|
||||
|
||||
# Offline wrapper entrypoint. Only a synthetic token/binding/config are used.
|
||||
node - "$SANDBOX" <<'EOF_OFFLINE'
|
||||
const fs=require('fs'),p=require('path'),root=process.argv[2];
|
||||
const data=p.join(root,'offline-data');fs.mkdirSync(p.join(data,'discord'),{recursive:true});
|
||||
const b=JSON.parse(fs.readFileSync('packages/discord/fixtures/binding.example.json','utf8'));
|
||||
b.name='offline-fixture';b.tokenFile=p.join(root,'offline-token');b.context.files=['packages/discord/README.md'];delete b.tools;
|
||||
fs.writeFileSync(b.tokenFile,'MTAw.abcdefghijklmnopqrstuvwxyz0123456789\n',{mode:0o600});
|
||||
fs.writeFileSync(p.join(data,'discord',b.name+'.json'),JSON.stringify(b),{mode:0o600});
|
||||
fs.writeFileSync(p.join(root,'offline-config'),JSON.stringify({dataRoot:data}));
|
||||
fs.writeFileSync(p.join(root,'offline-trap.mjs'),`globalThis.fetch=()=>{throw Error('network forbidden in offline fixture')};globalThis.WebSocket=class{constructor(){throw Error('gateway forbidden in offline fixture')}};`);
|
||||
EOF_OFFLINE
|
||||
NODE_OPTIONS="--import=$SANDBOX/offline-trap.mjs" scripts/discord.sh check offline-fixture --config "$SANDBOX/offline-config" --offline >"$SANDBOX/offline.out" 2>&1 \
|
||||
&& grep -qF 'offline check passed; no REST or gateway calls were made' "$SANDBOX/offline.out"
|
||||
check "wrapper check --offline passes local fixture and makes no network call" $?
|
||||
NODE_OPTIONS="--import=$SANDBOX/offline-trap.mjs" scripts/discord.sh run offline-fixture --config "$SANDBOX/offline-config" --offline >"$SANDBOX/offline-run.out" 2>&1
|
||||
[ $? -eq 4 ]
|
||||
check "wrapper run --offline refuses usage" $?
|
||||
|
||||
echo
|
||||
echo "discord suite: $PASS passed, $FAIL failed"
|
||||
[ "$FAIL" -eq 0 ]
|
||||
|
||||
Reference in New Issue
Block a user