mirror of
https://github.com/srlabs/blue-merle.git
synced 2024-12-23 06:09:27 -05:00
d4886a54a9
This makes it hopefully a bit easier to see what we're doing because you don't need to chase the files down. We don't re-use that functionality anywhere. Neither would we. A more important change is not restarting the gl-tertf service. First of all, there seems to be no process attached to gl-tertf. It is the "Bandwidth Monitor" and part of the kmod-gl-sdk4-tertf package, so it's kernel module. It does not appear to be holding the clients.db. There is, however, gl_clients which also makes sense, naming wise. That service defines that /usr/bin/gl_clients_update ought to be run. And stracing it shows that it does indeed touch the database: open("/etc/oui-tertf/client.db", O_RDWR|O_CREAT|O_LARGEFILE|O_NOFOLLOW|O_CLOEXEC, 0644) = 7 It also appears to be re-creating the file when it's missing. Anyway, we have the service stopped during installation so that we can safely delete the file without the process complaining. We also install our volatile mac service s.t. it runs ahead of the gl-client service so that the clientdb gets saved in volatile memory.
31 lines
1.1 KiB
Bash
31 lines
1.1 KiB
Bash
#!/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 60.
|
|
# We also want to run ahead of "gl_clients" which has 99.
|
|
START=59
|
|
STOP=99
|
|
|
|
start() {
|
|
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() {
|
|
shred /etc/oui-tertf/client.db || rm -f /etc/oui-tertf/client.db
|
|
}
|
|
|