Recommended ways of installing configuration files in SNAP_USER_DATA?
Ivan Lezhnjov IV
iliv at commandprompt.com
Mon Dec 12 19:27:03 UTC 2016
Hi,
I’m working on pgbouncer snap package and as I’m new to snaps I wanted to ask the community what is the current preferred way to install a program’s configuration files that are meant to be edited by users?
For example, pgbouncer has a couple of files: pgbouncer.ini and userlist.txt. Both normally located under /etc/pgbouncer.
As users need to be able to modify various settings in pgbouncer.ini it has to be under $SNAP_USER_DATA/etc/pgbouncer/.
I use a standalone wrapper script that initializes some filesystem paths, creates empty log files, etc. which is all required by pgbouncer and is never created by the program itself, where I essentially do this:
[ -e "$CNF_DIR/pgbouncer.ini" ] || cp $SNAP/etc/pgbouncer/pgbouncer.ini $CNF_DIR/pgbouncer.ini
As you can see I first dump pgbouncer.ini to $SNAP/etc/pgbouncer/ and then attempt to copy it to $CNF_DIR, which expands to $SNAP_USER_DATA/etc/pgbouncer.
However, this doesn’t work as $SNAP/etc/pgbouncer/pgbouncer.ini is owned by root and when the wrapper script is run as a normal user it cannot read the $SNAP/etc/pgbouncer/pgbouncer.ini file (permission denied).
I might be one step close to getting this to work but I was wondering what is the common/recommended practice to do what I’m trying to achieve here?
Ivan
More information about the Snapcraft
mailing list