Friday 28 December 2012

Raspi python script on startup


Attempting to get a Python script to run on bootup


Door Bell
Raspberry Pi door bell, with X-Mini as amp

I used the following code to get doorbell.py to run on boot up.


sudo bash
sudo nano /etc/init.d/doorboot

### BEGIN INIT INFO
# Provides: doorboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start door bell python script at boot time
# Description: Start doorbell at boot time.
### END INIT INFO
#! /bin/sh
# /etc/init.d/doorboot
case "$1" in
 start)
   echo "Starting DoorBell"
   python /home/pi/doorbell.py &
   ;;
 stop)
   echo "Stopping DoorBell"
   python -kill :0
   ;;
 *)
   echo "Usage: /etc/init.d/doorboot {start|stop}"
   exit 1
   ;;
esac
exit 0

chmod 755 /etc/init.d/doorboot
update-rc.d doorboot defaults

It doesn't appear to work, but this does start the app
sudo /etc/init.d/doorboot start

Anybody got any ideas?
and what is a .logon file and where would I find it?


3 comments:

  1. Hi,

    Nice post! I would really be interested in seeing a schema of the electronic part connected to your button. Also why do you need as much as 5 cables connected to your GPIO?

    Greetings

    ReplyDelete
    Replies
    1. Nuggets,
      I used a 5 cable connector only because I had an old USB header connector lying around. Only the red and white wires are connected to the back of my push-to-make switch. I did contemplate using one of the other output wires to light the LED on the switch, but the LED had already blown, hence the fact the switch was lying around unused.

      Delete
  2. I followed you startup for a python script i am working on and it worked, did you ever get yours working?

    ReplyDelete