Automation/RaspberryPi: Difference between revisions

From Medien Wiki
mNo edit summary
Line 22: Line 22:
make a file startup_script.sh (shell script) with the following content:
make a file startup_script.sh (shell script) with the following content:


clear
<syntaxhighlight lang="bash">
echo "Automatic start up script running"
clear
date '+Date %Y-%m-%d Time %H:%m'
echo "Automatic start up script running"
echo -e "This is \c" && hostname
date '+Date %Y-%m-%d Time %H:%m'
ifconfig | grep "inet addr"
echo -e "This is \c" && hostname
sleep 2
ifconfig | grep "inet addr"
clear
sleep 2
sudo shutdown -h +540 & omxplayer -r movie.mp4 --loop
clear
sudo shutdown -h +540 & omxplayer -r movie.mp4 --loop
</syntaxhighlight>


sudo shutdown -h +540 will shut the Raspberry down in 9 hours. You will have to make the file executable with
sudo shutdown -h +540 will shut the Raspberry down in 9 hours. You will have to make the file executable with
Line 47: Line 49:
Disable the getty program.
Disable the getty program.
Find this line and comment it our by adding a # at the beginning of the line
Find this line and comment it our by adding a # at the beginning of the line
#1:2345:respawn:/sbin/getty 115200 tty1
<syntaxhighlight lang="bash">
#1:2345:respawn:/sbin/getty 115200 tty1
</syntaxhighlight>


Add login program to inittab.
Add login program to inittab.
Add the following line just below the commented line
Add the following line just below the commented line
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
<syntaxhighlight lang="bash">
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
</syntaxhighlight>
This will run the login program with pi user and without any authentication
This will run the login program with pi user and without any authentication


Line 58: Line 64:
Make it start the script automatically:
Make it start the script automatically:
  sudo nano .bashrc
  sudo nano .bashrc
<syntaxhighlight lang="bash">
and right at the end put:
and right at the end put:
  if [ $(tty) == /dev/tty1 ]; then
  if [ $(tty) == /dev/tty1 ]; then
   ./startup_script.sh
   ./startup_script.sh
  fi
  fi
</syntaxhighlight>


(that last 'if' makes sure the script is not starting in an x session)
(that last 'if' makes sure the script is not starting in an x session)
Line 69: Line 77:


If you always want HDMI output, you would like to uncomment the lines
If you always want HDMI output, you would like to uncomment the lines
 
<syntaxhighlight lang="bash">
  hdmi_force_hotplug=1
  hdmi_force_hotplug=1
  hdmi_drive=2
  hdmi_drive=2
</syntaxhighlight>


all of the switches are explaned on [http://elinux.org/RPiconfig elinux]
all of the switches are explaned on [http://elinux.org/RPiconfig elinux]
Line 167: Line 176:




 
[[Category:Max Neupert]]
[[Category:Automation]]
[[Category:Automation]]
[[Category:RaspberryPi]]
[[Category:RaspberryPi]]