Control snap-2 services status with snap-1(stable)

Hi, I want to start/stop the snap-2 services from snap-1 in Ubuntu Core 22

In below mentioned grade and confinement

grade: devel 
confinement: devmode

I was able to perform below commands from snap-1 shell script.

snap stop --disable
snap start --enable

But when I change

grade: devel 
confinement: devmode

I am not able to control snap-2 services from snap-1. Need suggestions if I am making any mistake.

Thanks in advance!

You can not use the snap command from within confined snaps. You can also not control other snaps from a snap unless you use the snapd REST API through the snapd-control interface, which is usually not allowed for snaps in the global store (it is reserved for brand store use).

What you can do is to add a script to snap2 that uses the snapctl command to control its own services, provide access to that script through a socket and share the directory this socket lives in via a content interface to snap1… then snap1 can issue commands into the script through that socket.

Could all of your services and controller be part of a single snap? That would avoid the need for inter-snap communication. Your controller need only issue:

snapctl start --enable $

Which is allowed within a snap

1 Like