I use various travel routers: Beryl AX and Slate AX, the latest model. Both run on FW 4.8.
The routers are used for private and business travel. In "private" mode, I use them as media servers and mini NAS devices with TF cards or USB ports. USB devices are automatically mounted under /tmp/...
What I want to achieve is to plug in my "business" USB stick and have it mounted separately with different Samba credentials based on its UUID. All other sticks can be mounted normally.
So you'd want Samba to reload itself based on a specific configuration file based on the USB drive's UUID when the underlying OpenWrt OS detects & automatically mounts it. Yeah, it could be done with the right daemon to monitor for the change. I'd probably use inotifywait &/or inotifywatch as the core functionality for this case. How's your scripting skills?
Package: inotifywatch
Version: 3.20.11.0-1
Depends: libc, libinotifytools
License: GPLv2
Section: utils
Architecture: mipsel_24kc
Installed-Size: 7391
Filename: inotifywatch_3.20.11.0-1_mipsel_24kc.ipk
Size: 8396
SHA256sum: e052ed2e64901d75f2c15679a0b48a7a86e2d7913ae31ec041b2fb3a84a32a31
Description: inotify-tools is a C library and a set of command-line programs for
Linux providing a simple interface to inotify. These programs can be
used to monitor and act upon filesystem events. A more detailed
description of the programs is further down the page. The programs are
written in C and have no dependencies other than a Linux kernel
supporting inotify.
This package provides the inotifywatch tool.
I don't use Samba & I've never used that daemon so I don't have any advice there. I did see was seems to be a succinct tutorial with partial emphasis on scripting.
Here's a scaffolding script so you can get the required details out from uci.
#!/bin/sh
# shellcheck shell=sh
# set the stor device uuid here; determine via
# uci show fstab | grep 'uuid'
UUID='c2616dc5-0186-4911-b92a-9822b79a5333'
mount_id="$(uci show fstab | grep -m '1' "${UUID}" | cut -d '[' -f '2' | cut -d ']' -f '1')"
target="$(uci show fstab.@mount["${mount_id}"].target)"
mountpoint="$(printf "%s" "${target}" | cut -d "'" -f '2')"
blockdevice="$(printf "%s" "${mountpoint}" | cut -d "'" -f '2' | cut -d '/' -f '3')"
enabled="$(uci show fstab.@mount["${mount_id}"].enabled | cut -d "'" -f '2')"
# uncomment to check the output of the variables
# printf "%s\n"\
# "EXPECTED UUID: ${UUID}" \
# "id : ${mount_id}" \
# "target : ${target}" \
# "mountpoint : ${mountpoint}" \
# "blockdevice : /dev/${blockdevice}" \
# "enabled : ${enabled}"
# only execute if the stor device is enabled, present as a block device & is mounted
if [ "${enabled}" = '1' ] && [ -b "/dev/${blockdevice}" ] && [ -d "${mountpoint}" ]; then
# do something here like
echo 'yup'
fi
exit 0