Morse Micro c8fb813f41 dppd: add Morse Micro dpp daemon package and dependency
adds recipe for the Morse Micro dpp daemon and an updated version of libmicrohttpd
as required by the package - replicating that from the OpenWrt upstream.
2025-03-02 16:34:29 +11:00

80 lines
2.0 KiB
Bash
Executable File

#!/bin/sh /etc/rc.common
START=90
STOP=01
USE_PROCD=1
SERVICE=dppd
find_morse_device() {
local device=$1
local type_morse
config_get type_morse $device type
if [ "$type_morse" == "morse" ]; then
morse_radio=$1
return 1
fi
}
find_iface_ap_key() {
local iface=$1
local radio=$2
local dev_iface=
config_get dev_iface $iface device
[ "$dev_iface" != "$radio" ] && return;
local is_ap=
config_get is_ap $iface mode
[ "$is_ap" != "ap" ] && return;
local encryption=
config_get encryption $iface encryption
[ "$encryption" != "sae" ] && return;
config_get key $iface key
}
get_encryption_key() {
config_load wireless
config_foreach find_morse_device wifi-device
config_foreach find_iface_ap_key wifi-iface $morse_radio
}
start_dppd() {
procd_open_instance
procd_set_param command dppd --passphrase="$1"
procd_set_param stdout 1
procd_set_param stderr 1
procd_append_param command --http-secrets=/etc/dppd/auth_secrets.txt
procd_append_param command --tls-cert=/etc/dppd/server.pem --tls-key=/etc/dppd/server.key
procd_append_param command --configurator-key=/etc/dppd/key.pem --configurator-private-key=/etc/dppd/ppkey.pem
procd_append_param command daemon
procd_set_param limits as="15000000 15000000"
procd_set_param respawn 3600 5 50
procd_close_instance
}
start_service() {
get_encryption_key
if [ -z "$key" ]; then
logger -t $SERVICE -p daemon.crit "No AP on morse device with encryption as SAE"
return 1
fi
start_dppd $key
}
reload_service() {
stop
# Wait until hostapd stops (otherwise we reconnect to old hostapd with the wrong info,
# then lose the connection, then segfault when we find the new hostapd).
( sleep 5; start ) &
}
service_triggers() {
procd_add_reload_trigger wireless
}