⬢ DragonFlyBSD Kernel Audit
DF-5727 / enter_ddb.sh
← back to finding ↓ download raw
#!/bin/sh
# enter_ddb.sh UP — wait for ssh, fire debug.enter_debugger=ddb in the
# background (the sysctl blocks until DDB resumes), then wait for the db>
# prompt on the UP serial log.
set -eu
LOG=/tmp/opencode/df-5725-serial-up.log
cd /home/maxx/dfbsd/dfbsd/dfbsd-qemu

i=0
while [ $i -lt 40 ]; do
    if ssh -F config -o ConnectTimeout=5 -o BatchMode=yes dfbsd-maxx true >/dev/null 2>&1; then
        break
    fi
    sleep 3; i=$((i+3))
done
[ $i -lt 40 ] || { echo "ssh never came back"; exit 1; }

( ssh -F config -o ConnectTimeout=8 -o BatchMode=yes root@dfbsd \
    'sysctl debug.enter_debugger=ddb' >/tmp/opencode/df-5725-enter.out 2>&1 & ) || true

j=0
while [ $j -lt 30 ]; do
    if tail -2 "$LOG" 2>/dev/null | grep -q 'db>'; then
        echo "DDB entered"; exit 0
    fi
    sleep 1; j=$((j+1))
done
echo "DDB prompt not seen"; tail -5 "$LOG"; exit 1