Octolapse script won't run

Hi,

I've built a simple working python script to trigger my DLSR camera using GPIO pins to send a signal to an IR trigger. If I run the script manually, it works but octolapse seems to not have permission to run the script.

My python script is as follows:

#!/usr/bin/env python

import RPi.GPIO as GPIO
import time

GPIO.setwarnings(False)

GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT)

GPIO.output(24, True)
time.sleep(01)
GPIO.output(24, False)

print "Done..."

I found a couple of old posts about GPIO usage in this kind of way and they indicated that I should put the python script inside a .sh script and add my password(removed) at the start. So I did, like this:

#!/bin/sh
echo "password" | sudo -S python /home/pi/scripts/external-camera-trigger.py

Made both of these scripts executable with chmod and they work on their own:

sudo chmod +X external-camera-trigger.py
sudo chmod +X external-camera-trigger.sh

How to give octolapse the permission to run this? Logs attached.

plugin_octolapse (1).log (4.2 KB)

You haven't told about your system, but I assume it is octopi.

You can omit writing your password thru customizing the sudo configuration.

Uncomment the line in /etc/sudoers.d/010_pi-nopasswd and the user pi can issue sudo with any command without password. If you don't want this, you can make a special definition for the camera script.

Make a new file e.g. /etc/sudoers.d/099_camera-no-password with the content
pi ALL=NOPASSWD: /home/pi/scripts/external-camera-trigger.py

As /home/pi/scripts/external-camera-trigger.py is writable by the user pi this adds no real security. The script executed as root should be owned by root and in a directory owned by root e.g. /usr/local/bin.

However, chmod +X doesn't do what you probably think

root@octopi:/tmp# touch example
root@octopi:/tmp# ls -l example
-rw-r--r-- 1 root root 0 Jun 12 12:40 example
root@octopi:/tmp# chmod +X example
root@octopi:/tmp# ls -l example
-rw-r--r-- 1 root root 0 Jun 12 12:40 example
root@octopi:/tmp# chmod +x example
root@octopi:/tmp# ls -l example
-rwxr-xr-x 1 root root 0 Jun 12 12:40 example

chmod +x (lower case x) is what you want.

A way to make sudo completely unnecessary is an udev rule to change the owner of the gpio devices to pi.

# /etc/udev/rules.d/80-gpio-noroot.rules
# Zugriff auf GPIO ohne root-Rechte ermoeglichen
#
# Gruppe aendern
SUBSYSTEM=="gpio", RUN+="/bin/chown -R root.gpio /sys/class/gpio"
SUBSYSTEM=="gpio", RUN+="/bin/chown -R root.gpio /sys/devices/virtual/gpio"
# Sticky-Bit setzen
SUBSYSTEM=="gpio", RUN+="/bin/chmod g+s /sys/class/gpio"
SUBSYSTEM=="gpio", RUN+="/bin/chmod g+s /sys/devices/virtual/gpio"
# Zugriffsrechte setzen
SUBSYSTEM=="gpio", RUN+="/bin/chmod -R ug+rw /sys/class/gpio"
SUBSYSTEM=="gpio", RUN+="/bin/chmod -R ug+rw /sys/devices/virtual/gpio"

(from RasPi_GPIO_Shell)