I want to make a modification of a configuration file in the / etc / directory during installation using the install file in hooks, but to modify a file located in / etc / it is necessary to add a “system-files” interface, so my question It is how I could add to the install scipt a check to check if the connection is already made and if you can modify the file in case you do not ignore that step. Since I have tried without that check and at the time the scrip install is executed it fails because you do not have the permissions to write in / etc /
You can use
snapctl to check if an interface is-connected from inside a hook script.
system-files to modify /etc/ is probably not supported since allowing a snap to write system-wide configuration files is not consistent with confinement.
Some snapd interfaces allow writing to some areas in /etc/ So you might check them.
If the conf file is for software running in your snap, you could use
Layouts. This way your snap can ship the conf file and your snap code will read it, and you never need to modify /etc/foo.