Where to place config files, and nested config files

Didier Roche didrocks at ubuntu.com
Wed Aug 10 06:06:48 UTC 2016


Le 09/08/2016 à 23:50, Andreas Hasenack a écrit :
> Hi,

Hey Andreas,
>
> I'm starting to use snapcraft and picked squid-deb-proxy as my first
> victim. This is just the normal squid service with a set of
> configuration files tailored for deb package caching.
>
> I'm assuming that the best place for the squid config files is
> SNAP_DATA, because it's versioned and any rollback will include the
> configuration files as they were in the previous installed revision.
> Is that correct?
Correct!

>
> My other question is about nested configuration files.
>
> This particular squid config file includes other config files via
> absolute paths. In the normal deb package, you will see things like this:
>
>     acl allowed_networks src
> "/etc/squid-deb-proxy/allowed-networks-src.acl"
>
> Now even if I point squid to the main/parent config file in SNAP_DATA,
> that absolute path above inside the config won't work because it's
> ouside SNAP_DATA. So what are my alternatives?
>
> a) hardcode the path above to use this prefix:
> /var/snap/squid-deb-proxy/current/. This is just like SNAP_DATA, but
> using "current" instead of the revision number, so it's stable. The
> acl line above would be like this, for example:
>
>     acl allowed_networks src
> "/var/snap/squid-deb-proxy/current/etc/squid-deb-proxy/allowed-networks-src.acl"
>
> Can I use "current" like this, or is that abuse or bad form?
>
>
> b) use a simple template system and dynamically generate the config
> file with SNAP_DATA as the prefix before starting the service. I would
> have something like this in the template file:
>     
>     acl allowed_networks src
> "@PREFIX@/etc/squid-deb-proxy/allowed-networks-src.acl"
>
> And generate the actual config file replacing @PREFIX@ with the
> contents of SNAP_DATA before starting the service. Is this overkill,
> or the most elegant solution?
>
>
> c) something else I'm missing? I'm very much starting my journey here :)

b) is the most elegant solution IMHO, it will always point to the right
directory, at runtime. That makes as well upstream config relocatable,
which is a net benefit for everyone :)

Cheers,
Didier




More information about the Snapcraft mailing list