Linux Format forumsHelp, discussion, magazine feedback and more2014-07-08T10:04:23+00:00http://www.linuxformat.com/forums/feed.php?t=162112014-07-08T10:04:23+00:002014-07-08T10:04:23+00:00http://www.linuxformat.com/forums/viewtopic.php?t=16211&p=114980#p114980The command “gphoto2 –set-config-value” does not change the settings in the camera, but writes them to file .gphoto2/settings in the home directory. When run under systemd, this HOME environment variable was not set (even when using the /root/.bash_profile). I could probably have set this in the profile, but opted to replace the "source /root/.bash_profile" line with "export HOME=/home/pi".

]]>2013-12-14T12:16:56+00:002013-12-14T12:16:56+00:00http://www.linuxformat.com/forums/viewtopic.php?t=16211&p=113306#p113306I have been trying to get my head around sessions and profiles and, after reading through various webpages, including the Arch wiki pages, have tried the following:

1. copying the .bash_profile file from /etc/skel to /root and sourcing it;2. sourcing the .bash_profile in /home/pi;3. sourcing /etc/profile

All have the same result - the script executes and triggers the camera to take the required number of shots, but fails to set the config value to save the images on the SD card

]]>2013-11-25T22:42:38+00:002013-11-25T22:42:38+00:00http://www.linuxformat.com/forums/viewtopic.php?t=16211&p=113136#p113136Statistics: Posted by nelz — Mon Nov 25, 2013 10:42 pm
]]>2013-11-25T21:00:09+00:002013-11-25T21:00:09+00:00http://www.linuxformat.com/forums/viewtopic.php?t=16211&p=113131#p113131“This is not an issue with systemd but with the environment in which the script is being run.There is a difference between running a script or program from a daemon such as systemd and from a shell. When you open a shell session, a specific environment is set up - that environment is not present when running from a daemon, even though it is running as the same user. The issue here is not that you are running the script from systemd, but that you are not running it from a shell session.”

The recommendation is to run the Python script within the correct environment by using a wrapper script:#!/bin/bashsource /root/.bash_profile/home/pi/timelapse.py

I’ve now resorted to trying to fix this on my laptop before committing it to the Pi. I have Arch on a laptop and on a PC, and /root/.bash_profile did not exist on either. I have tried calling /home/user/.bash_profile within the wrapper, calling /etc/skel/.bash_profile, and creating /root/.bash_profile by copying from both /home/user, and from /etc/skel. In all cases, running the wrapper script in a terminal session causes the script to run correctly and store images on the SD card. If it is run through systemd, the script runs OK but fails to save the images to the SD card.

So I’m currently trawling through anything I can find on bash environment settings. And that’s where I am with this now.

]]>2013-08-24T08:43:52+00:002013-08-24T08:43:52+00:00http://www.linuxformat.com/forums/viewtopic.php?t=16211&p=112246#p112246The script uses the command “gphoto2 –set-config-value” to instruct the camera to save the images on the SD card in the camera. If I run the script under Python (which has to be done with sudo to run the Adafruit modules), it runs correctly and saves the images on the camera. If I run it through systemd with a service script linking to the exact same file, either at boot or starting it with “sudo systemcontrol start gphoto.service”, it executes the command to set the config value, but then appears to ignore it. The script executes without error but the images are not saved. I have added logging to the script which shows the command being executed as below.

I’ve run a stripped down version on a laptop running Arch, and the same issue occurs. I have also run it under openSUSE on a laptop also using systemd and the same thing happened, so I suspect this is an issue with systemd (or my use of it) rather than the Pi. I would add that I have run the same script under Raspbian (using init script) and this worked correctly both run as a Python script, and at boot as an init script (with the addition of a usbreset code to prevent it from hanging between shots; this code has also been added to the Arch version and the scripts on the two different OS are identical). Below is my service file. Does my problem lie with the (rather basic) service file, or is it elsewhere?