I have a python script that I would like to be run at startup. I have made a init.d script as follows:
#! /bin/sh case "$1" in start) echo "starting pitracker" su 'pi' -c 'python3 /home/pi/python/main/myprogram.py&' ;; stop) echo "stopping" ;; esac exit 0
I have changed the permission of this startup script to 755. I have also created a symbolic link using
update-rc.d /etc/init.d/dnscheck defaults
The problem is when I use the 'pi' user in my startup script, I get the following error message:
File "/home/pi/python/main/myprogram.py" , line 21, in <module> import RPi.GPIO as GOPI RunTimeError: No access to /dev/mem. Try running as root!
And when I change the username in my startup script to 'root', nothing happens at all. I believe this is a permission problem for accessing the GPIO. How can I start up my script without running into this issue?