How do you automatically run Pi commands at startup?


#1

I am using a bed-mounted Logitech c920 and can log into my OctoPi via Putty and use the following commands to get the webcam into sharp focus:

sudo v4l2-ctl --set-ctrl=focus_auto=0
sudo v4l2-ctl --set-ctrl=focus_absolute=20

The problem is that when I reboot the OctoPi the settings are lost. My question is how do I get the Pi to run these commands automatically when booting? I've tried using Crontab but the OctoPi doesn't seem to support it:

crontab -e
@reboot sleep 10 && sudo v4l2-ctl --set-ctrl=focus_auto=0
@reboot sleep 10 && sudo v4l2-ctl --set-ctrl=focus_absolute=20

Thanks!


#2

use the normal startup scripts...


#3

Exactly! Where are they? The only startup files I remember configuring for the OctoPi were octopi-network.txt for the network settings and octopi.txt to enable MJPG streamer for the webcam but I don't think you can use bash commands in those scripts as they are OctoPi-specific.


#4

I am finally able to run startup commands by ssh'ing into the OctoPi and adding them to mjpg-streamer/start.sh

cd\
nano mjpg-streamer/start.sh
sudo v4l2-ctl --set-ctrl=focus_auto=0
sudo v4l2-ctl --set-ctrl=focus_absolute=40

2018-09-28_013944