Using the script inside the snap


Tell me, please, during the installation of the snap package, run the script that is inside the package itself, and this script should create a directory in /var/log/ and copy there file what I need?
As I understand it it is necessary to adjust in a file snapcraft.yaml?


I correctly understand that if no one answered then such a functional can not be realized?))


If your snap has an install hook, it will run on installation.

You cannot create arbitrary directories in /var/log, no. If your application is a service, configure it to use something in $SNAP_DATA (if the data is versioned) or $SNAP_COMMON (otherwise); if it’s a command, use $SNAP_USER_DATA or $SNAP_USER_COMMON as appropriate.


At the moment the snap package does not have anything from
Probably just this information I was looking for.
I want to explain why I’m trying to implement it, at the moment the application has a deb format. When you install the package, script with the name “postinstal” starts , it looks like this:

set -e


    if ! getent group $GROUP >/dev/null; then
        groupadd --system $GROUP

case "$1" in

        mkdir -p /var/log/veeam/
        mkdir -p -m 2775 /var/log/veeam/config

As you can see, script creates the necessary directories with the given access paths for the group.
Then you need to create a group in the system and add the user to it.
And as you can see, this is the log files, and that’s why they need to be created in the system.
And the most important thing that I’m still trying to do, is to copy the important(for app) file and put it in the system path /etc/veeam/veeam.ini

Thank you in advance, and I hope to hear advice on how to implement it correctly.


Using your advice, I tried to build a snap package, but I get this error:

hook '.install.swp' is not executable
Stopping local:snapcraft-nicely-casual-shrew
ls -l snap/hooks/
-rwxr-xr-x 1 blin lxd 772 сен 16 16:06 configure
-rwxr-xr-x 1 blin lxd 799 сен 16 16:40 install
-rwxr-xr-x 1 blin lxd 703 сен 16 16:13 remove

Is this a bug, or am I making a mistake?


Close any editors that have the install script open, such as vim. The .install.swp will disappear once you close active editors. If it doesn’t, and you’re sure all editors are closed then delete the file.


I’d just like to note that if you are not a member of the Veeam organisation, with authority to submit the snap to the store, the license prohibits redistribution of the software.

Now that’s out of the way, a strictly confined snap will not be permitted to write or create files and folders at /var/log or /etc. Nor will it be allowed, currently, to create users or groups within the host system. (There is work under way to allow limited user and group creation in the future.) As a backup solution it is probably advisable that you pursue classic confinement for the snap to allow access to the whole system. This will require requesting the store team to consider the requirements and vote on whether to allow or deny the use of classic confinement.


I work for this company. And I am in a group that exactly and writes this client for Linux systems.
And for this personally, I took up an attempt to launch our application as a snap.


ok, awesome :slight_smile: I just wanted to be sure that a community member wasn’t getting themselves into legal soup.


I recommend that classic confinement is where you should be putting your efforts, rather than trying to work within the strict confinement limits. As I said above as a backup solution, your need for users and groups, and other system-level access your snap is a prime candidate for requiring classic confinement. The documentation about the process is here:


I used your advice.
Now I was marked with a couple of problems:
1: when the servise is launched, it searches for its work the file that should be on the way /etc/veeam/veeam.ini, several variables that are in this file.
They need for create a database.
But, these scripts are not in the system,
they in snap
Service is looking for file here
If the service does not find the file, it will also look for the scripts by default in the system itself.

I hope I was able to explain the principle of the service and you could explain how to use it correctly.
I tried the script in hooks: install I tried to copy the file from snap to the system in this way
cp ${SNAP}/etc/veeam/veeam.ini /etc/veeam/veeam.ini
it did not work.


Now this is the error when starting the service

сен 16 18:40:25 blin-System-Product-Name veeamservice[20352]: Service has failed. File /usr/share/veeam/lpb_upgrade_scheme.sql was not found.
--tr:Failed to load SQL upgrade script '/usr/share/veeam/lpb_upgrade_scheme.sql'.
--tr:Unable upgrade db: /var/lib/veeam/veeam_db.sqlite.


I was able to solve the problem of copying files needed for the service.
At the moment, status:
systemctl status snap.veeam.veeamservice.service
● snap.veeam.veeamservice.service - Service for snap application veeam.veeamservice
Loaded: loaded (/etc/systemd/system/snap.veeam.veeamservice.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2018-09-17 20:59:56 CEST; 36min ago
Process: 3128 ExecStart=/usr/bin/snap run veeam.veeamservice (code=exited, status=0/SUCCESS)
Main PID: 3128 (code=exited, status=0/SUCCESS)

сен 17 20:59:55 blin-System-Product-Name systemd[1]: Started Service for snap application veeam.veeamservice.
сен 17 20:59:56 blin-System-Product-Name veeamservice[3216]: Service started.
сен 17 20:59:56 blin-System-Product-Name veeamservice[3216]: Initializing log file [/var/log/veeam/veeamsvc.log].
сен 17 20:59:56 blin-System-Product-Name veeamservice[3216]: Service is stopped.

When I try to restart the service, nothing changes
сен 17 21:36:47 blin-System-Product-Name sudo[4368]: blin : TTY=pts/1 ; PWD=/home/blin ; USER=root ; COMMAND=/usr/bin/snap restart veeam
сен 17 21:36:47 blin-System-Product-Name sudo[4368]: pam_unix(sudo:session): session opened for user root by (uid=0)
сен 17 21:36:47 blin-System-Product-Name systemd[1]: Started Service for snap application veeam.veeamservice.
сен 17 21:36:47 blin-System-Product-Name sudo[4368]: pam_unix(sudo:session): session closed for user root
and nothing.
How else can I understand that there is not enough service for a normal launch?


It might be that Veeam agent forks itself into the background? If that is the case, your snapcraft.yaml needs to specify the forking type on daemon:

        # ... the rest of your config
        daemon: forking


It worked)
Immediately then a very important question.
When the service is running, then veeamconfig has certain parameters.
For example:
veeamconfig job start (further, if a job was created for backup, for example with the name of the BackUpJob1, then after double press button tab, a variant of this name’s choice appeared.)
That is, the parameters become available in the dependencies of what was selected before that.
Now snap does not give me such a choice.
How should this work? Or snap package does not give access to available application parameters at all?