#!/bin/sh

### BEGIN INIT INFO
# Provides:           host-ssh-keys
# Required-Start:     $local_fs
# Required-Stop:      $local_fs
# Default-Start:      S
# Default-Stop:
# Short-Description:  Generate SSH host keys on first boot.
### END INIT INFO

. /lib/lsb/init-functions

set -e

case "$1" in
	start)
		log_begin_msg 'Generating SSH host keys'
		ssh-keygen -q -f /etc/ssh/ssh_host_rsa_key -t rsa -N ''
		ssh-keygen -q -f /etc/ssh/ssh_host_dsa_key -t dsa -N ''
		ssh-keygen -q -f /etc/ssh/ssh_host_ecdsa_key -t ecdsa -N ''
		ssh-keygen -q -f /etc/ssh/ssh_host_ed25519_key -t ed25519 -N ''
		update-rc.d generate_ssh_keys remove
		rm -f /etc/init.d/generate_ssh_keys
		log_end_msg $?
		;;
	*)
		log_failure_msg "operation '$2' not supported"
		exit 1
		;;
esac

exit 0
