/bin/sh -c "
# Wait until the printer is genuinely up -- klippy answering and moonraker
# serving -- retrying klipper when a board did not come back, and on a first
# boot import this unit's factory calibration. The UI depends on this, so
# HelixScreen starts in front of a working printer rather than a connecting one.
#
# IT NEVER EXITS NON-ZERO -- a timeout would leave the printer with no screen,
# which is worse than the thing it would be reporting.
MODDIR=/usr/data/anvil
[ -f \$MODDIR/anvil-env.sh ] && . \$MODDIR/anvil-env.sh

if [ ! -f \$MODDIR/bin/ff-startup.py ] || [ ! -x \"\$FF_PYTHON\" ]; then
    echo 'ff-startup: !! no ff-startup.py or no interpreter -- not waiting for the printer'
    exit 0
fi

# --no-bringup because mcu-bringup already did it; retries inside the program
# still redo the handover, which is the half that matters. --no-klipper because
# klipper is a dependency now, not this program's to launch -- it still restarts
# it through s6-svc.
#
# NO --timeout AND NO --klipper-tries: the program's own defaults are the only
# statement of either, so there is nowhere for the two to disagree.
\"\$FF_PYTHON\" \$MODDIR/bin/ff-startup.py --no-bringup --no-klipper \
    || echo \"ff-startup: !! returned \$? -- the next boot will try again\"
exit 0
"
