Got a quick question, is it possible to restart another service in the snap’s configure hook script? I am trying to allow some settings from command line snap set SNAP_NAME settings=something. When the snap service started, the configure hook was loaded and the error message returned as systemctl: Permission denied.
you can restart any service the snap ships inside with snapctl restart $SNAP_NAME.<service name> … you can not restart any services outside of the snap (unless there is an interface that explicitly allows this but even then it is usually through a dbus call and not by giving access to the hosts systemctl command (for obvious security reasons))
i dont think you can set system options from a snap hook but if you would it would again be snapctl set ... not snap set ... the snap binary is not accessible from inside a snap package, snapctl provides a (limited) route to the features the snap command offers …
system options need to either be set manually (or from a script or tool) outside of confinement or via an entry in a gadget.yaml in case you are on Ubuntu Core
Thanks for the hint, and I believe it should work with snapctl set system.journal.persistent=true (I have not tried in an image yet ) Is journalctl command allowed to run in configure hook? I used snap run --shell snap_name.application, then the command journalctl returned Permission Denied.