Executing a script inside snap package. Is this possible?

Roberto Mier Escandón  roberto.escandon at canonical.com
Mon Apr 17 08:17:46 UTC 2017


Hey Eloy,

Maybe you have already tried this, but just in case, you can debug the
snap in confined mode [1], to see if there are some apparmor or seccomp
denials. That would give you some clues about what is causing snap not
to work and suggested solution.

sudo snap install snappy-debug
sudo snappy-debug.security scanlog <yoursnap>

Take a look also at /var/log/syslog

Cheers.

[1] https://snapcraft.io/docs/build-snaps/debugging

On 16/04/17 23:13, Eloy García (PC Actual) wrote:
> Hello everybody.
> 
> I develop a graphical java-based application which is published in the
> Ubuntu Store as a snap package (sctrict confinment) called
> wallpaperdownloader to download, manage and set desktop wallpapers.
> 
> I'm developing version 2.7 which will bring KDE support, but for this I
> need to execute a shell script from Java. In classic confinement and
> natively, this script is executed without problems. I use this code to do
> it:
> 
> process = Runtime.getRuntime().exec("/bin/sh " + WDUtilities.getAppPath() +
> WDUtilities.URL_SLASH + WDUtilities.PLASMA_SCRIPT + " " +  wallpaperPath);
> 
> As you can see, I use /bin/sh command to run the script. This is the
> content of the script:
> 
> #!/bin/bash
> 
> # Changing wallpaper
> qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript
> "var allDesktops = desktops();print (allDesktops);for
> (i=0;i<allDesktops.length;i++) {d =
> allDesktops[i];d.wallpaperPlugin = 'org.kde.image';d.currentConfigGroup =
> Array('Wallpaper', 'org.kde.image', 'General');d.writeConfig('Image',
> 'file://"$1"')}"
> 
> This command changes the current wallpaper for version 5.8 or higher in
> Plasma.
> 
> When this part is executed within the snap package (strict confinement),
> nothing happens. I have tried to include bash and dash pacakges as
> stage-packages but it doesn work. Is this something that can be achieved
> using the snap package system?
> 
> Thank you very much!
> 
> Best,
> 
> Eloy
> 

-- 
--
. Roberto Mier Escandón.
. Software Engineer
.
. Canonical - Solutions Engineering
--




More information about the Snapcraft mailing list