redpitaya-puzzlefw/sw/buildroot_overlay/etc/init.d/S03read_config.sh

43 lines
967 B
Bash
Raw Normal View History

#!/bin/sh
#
# Read configuration files from SD card.
#
. /opt/puzzlefw/lib/functions.sh
# Copy SSH host key from configuration partition.
copy_ssh_host_key() {
# 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
fi
chmod 0600 /etc/dropbear/dropbear_ed25519_host_key || true
}
case "$1" in
start)
echo "Reading configuration files from SD card ..."
lock_config || exit 1
read_config || exit 1
copy_ssh_host_key
;;
stop|restart|reload)
true
;;
*)
echo "Usage: $0 start"
exit 1
esac