There are a number of interfaces that wont auto connect such as removable media, serial port, snapd, etc does this apply to snaps running as daemon’s. I would also like them to be able to run scripts when a user plugs in removable media, as is currently possible through udev rules.
Is it possible to configure this? ie:
Autodetection of removable media
Running scripts if removable media meets certain requirements.
Autoconnection of specific interfaces
Another question is if they have been connected manually, does this persist between reboots?
To get interfaces, that are not default connected when declared, to auto-connect you need to petition the store section of the forum with your use-case and rationale for the admins to vote on whether to allow auto-connection.
But for development purposes, using devmode I should be able to connect to them? Are there any config in the gadget snap to get them to run some script on connection like traditional udev rules?
if you use --devmode you dont need to connect anything (well, it quietens the logs if you do (you get less “APPROVED” messages)), devmode installed snaps run completely unconfined.
okay, must be another issue, why I can’t see the devices on /media. Do you have any guidance on how the removable media can trigger a daemon service to start. in classic ubuntu the following works:
I misread this as a request for ‘removable-media’ to be auto-connected, but for others, @peter.milani’s question is about making ntfs-formatted USB drives automount in /media. AFAICT, there are missing packages in core for this to work.
Yes, @jdstrand I had expected the removable media plug to auto mount when removable media was inserted.
I am also trying to get scripts to run after said media was inserted (ie for copying files etc.). On a classic system that is done via a udev rule for systemd to call a service that copies files etc. That service also mounted the usb too.
So effectively systemd and udev work pretty much the same between the classic and ubuntu core. If you want to start a script when removable media is plugged in:
Setup script to run as a daemon… Snap the script to run as a daemon using the command reference, likely you’ll want it to be one-shot or forking. Upon install this will create a service definition in /etc/systemd/system/snap.my_snap_name.usb-mount.service assuming your daemon command is called usb-mount.
Insert new rule /etc/udev/rules.d to specify that systemd wants your service.