See the configs and scripts in our repository.
Basically we have a udev rule LibreELEC.tv/95-udevil-mount.rules at master · LibreELEC/LibreELEC.tv · GitHub that determines which devices should be auto-mounted and then starts the udevil-mount@ systemd service LibreELEC.tv/[email protected] at master · LibreELEC/LibreELEC.tv · GitHub
This service calls the samba-autoshare wrapper script LibreELEC.tv/samba-autoshare at master · LibreELEC/LibreELEC.tv · GitHub which in turn calls the samba-config script LibreELEC.tv/smbd-config at master · LibreELEC/LibreELEC.tv · GitHub to (re-)generate the samba config file and then sends a HUP signal to smbd so samba re-reads the config file.
The share name is identical to the mount-directory in /media which is handled by udevil (using the filesystem label, if present).
so long,
Hias