I have Raspberry Pi that loads a shell script on start up.
This script runs a python script, boot_camera.py
, which is found in a repository.
I Have a server which sends the Raspberry Pi a command to issue a git pull
command. The git pull command fails when the boot_camera.py
is loaded on start-up.
However when I load the 'boot_camera.py' script manually after connecting with ssh the git pull
command is executed successfully.
At first I thought the problem was with having to use 'sudo' permissions to run the command, so I used this solution which fixed the problem:
>>>Solution to not using sudo<<<
But when the script is booted on start-up the pull
command still fails.
Update:
This is the script that sets up the boot script:
sudo cp bootCameraModule.sh /etc/init.d/
sudo update-rc.d bootCameraModule.sh defaults
And this is the script itself:
case "$1" in
start)
echo "Starting camera"
. /home/pi/.virtualenvs/env/bin/activate
# run application
cd /home/pi/rpi-repo/rpi/
python boot_camera.py &
;;
stop)
echo "Stopping camera"
# kill application
sudo killall camera
;;
*)
echo "Usage: /etc/init.d/bootCameraModule {start|stop}"
exit 1
;;
esac
exit 0
Best Answer
Without seeing the script itself, one strong possibility I'd suggest investigating is that the networking isn't fully level by the time your script executes. The reason it manually succeeds is that you've executed it after the networking is fully up.
I have a git repo my own pi camera application is dependent on for shoveling pictures & videos it captures to the cloud. My script just keep looping the
git clone
until it either succeeds or at least makes me aware its failed: