| 1 | * Run a program at startup of Pi/Raspian: |
| 2 | |
| 3 | Check out the following URLs for examples and reference information: |
| 4 | |
| 5 | http://www.mikeslab.net/?p=176 |
| 6 | http://wiki.debian.org/LSBInitScripts |
| 7 | |
| 8 | Highlights from this page: |
| 9 | |
| 10 | NOTE: Use ‘sudo’ to perform these operations as root in a Raspbian shell… |
| 11 | |
| 12 | Create an LSB style init script for launching a PiBot autonomous startup app.[[BR]] |
| 13 | * I copied rc.local as a starting point and modified it to run my desired - PiBot app as follows: |
| 14 | * sudo cp /etc/init.d/rc.local /etc/init.d/pibot_auto |
| 15 | * sudo vi /etc/init.d/pibot_auto |
| 16 | * Revise the header block to describe PiBot autonomous app |
| 17 | * Revise the do_start() to launch the PiBot autonomous app |
| 18 | * Save and exit editor |
| 19 | * Test/debug the script until it works as desired using these commands: |
| 20 | * sudo /etc/init.d/pibot_auto start |
| 21 | * sudo /etc/init.d/pibot_auto stop |
| 22 | * sudo /etc/init.d/pibot_auto restart |
| 23 | When working as desired, register script to run at startup/shutdown: |
| 24 | * sudo update-rc.d pibot_auto defaults |
| 25 | If the script is changed (edited) after registering, a ‘reload’ may be necessary as follows: |
| 26 | * sudo systemctl daemon-reload |
| 27 | To unregister the script (i.e., stop it from running at startup/shutdown): |
| 28 | * sudo update-rc.d -f pibot_auto remove |