Boot To Python Program


4 posts
by The_Pixie » Mon Nov 05, 2012 2:10 pm
Hey

Which file, line of code, script or whatever, would I use to auto boot up into a (self built) python program?

Ta!
Posts: 11
Joined: Tue May 22, 2012 10:21 am
Location: Welbeck
by penguintutor » Mon Nov 05, 2012 4:20 pm
It depends what you want it to do

To run as a background daemon
/etc/init.d/<appname>
- then register using update-rc.d
or use /etc/rc.local

To have it run on login - without X starting
add a script to /etc/profile.d
(I believe this is how raspi-config runs on first startup)

Note autologin can be handled by including the following line in /etc/inittab
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

To have it run as a GUI application once X has started
Add an <appname>.desktop file to ~/.config/autostart/ )
User avatar
Posts: 338
Joined: Tue May 08, 2012 9:11 am
Location: UK
by LetHopeItsSnowing » Tue Nov 06, 2012 8:53 am
If your looking to run your program as a daemon (in the background), see this post, http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html, for info on how to set it up.

LHIS
"am I getting slower, or is stuff more complicated; either way I now have to write it down - stuffaboutcode.com"
User avatar
Posts: 208
Joined: Sat May 26, 2012 6:40 am
Location: UK
by Super-Nathan » Wed Nov 07, 2012 2:12 am
This code should clear up how raspi-setup (PiBang) and raspi-config(Raspbian) boot


Code: Select all
#!/bin/sh
# Part of raspi-setup http://github.com/super-nathan/raspi-setup
#
# See LICENSE file for copyright and license details

# Should be installed to /etc/profile.d/raspi-config.sh to force raspi-config
# to run at initial login

# You may also want to set automatic login in /etc/inittab on tty1 by adding a
# line such as:
# 1:2345:respawn:/bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1 # RPICFG_TO_DISABLE

# If you are trying to make this run on boot for a machine that has already been configured,
# then if you follow all the above instructions you will still be booted into an X session.
# If you <ctlr>+<alt>+<f1> you will find the raspi-config there ready to run.
# In order to boot straight into Raspi-config you must disable lightdm with
# $ sudo update-rc.d lightdm disable
# Then when you reboot the machine, you will be sent straight into the config.


if [ $(id -u) -ne 0 ]; then
  printf "\nNOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-setup'\n\n"
else
  raspi-setup
  exec login -f pi
fi
echo "Something Useful" > /dev/null
User avatar
Posts: 67
Joined: Sun Jun 17, 2012 6:56 am
Location: South Korea