Snap autostart in Ubuntu Core

Hi all,

I am trying to create a snap that is able to automatically run after login in Ubuntu Core 18.
I think that I cannot use the autostart option, since UC should not support desktop applications.
Looking around, I saw suggestions about defining the app as a daemon. So, I defined the snapcraft.yaml file as follows (by taking the cue from the example https://snapcraft.io/docs/defining-a-command):

name: os-release
base: core18
version: '0.1'
summary: Outputs the contents of /etc/os-release
description: Prints the contents of os-release
grade: devel
confinement: devmode

apps:
  os-release:
    command: bin/os-release.sh
    daemon: simple
    restart-condition: on-abnormal

parts:
  os-release:
    plugin: dump
    source: .
    organize:
      os-release.sh: bin/

Although, it seems to me that the snap is not automatically run. I can get its output just by using cd /snap/os-release/1/bin/ and ./os-release.sh
Do you have any suggestions about how to make it work?

Thank you in advance!

first of all take a look at “DENIED” messages in your journal to see if you are missing interfaces, also check if you see it failing in the journal if you call snap restart os-release, the errors should be logged there …

… also note that /etc/os-release comes from the base snap your app is using (in your case core18) … it will not actually show the one from the host … that sits in /var/lib/snapd/hostfs/etc/os-release and is accessible through the system-observe interface …

1 Like

Thank you! By using sudo journalctl -r I was able to see that the snap had been correctly executed. I thought it would have displayed its output on terminal, but it seems not.
About the snap name, actually I gave it a different one, and the same for what regards the .sh file, so there should not be ambiguities in the execution.