Created
November 30, 2013 11:48
-
-
Save ironpinguin/7718053 to your computer and use it in GitHub Desktop.
Script to Display the RaspberryPi IP Addresses on Startup in the LCD dogl-128 Display. (rpi-gpio + rpi-dog128).
add in /etc/network/interfaces at the end:
post_up /usr/local/bin/display_ip_info.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
socket=/var/lib/gpiod/socket | |
set_backlight="LCD BACKLIGHT 30\n" | |
lcd_clear="LCD CLEAR\n" | |
lcd_start=${set_backlight}${lcd_clear} | |
lcd_show="LCD SHOW\n" | |
pos_x=0 | |
pos_y=0 | |
lcd_text_pre="LCD TEXT 8 " | |
if_count=0 | |
IFSTATUS=`ifplugstatus | grep -v lo | grep -v unplugged |cut -d: -f1` | |
for interface in $IFSTATUS | |
do | |
if_count=$(($if_count + 1)) | |
addr=`ip -4 addr list dev $interface | grep inet | awk '{print $2;}' | cut -d'/' -f1` | |
iftext[$if_count]="$interface:" | |
ifaddr[$if_count]="$addr" | |
done | |
lcd_out="${lcd_start}${lcd_text_pre}${pos_x} $pos_y Raspberry Pi Kicker\n" | |
pos_y=$(($pos_y + 8)) | |
lcd_out="${lcd_out}${lcd_text_pre}${pos_x} $pos_y -------------------\n" | |
pos_y=$(($pos_y + 8)) | |
if [ "$if_count" -ne "0" ] | |
then | |
for i in `seq 1 $if_count` | |
do | |
lcd_out="${lcd_out}${lcd_text_pre}${pos_x} $pos_y ${iftext[$i]}\n" | |
pos_y=$(($pos_y + 8)) | |
xp=$(($pos_x + 16)) | |
lcd_out="${lcd_out}${lcd_text_pre}${xp} $pos_y ${ifaddr[$i]}\n" | |
pos_y=$(($pos_y + 8)) | |
done | |
fi | |
lcd_out="${lcd_out}$lcd_show" | |
echo -e $lcd_out | nc -U $socket |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment