I have enabled fstab.auto_mount
and I need to execute a script on mounting to share a folder from a flash drive.
Is it possible with ubus or hotplug?
UPD from source https://git.openwrt.org/?p=project/fstools.git I see that it sends notifications with block
but I didn't get how to catch them properly. But I see something on monitor:
# ubus -v monitor | grep mount
-> bf738430 #00000000 data: {"objpath":"block","objid":-33237553,"objtype":-2109400214,"signature":{"hotplug":{"uuid":3,"label":3,"enabled":5,"target":3,"device":3,"options":3,"autofs":5,"anon":5,"remove":5},"mount":{"uuid":3,"label":3,"enabled":5,"target":3,"device":3,"options":3,"autofs":5,"anon":5,"remove":5},"umount":{"uuid":3,"label":3,"enabled":5,"target":3,"device":3,"options":3,"autofs":5,"anon":5,"remove":5},"info":{"device":3}}}
<- bf738430 #fe04d5cf invoke: {"objid":-33237553,"method":"mount","data":{"device":"sda1","remove":1}}
-> 3536528e #bf738430 invoke: {"objid":-33237553,"method":"mount","data":{"device":"sda1","remove":1},"user":"root","group":"root"}
Basically now I think that I can try to live without the hook.
I also want to make a generic solution for self-hosting e.g. for non experienced users like my old parents.
My initial idea was to automount anonymous drives e.g. just injected USB stick, then check if it contains a special folder /AutoShare
and make it's content available for local network via WebDAV, SMB, SFTP or minidlna. So that a user can easily see it's photos or media from a TV. All what is needed is just to create a special folder on a flash drive.
But now I found that the automount can be done by a specific label e.g. in the /etc/config/fstab
:
config mount
option target '/mnt/autoshare'
option label 'AutoShare'
option enabled '1'
Now I can I'll just configure symlinks or mount bind to the mount folder.
Here still remains some problems:
- Setting a label to a flash drive is still something complicated for my parents. At least I need to explain this on a phone where in Windows make a right click on drive etc.
- Label matching is case sensitive and it's easy to make a typo when explaining on a phone. This is minor thing but maybe we can make the label matching case insensitive?
- What if two autosharing drives are inserted? Then they'll try to mount in the same folder. Maybe a label can be just a prefix e.g. if inserted
AutoShare_site
,AoutoShare_photos
and justAutoShare
they'll be mounted into/mnt/autoshare/site
,/mnt/autoshare/photos
and/mnt/autoshare/627A-B1F0
e.g. by UUID.
The similar principle of automounting can be used for extroot, external storage for opkg, spool, mailbox or even to share a website.
E.g. a user may create /AutoShare/www/example.com
and the folder become a website accessible from web for the example.com domain. This may be a good and simple way for a small business owner like a farmer to make a site with their goods and services.
Ideally the autoshare mounting should be added into OpenWrt by default.
Please share your thought or ideas about the idea.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.