I want to automate a bunch of smaller scripts and want to bundle them in a snap to deploy on a bunch of customer sites. Basically doing log cleanup, parsing…etc but only in the home directory of an Ubuntu install on site. Log folders can get pretty big so wrote it in python to scrape some info and remove all but today’s logs.
So I made a snapcraft.yaml file that looks like:
name: daily-report-gen base: core20 summary: Generate daily report templates description: | I have to write reports a lot. grade: devel confinement: strict adopt-info: daily-report-gen parts: daily-report-gen: plugin: python source: . parse-info: [setup.py] apps: daily-report-gen: command: bin/main.py plugs: [home] daemon: simple timer: 00:00
If I do a snap run daily-report-gen as user it works perfectly because it’s run as the current user. When it runs as a daemon I don’t have permission to edit the files. First thing I tried for this was just using chown in python to fix it guessing that the snap process itself would have permission to change the permissions but that didn’t work. I tried checking if there was a way to set a daemon to only run as a specific user account but I didn’t find anything that could help with that.
Any suggestions on how to either run that daemon as a user or ensure the permissions can be set correctly in the script level?