functions: Do not automatically restart the wifi on RESET_BSSIDS

Instead of restarting the service we have the service started *after*
our modification to its configuration.
This makes it slightly more inconvenient to reset the WiFi BSSIDs while
the device is booted but that capability can be restored and made better
through an executable, say, /usr/bin/reset-wifi-bssids or something.

We also split the volatile client MACs into its own service to have
a bit of a clearer separation of duties. This will allow us to eventually
split the package more easily into sub-packages with finer-grained control.
This commit is contained in:
Tobias Mueller 2023-10-17 19:42:22 +02:00
parent 1c3c5f79e1
commit 8b4d371c9f
4 changed files with 49 additions and 10 deletions

View File

@ -2,15 +2,21 @@
. /lib/blue-merle/functions.sh
START=81
# We intend to be started before the first network-related service is started.
# According to https://openwrt.org/docs/techref/initscripts, /etc/rc.d/ determines
# the order of the services to be started (or stopped). The lower the number,
# the earlier the service is started.
# We observe "repeater" having the value 15. "network" 20. We certainly want to ahead of those.
START=14
STOP=99
start() {
start() {
/lib/blue-merle/mac-wipe.sh
RESET_BSSIDS
}
stop() {
RANDOMIZE_MACADDR
}
stop() {
/lib/blue-merle/mac-wipe.sh
}

View File

@ -0,0 +1,19 @@
#!/bin/sh /etc/rc.common
# MAC addresses of connected clients are stored in a sqlite database.
# Having the database seems to be necessary for the device to be working properly.
# We intent to have the device store the database in RAM rather than on flash.
# We replace the directory with a memory-backed tmpfs which is as volatile as we can make it.
# We want to run ahead of "gl-tertf" which, currently, has a prioprity of 20.
START=19
STOP=99
start() {
/lib/blue-merle/mac-wipe.sh
}
stop() {
shred /etc/oui-tertf/client.db || rm -f /etc/oui-tertf/client.db
}

View File

@ -14,7 +14,16 @@ RESET_BSSIDS () {
uci set wireless.@wifi-iface[1].macaddr=`UNICAST_MAC_GEN`
uci set wireless.@wifi-iface[0].macaddr=`UNICAST_MAC_GEN`
uci commit wireless
wifi # need to reset wifi for changes to apply
# you need to reset wifi for changes to apply, i.e. executing "wifi"
}
# This chaneges the MAC address clients see when connecting to the WiFi spawned by the device.
# You can check with "arp -a" that your endpoint, e.g. your laptop, sees a different MAC after a reboot of the Mudi.
RANDOMIZE_MACADDR () {
uci set network.@device[1].macaddr=`UNICAST_MAC_GEN`
uci commit network
# You need to restart the network, i.e. /etc/init.d/network restart
}
READ_IMEI () {

View File

@ -15,6 +15,11 @@ mount -t tmpfs / /etc/oui-tertf
cp -a "$tmpdir/client.db" /etc/oui-tertf/client.db
umount -t tmpfs -l "$tmpdir"
logger -p notice -t blue-merle-mac-wipe "Restarting tertf..."
/etc/init.d/gl-tertf start
logger -p notice -t blue-merle-mac-wipe "... Finished"
if [ $1 == "restart" ]; then
logger -p notice -t blue-merle-mac-wipe "Restarting tertf..."
/etc/init.d/gl-tertf start
logger -p notice -t blue-merle-mac-wipe "... Finished"
else
echo You will need to restart the gl-tertf service, i.e. /etc/init.d/gl-tertf restart
fi