#!/bin/bash
# /etc/rc.d/sshd — Dropbear SSH server on port 22.
#
# /sbin/sshd is a tiny launcher (userland/sshd/sshd.c) that execs /sbin/dropbear
# with the AnotherOS options. It binds 0.0.0.0 EXPLICITLY: we have no IPv6, and
# Dropbear treats the EAFNOSUPPORT from the passive wildcard's first (AF_INET6)
# result as fatal rather than falling through to the AF_INET one.
case "$1" in
    start)
        # A missing binary used to `exit 0` silently, which made a failed SSH
        # start indistinguishable from a disabled one — the reason this daemon
        # was dead at boot for so long without a word on the console.
        if [ ! -x /sbin/sshd ]; then
            echo "rc: sshd: /sbin/sshd missing or not executable" >&2
            exit 1
        fi
        /sbin/sshd &
        ;;
    stop)
        killall dropbear 2>/dev/null
        ;;
    *)
        echo "usage: $0 start|stop" >&2; exit 1 ;;
esac
exit 0
