From a3366728c439c9e2f19d57080322e64baee18dd1 Mon Sep 17 00:00:00 2001 From: goatzillax <13460445+goatzillax@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:45:35 -0600 Subject: [PATCH 1/5] Update busybox.config Enable dumpleases, early udhcpd lease writeout, and ntpd server for use in self-hosted AP mode. --- package/busybox/busybox.config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/busybox/busybox.config b/package/busybox/busybox.config index d61c19939..74a48956c 100644 --- a/package/busybox/busybox.config +++ b/package/busybox/busybox.config @@ -957,7 +957,7 @@ CONFIG_NSLOOKUP=y CONFIG_FEATURE_NSLOOKUP_BIG=y CONFIG_FEATURE_NSLOOKUP_LONG_OPTIONS=y CONFIG_NTPD=y -# CONFIG_FEATURE_NTPD_SERVER is not set +CONFIG_FEATURE_NTPD_SERVER=y CONFIG_FEATURE_NTPD_CONF=y CONFIG_FEATURE_NTP_AUTH=y CONFIG_PING=y @@ -1007,9 +1007,9 @@ CONFIG_FEATURE_WGET_TIMEOUT=y # CONFIG_ZCIP is not set CONFIG_UDHCPD=y # CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC is not set -# CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY is not set +CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY=y CONFIG_DHCPD_LEASES_FILE="" -# CONFIG_DUMPLEASES is not set +CONFIG_DUMPLEASES=y # CONFIG_DHCPRELAY is not set CONFIG_UDHCPC=y CONFIG_FEATURE_UDHCPC_ARPING=y From 196ca6fbb0012c8fc894816807b04ef0655549cb Mon Sep 17 00:00:00 2001 From: goatzillax <13460445+goatzillax@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:56:52 -0600 Subject: [PATCH 2/5] Update S49ntpd to launch listener in AP mode --- overlay/lower/etc/init.d/S49ntpd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/overlay/lower/etc/init.d/S49ntpd b/overlay/lower/etc/init.d/S49ntpd index 5be8c41d4..24bbf29de 100755 --- a/overlay/lower/etc/init.d/S49ntpd +++ b/overlay/lower/etc/init.d/S49ntpd @@ -9,7 +9,10 @@ TMP_CONF="/tmp/ntp.conf" start() { starting - [ "true" = "$(get wlanap_enabled)" ] && quit "AP mode" + if [ "true" = "$(get wlanap_enabled)" ]; then + touch $TMP_CONF + DAEMON_ARGS="-n -l" + fi if [ -f $TMP_CONF ]; then info "work config found" From 1e1c4ebfe9396d058cc8c6cc550b44cabe90ea3d Mon Sep 17 00:00:00 2001 From: goatzillax <13460445+goatzillax@users.noreply.github.com> Date: Tue, 19 Nov 2024 00:14:22 -0600 Subject: [PATCH 3/5] Update S42wifiap to add hostname to dns lookup This is in the remote use case where you have N number of cameras and any one of them can be switched into AP mode for the others to connect to, but it will resolve to the same hostname so scripting, etc. is maintained. --- package/thingino-ap/files/S42wifiap | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package/thingino-ap/files/S42wifiap b/package/thingino-ap/files/S42wifiap index 26651f02a..b6384de2f 100755 --- a/package/thingino-ap/files/S42wifiap +++ b/package/thingino-ap/files/S42wifiap @@ -27,8 +27,12 @@ case "$1" in ip link set $net_dev up ip route add ${CNET}.0/24 dev $net_dev > /dev/null 2>&1 + cp /etc/dnsd-ap.conf /tmp/dnsd.conf + hostname=$(get hostname) + grep $hostname /tmp/dnsd.conf > /dev/null || echo $hostname.local ${CNET}.1 >> /tmp/dnsd.conf + start-stop-daemon -S -x /sbin/udhcpd -- -S -I ${CNET}.1 /etc/udhcpd-ap.conf 2>&1 - start-stop-daemon -S -x /sbin/dnsd -- -i ${CNET}.1 -c /etc/dnsd-ap.conf -d | log + start-stop-daemon -S -x /sbin/dnsd -- -i ${CNET}.1 -c /tmp/dnsd.conf -d | log mac_address=$(ip link show $net_dev | awk '/ether/ {print $2}') last_two=$(echo $mac_address | awk -F: '{print $(NF-1) $NF}') From 21e8ecc74e838503d6f79b23a949b9c21454b8a4 Mon Sep 17 00:00:00 2001 From: goatzillax Date: Tue, 19 Nov 2024 18:40:43 -0600 Subject: [PATCH 4/5] Add script to update dnsd hosts from dumpleases --- package/thingino-ap/files/hosts-update | 14 ++++++++++++++ package/thingino-ap/thingino-ap.mk | 3 +++ 2 files changed, 17 insertions(+) create mode 100755 package/thingino-ap/files/hosts-update diff --git a/package/thingino-ap/files/hosts-update b/package/thingino-ap/files/hosts-update new file mode 100755 index 000000000..30105c9a4 --- /dev/null +++ b/package/thingino-ap/files/hosts-update @@ -0,0 +1,14 @@ +#!/bin/sh + +HOSTS=/tmp/dnsd.conf + +cp /etc/dnsd-ap.conf ${HOSTS} +hostname=$(get hostname) +grep $hostname ${HOSTS} > /dev/null || echo $(hostname).local $(hostname -i) >> ${HOSTS} + +dumpleases -f /run/udhcpd_ap.leases -d | grep -v "^Mac Address" | +while read line; do + ip=$(echo $line | cut -s -F 2) + hostname=$(echo $line | cut -s -F 3) + [ " " != "${line:34:1}" ] && echo $hostname.local $ip >> ${HOSTS} +done diff --git a/package/thingino-ap/thingino-ap.mk b/package/thingino-ap/thingino-ap.mk index 2a0549915..a8001b2a4 100644 --- a/package/thingino-ap/thingino-ap.mk +++ b/package/thingino-ap/thingino-ap.mk @@ -7,6 +7,9 @@ define THINGINO_AP_INSTALL_TARGET_CMDS $(INSTALL) -m 755 -d $(TARGET_DIR)/etc/init.d $(INSTALL) -m 755 -t $(TARGET_DIR)/etc/init.d/ $(THINGINO_AP_PKGDIR)/files/S42wifiap + + $(INSTALL) -m 755 -d $(TARGET_DIR)/usr/sbin + $(INSTALL) -m 755 -t $(TARGET_DIR)/usr/sbin/ $(THINGINO_AP_PKGDIR)/files/hosts-update endef $(eval $(generic-package)) From c66e442d9795da97419d6219601610ab2e5dc1d4 Mon Sep 17 00:00:00 2001 From: goatzillax Date: Tue, 19 Nov 2024 20:16:29 -0600 Subject: [PATCH 5/5] Update udhcpd-ap.conf to run hosts-update on accepted leases --- package/thingino-ap/files/udhcpd-ap.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/thingino-ap/files/udhcpd-ap.conf b/package/thingino-ap/files/udhcpd-ap.conf index 53db5d8c1..3ca24579d 100644 --- a/package/thingino-ap/files/udhcpd-ap.conf +++ b/package/thingino-ap/files/udhcpd-ap.conf @@ -10,7 +10,7 @@ offer_time 60 # 1 min min_lease 60 # 1 min lease_file /var/run/udhcpd_ap.leases pidfile /var/run/udhcpd_ap.pid -#notify_file dumpleases +notify_file /sbin/hosts-update opt dns 100.64.1.1 option subnet 255.255.255.0