#!/bin/bash # BRINTOS-32 self-test (non-interactive half): mc binary + runtime data. # Runs on any capability set (no expect needed). The interactive UI half is # /root/selftest_mc.exp (needs /bin/expect-dyn) or a human in the browser. pass=0; fail=0 ok(){ pass=$((pass+1)); echo "MC-OK $1"; } bad(){ fail=$((fail+1)); echo "MC-FAIL $1"; } v=$(/usr/bin/mc --version 2>&1 | head -1) case "$v" in *"GNU Midnight Commander 4.8.33"*) ok "version: $v";; *) bad "version: $v";; esac for l in mcedit mcview mcdiff; do [ -e "/usr/bin/$l" ] && ok "$l present" || bad "$l missing" done [ -f /usr/share/mc/help/mc.hlp ] && ok "help file" || bad "help file missing" [ -d /usr/share/mc/syntax ] && ok "syntax dir" || bad "syntax dir missing" [ -d /usr/share/mc/skins ] && ok "skins dir" || bad "skins dir missing" [ -f /etc/mc/mc.menu ] && ok "/etc/mc/mc.menu" || bad "/etc/mc/mc.menu missing" [ -f /usr/share/terminfo/x/xterm ] && ok "terminfo xterm" || bad "terminfo xterm missing" # RED witness: an absurd version must NOT match. Uses only shell builtins -- # the image ships no grep (coreutils does not carry it), and piping into a # missing grep returns 127, which the old `grep -q ... && bad || ok` form # silently scored as a PASS -- the witness could never fire. mcver=$(/usr/bin/mc --version 2>&1) case "$mcver" in *"GNU Midnight Commander 9.9.99"*) bad "red-witness (absurd version matched)" ;; *"GNU Midnight Commander"*) ok "red-witness" ;; *) bad "red-witness (no version banner at all)" ;; esac echo "pass=$pass fail=$fail" [ "$fail" -eq 0 ] && echo "ALL-MC-OK" || exit 1