#!/bin/sh # # Load SSH host key from SD card. # . /opt/puzzlefw/lib/functions.sh start() { # If host key exists, do nothing. [ -f /etc/dropbear/dropbear_ed25519_host_key ] && return # If /etc/dropbear is a symlink, delete it. [ -L /etc/dropbear ] && rm /etc/dropbear # Create directory /etc/dropbear if it does not exist. mkdir -p /etc/dropbear # Try to copy SSH host key from configuration files. if ! cp -p ${CONFIG_DIR}/dropbear_ed25519_host_key /etc/dropbear ; then echo "WARNING: Failed to load SSH host key from SD card" >&2 echo "Generating new SSH host key." >&2 dropbearkey -t ed25519 -f ${CONFIG_DIR}/dropbear_ed25519_host_key.new sync_config dropbear_ed25519_host_key cp -p ${CONFIG_DIR}/dropbear_ed25519_host_key /etc/dropbear fi chmod 0600 /etc/dropbear/dropbear_ed25519_host_key } case "$1" in start) start ;; stop|restart|reload) ;; *) echo "Usage: $0 start" exit 1 esac