mac-wipe: avoid accumulating mounts

If we mount over and over again we may consume memory unnecessarily.
This commit is contained in:
Tobias Mueller 2023-10-16 15:15:29 +02:00
parent 4beae781a2
commit 4f584b4b6c

View File

@ -1,6 +1,6 @@
#!/usr/bin/env ash
# This script wipes all MAC address data from the device and is called upon boot
# 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
@ -8,6 +8,8 @@ mount -t tmpfs / "$tmpdir"
/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