How can I allow a snap application to execute a custom script
I have a Nextcloud server that was installed via snap (Github page). It has run quite well so far, but now I would like to start using Nextcloud's workflow feature to run a script when a new mkv file is created (Very simple script that executes ffmpeg and just converts the file from an mkv container to mp4).
However this is where my knowledge of snap ends. The snap has no access to the script I've created, and also doesn't have permissions to execute ffmpeg. Is there a way to give snap the access it needs to run ffmpeg and my script?
51 Answer
Based on everyone's comments. It sounds like in order to give snap permission to execute ffmpeg and my script, I would either need to A) redo my implementation as a "writable snap" per the nextcloud-snap documentation, or B) stop using snap altogether (I'm not tied to snap, but I'm also not interested in redoing my nextcloud installation at this time). So I can't use my script through nextcloud's workflow feature as-implemented. However, I did find a workaround for my scenario. My script just needs access to run ffmpeg on my stored nextcloud data, and the snap does allow me to designate an external data directory where my nextcloud data can be stored. So I did the following
I copied my data to an external directory, pointed snap to use that data directory per These instructions
Set up an incron job to execute my script when a new file is uploaded via nextcloud. My incrontab entry looks like this
/mnt/nextcloud/data/directory/ IN_ATTRIB ~/bin/my_script.sh $@$#As the final step in my script, I instruct nextcloud to scan for new files in my destination directory by running
/snap/bin/nextcloud.occ files:scan --path="username/videos/converted(note: path is relative to the nextcloud username)