#!/usr/bin/execlineb -P

foreground { if { test -e /etc/ssh/sshd_not_to_be_run } s6-rc stop sshd }
foreground { bash -c "if id -u sshd >/dev/null 2>&1 ; then exit 0 ; else /sbin/useradd -r sshd -s /bin/nologin >/dev/null 2>&1 ; fi" }
foreground { mkdir -p /run/sshd }
foreground { chmod 0755 /run/sshd }
foreground { redirfd -w 1 /dev/null ssh-keygen -A }
foreground { touch /var/log/lastlog }
foreground { chgrp utmp /var/log/lastlog }
foreground { chmod 664 /var/log/lastlog }

envfile /etc/s6-rc/config/sshd.conf
importas -sCuD "" OPTS OPTS

fdmove -c 2 1
exec -c /usr/sbin/sshd -D -e ${OPTS}
