Notes

Custom Raspberry Pi MOTD (Message Of The Day)

Edit on GitHub

Raspberry Pi
2 minutes
 1let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
 2let secs=$((${upSeconds}%60))
 3let mins=$((${upSeconds}/60%60))
 4let hours=$((${upSeconds}/3600%24))
 5let days=$((${upSeconds}/86400))
 6UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
 7
 8# get the load averages
 9read one five fifteen rest < /proc/loadavg
10
11echo "$(tput setaf 2)
12    .~~.   .~~.    `date +"%A, %e %B %Y, %r"`
13    '. \ ' ' / .'   `uname -srmo`$(tput setaf 1)
14    .~ .~~~..~.   
15    : .~.'~'.~. :   Uptime.............: ${UPTIME}
16    ~ (   ) (   ) ~  Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
17( : '~'.~.'~' : ) Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
18    ~ .~ (   ) ~. ~  Running Processes..: `ps ax | wc -l | tr -d " "`
19    (  : '~' :  )   IP Addresses.......: `/sbin/ifconfig eth0 | /bin/grep "inet addr" | /usr/bin/cut -d ":" -f 2 | /usr/bin/cut -d " " -f 1` and `wget -q -O - http://icanhazip.com/ | tail`
20    '~ .~~~. ~'    Weather............: `curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|UK|UK001|NAILSEA|" | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'`
21        '~'
22$(tput sgr0)"
23
24Free Disk Space....: `df -Pk | grep -E '^/dev/sda1' | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`k on /dev/sda1

I had to change eth0 to wlan0 in order to show the local IP of Raspberry Pi. This depends on the way you are connected to the network, change this accrodingly. eth0 is for ethernet and wlan0 is for wifi.

Changing Location

1    For Lahore: 
2    
3    	ASI|PK|PK007|LAHORE 

Remove existing stuff

1sudo nano motd

Press Ctrl+K for a few seconds. Then Ctrl+O, Enter and Ctrl+X

Related