#!/bin/sh
set -eu

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

if [ -x /usr/sbin/dropbear ]; then
    exec /usr/sbin/dropbear -F -p "$SSHD_PORT" -R -P /run/peacock-debug-sshd.pid -B "$@"
fi
if [ -x /usr/bin/dropbear ]; then
    exec /usr/bin/dropbear -F -p "$SSHD_PORT" -R -P /run/peacock-debug-sshd.pid -B "$@"
fi
if [ -x /usr/bin/sshd ]; then
    exec /usr/bin/sshd -D -f /etc/ssh/sshd_config_peacock_debug -E /var/log/peacock-debug-sshd.log "$@"
fi
if [ -x /usr/sbin/sshd ]; then
    exec /usr/sbin/sshd -D -f /etc/ssh/sshd_config_peacock_debug -E /var/log/peacock-debug-sshd.log "$@"
fi

echo "peacock-debug-sshd: no ssh daemon binary found (sshd/dropbear)" >&2
exit 127
