Raspberry Pi startup scripts

There are several methods to run programs, services and scripts at start when you boot the Raspberry Pi. For my MediaPlayer Box, i use the method over the .bashrc. After the automatic login to the console, a script is executed.

Run raspi-config for automatic login (Raspbian Jessie (Lite))

  • Boot Options -> Console Autologin
pi@raspberrypi ~ $ sudo raspi-config
  • Manual setting:
pi@raspberrypi ~ $ sudo mkdir -p /etc/systemd/system/getty@tty1.service.d
pi@raspberrypi ~ $ sudo nano /etc/systemd/system/getty@tty1.service.d/autologin.conf

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux

pi@raspberrypi ~ $ sudo systemctl enable getty@tty1.service

1a. Create script file

pi@raspberrypi ~ $ nano start_script.sh

python KodiDisplayInfo/displayinfo.py &
kodi 

1b. Make file executable

pi@raspberrypi ~ $ chmod u+x start_script.sh

2. Edit .bashrc

Add it to the END of file:

pi@raspberrypi ~ $ nano .bashrc

if [ $(tty) == /dev/tty1 ]; then
./start_script.sh
fi

Comments:

Allowed HTML-Tags: <strong>, <a href="">, <em>
Info: Comment will be shown shortly after processing.