diff --git a/Makefile b/Makefile index 122655d..cae664b 100644 --- a/Makefile +++ b/Makefile @@ -81,12 +81,21 @@ define Package/blue-merle/preinst else ABORT_GLVERSION fi + + # Our volatile-mac service gets started during the installation + # but it modifies the client database held by the gl_clients process. + # So we stop that process now, have the database put onto volatile storage + # and start the service after installation + /etc/init.d/gl_clients stop endef define Package/blue-merle/postinst #!/bin/sh uci set switch-button.@main[0].func='sim' uci commit switch-button + + /etc/init.d/gl_clients start + echo {\"msg\": \"Successfully installed Blue Merle\"} > /dev/ttyS0 endef diff --git a/files/etc/init.d/blue-merle b/files/etc/init.d/blue-merle index e0a3653..ecbdc4f 100755 --- a/files/etc/init.d/blue-merle +++ b/files/etc/init.d/blue-merle @@ -11,12 +11,6 @@ START=14 STOP=99 start() { - /lib/blue-merle/mac-wipe.sh RESET_BSSIDS RANDOMIZE_MACADDR } - -stop() { - /lib/blue-merle/mac-wipe.sh -} - diff --git a/files/etc/init.d/volatile-client-macs b/files/etc/init.d/volatile-client-macs index 8624a2e..7b12913 100644 --- a/files/etc/init.d/volatile-client-macs +++ b/files/etc/init.d/volatile-client-macs @@ -11,7 +11,17 @@ START=59 STOP=99 start() { - /lib/blue-merle/mac-wipe.sh + tmpdir="$(mktemp -d)" + # We mount a tmpfs so that the client database will be stored in memory only + mount -t tmpfs / "$tmpdir" + cp -a /etc/oui-tertf/client.db "$tmpdir" + shred /etc/oui-tertf/client.db || rm -f /etc/oui-tertf/client.db + # If this script runs multiple times, we accumulate mounts; we try to avoid having mounts over mounts, so we unmount any existing tmpfs + umount -t tmpfs -l /etc/oui-tertf + + mount -t tmpfs / /etc/oui-tertf + cp -a "$tmpdir/client.db" /etc/oui-tertf/client.db + umount -t tmpfs -l "$tmpdir" } stop() { diff --git a/files/lib/blue-merle/mac-wipe.sh b/files/lib/blue-merle/mac-wipe.sh deleted file mode 100644 index a8d5157..0000000 --- a/files/lib/blue-merle/mac-wipe.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env ash - -# This script ensures that MAC addresses are stored on volatile memory rather than flash - -tmpdir="$(mktemp -d)" -# We mount a tmpfs so that the client database will be stored in memory only -mount -t tmpfs / "$tmpdir" -## Somehow, we cannot "stop" this service as it does not define such action. There is also no such process. Weird. -# /etc/init.d/gl-tertf stop -cp -a /etc/oui-tertf/client.db "$tmpdir" -shred /etc/oui-tertf/client.db || rm -f /etc/oui-tertf/client.db -# If this script runs multiple times, we accumulate mounts; we try to avoid having mounts over mounts, so we unmount any existing tmpfs -umount -t tmpfs -l /etc/oui-tertf - -mount -t tmpfs / /etc/oui-tertf -cp -a "$tmpdir/client.db" /etc/oui-tertf/client.db -umount -t tmpfs -l "$tmpdir" - - -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