2024-09-29 20:39:30 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Read configuration files from SD card.
|
|
|
|
#
|
|
|
|
|
|
|
|
. /opt/puzzlefw/lib/functions.sh
|
|
|
|
|
2024-10-13 14:51:43 +02:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2024-09-29 20:39:30 +02:00
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
echo "Reading configuration files from SD card ..."
|
|
|
|
lock_config || exit 1
|
|
|
|
read_config || exit 1
|
2024-10-13 14:51:43 +02:00
|
|
|
copy_ssh_host_key
|
2024-09-29 20:39:30 +02:00
|
|
|
;;
|
|
|
|
stop|restart|reload)
|
|
|
|
true
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 start"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|