# -*- mode: shell-script; -*-
# dropbear

start on stopped finish
stop on runlevel [!2]
stop on started start_update

console output

service

script
    # Current plan is that the dropbear package includes these keys.
    # This is not secure, but it speeds boots considerably, and
    # current plan is also that we don't ship with dropbear.  If we do
    # ship, we'll want to move back to generating keys locally.  So
    # leave this in.
    mkdir -p /etc/dropbear
    if [ ! -f /etc/dropbear/dropbear_rsa_host_key ]; then
	    echo "generating /etc/dropbear/dropbear_rsa_host_key"
	    /usr/sbin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
    fi  
    if [ ! -f /etc/dropbear/dropbear_dss_host_key ]; then
	    echo "generating /etc/dropbear/dropbear_dss_host_key"
	    /usr/sbin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
    fi

    # dropbear expects /var/log/lastlog, so touch, and use /bin/true
    # in case touch fails, e.g. because /var/log doesn't exist
    [ -e /var/log/lastlog ] || touch /var/log/lastlog || /bin/true
    /usr/sbin/dropbear -F
end script

respawn
