#!/sbin/openrc-run
description="Peacock debug SSH daemon"

[ -f /etc/peacock/debug-ssh.conf ] && . /etc/peacock/debug-ssh.conf || true
SSHD_PORT="${SSHD_PORT:-22}"

command="/usr/local/sbin/peacock-debug-sshd"
command_args=""
command_background="yes"
pidfile="/run/peacock-debug-sshd.pid"

start_pre() {
    /usr/local/sbin/peacock-debug-sshd-prepare
    # Force debug daemon ownership of the SSH port.
    killall sshd >/dev/null 2>&1 || true
    killall dropbear >/dev/null 2>&1 || true
    rm -f "${pidfile}" >/dev/null 2>&1 || true
}

depend() {
    need localmount
    after peacock-debug-rndis net
    before sshd
}
