For my snap , I need to connect interfaces manually and daemon must be started automatically once interface is configured. Interfaces are -
system-observe,hardware-observe and network-control.
Method 1 : Configure-hook
As per documentation, configure-hook is triggered when -
initial installation
snapctl set/get/unset
refresh
Is there a way to trigger configure-hook when "snapctl refresh/start/stop $SNAP_NAME. " or "snapctl start --enable $SNAP_NAME. " is run ?
Method2 : Is there a way to automate the connection of manual-non auto connect interfaces ?
Right, the configure hook is only executed on configure events coming from snapd or at package install time after the install hook …
I’d move the content of the configure hook into a separate script that you then can execute from the various hooks you want to call it from … (i.e. when the last interface is connected, call it from the interface hook)
To make sure that you only call it when the last interface hook is run, you will need some interaction between the interface hooks … here is an example where i am cross-checking between the hooks and make sure to only start my daemon once all hooks are connected:
If your snap is designed to run pre-installed on an UbuntuCore device you can set auto-connections on first boot via your gadget snap of the system or manage auto-connecttions on a per-snap basis via your brand store…
If you provide your snap via the global store to a wider user base you can file an auto-connection request here in the store-requests category… interfaces that are essential for the app to run might be considered for auto-connect if they are not actually super-privileged
Yes, snap is designed to run pre-installed on Ubuntu core and its private snap . And yes, the interfaces are not super-privileged.
I figured out that for gadget snap , snap id is needed which is not available as it is not part of global store/brand-store.
Is there a way to mention snap name instead of snap-id in gadget snap ?
The snap id is assigned to every snap by the store (no matter if it is a brand store or the global one) at its initial upload (and is permanent… i.e it never changes) … i dont think there is a way to use the name