How to move config files during snap install

Jasko

I am trying to package my app to be able to install it using snap. App is already compiled as executable and has one config file and one certificate file which I package inside the snap.

Once installation is complete I can see everything in /snap/myapp/x1 but as x1 part will be changing after updates I'd like to take out resource files and put them to a more convenient location.

For testing purposes I tied resource files to be pulled from the same folder where my app is running and I found out that I needed to put them to /var/lib/snapd/void folder for app to work. This does not seem as a good location to start with.

As user will be able to change the config files I'd like to keep them at say $SNAP_COMMON so it would be great if I could somehow get these files to be moved over to that location during installation. Any thoughts?

kyrofa

For the purpose of this response I'm going to assume the application contained within your snap has command: my-binary.

You really have two options:

  1. Wrap your application in a script that ensures the config file has been migrated before running. For example, if you wrote a script called run-my-binary that looks like this:

    #!/bin/sh
    
    # Migrate config if necessary
    if [ ! -d $SNAP_COMMON/my.config ]; then
        cp $SNAP/conf/default.conf $SNAP_COMMON/my.config
    fi
    
    my-binary
    

    Change your snapcraft.yaml to install this script, and change your app to command: run-my-binary.

  2. Use the configure hook, which runs upon initial install (among other times). That can be a shell script that looks very similar to the wrapper.

Note that while I wanted to answer the question you asked, I don't really recommend putting config files in $SNAP_COMMON since it's specifically unversioned-- it won't be backed up when you upgrade/rollback. I recommend using $SNAP_DATA instead. For more information see this answer.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to find config files for snap apps?

From Dev

How to install Asterisk config files?

From Dev

How to move files and remove hyphens in file names during file move?

From Dev

How to move hidden config files to sub folder in the home directory

From Dev

How to install Chromium without snap?

From Dev

How to install Chromium without snap?

From Dev

How to specify install location of additional files during the creation of module

From Dev

How to work with html files in snap?

From Dev

How to install gimp-GAP for gimp snap

From Dev

How to configure port number for OwnCloud snap install?

From Dev

How to install Resynthesizer Plugin in GIMP snap?

From Dev

How do I install Firefox as a snap?

From Dev

How to install & run Gimp using snap

From Dev

how to launch the tor browser from a snap install?

From Dev

Linux: how to move a large file tree, deleting files during the copy (not after)

From Dev

How to list files installed by a snap package?

From Dev

how to move config xml files from WEB-INF to resources in java spring?

From Dev

Writing Application config files on APK install

From Dev

what should put in config files django install?

From Dev

How to install .tar.gz files which don't have .config file?

From Dev

How to get all changes you made to your config files (since system install) in one shot?

From Dev

How to install snap packages behind web proxy on Ubuntu 16.04

From Dev

How to remove snap from Ubuntu 18.04 (before and after install)?

From Dev

How to install a self-created snap on an Ubuntu Core machine?

From Dev

How do I install a plugin in Audacity installed via snap?

From Dev

How can i install Blender from the Snap LTS channel?

From Dev

how to move and remove files in WinJS

From Dev

How to move files to folders in github?

From Dev

How to move files in sftp server?

Related Related

  1. 1

    How to find config files for snap apps?

  2. 2

    How to install Asterisk config files?

  3. 3

    How to move files and remove hyphens in file names during file move?

  4. 4

    How to move hidden config files to sub folder in the home directory

  5. 5

    How to install Chromium without snap?

  6. 6

    How to install Chromium without snap?

  7. 7

    How to specify install location of additional files during the creation of module

  8. 8

    How to work with html files in snap?

  9. 9

    How to install gimp-GAP for gimp snap

  10. 10

    How to configure port number for OwnCloud snap install?

  11. 11

    How to install Resynthesizer Plugin in GIMP snap?

  12. 12

    How do I install Firefox as a snap?

  13. 13

    How to install & run Gimp using snap

  14. 14

    how to launch the tor browser from a snap install?

  15. 15

    Linux: how to move a large file tree, deleting files during the copy (not after)

  16. 16

    How to list files installed by a snap package?

  17. 17

    how to move config xml files from WEB-INF to resources in java spring?

  18. 18

    Writing Application config files on APK install

  19. 19

    what should put in config files django install?

  20. 20

    How to install .tar.gz files which don't have .config file?

  21. 21

    How to get all changes you made to your config files (since system install) in one shot?

  22. 22

    How to install snap packages behind web proxy on Ubuntu 16.04

  23. 23

    How to remove snap from Ubuntu 18.04 (before and after install)?

  24. 24

    How to install a self-created snap on an Ubuntu Core machine?

  25. 25

    How do I install a plugin in Audacity installed via snap?

  26. 26

    How can i install Blender from the Snap LTS channel?

  27. 27

    how to move and remove files in WinJS

  28. 28

    How to move files to folders in github?

  29. 29

    How to move files in sftp server?

HotTag

Archive