Although the Raspberry Pi comes with a HDMI port most projects are ‘head’ less (without a display), this means you spend a lot of time using either VNC or SSH to access the operating system, if it’s the latter you will normally get the most basic and boring login banner, this login banner is your MOTD (Message of the day, Linux term).
Theres a great post on the Raspberry PI forums, where someone has created the below dynamic banner for each time that you login.
Hopefully one day this might get included into the standard operating system, if you can’t wait like me it’s fairly simple to get it installed.
Note; See the comments for some tips on a better place to put this scriptFirst you need to edit your profile:
sudo nano /home/pi/.bash_profile
Then just past in the code below, anywhere within that file:
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)" let secs=$((${upSeconds}%60)) let mins=$((${upSeconds}/60%60)) let hours=$((${upSeconds}/3600%24)) let days=$((${upSeconds}/86400)) UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"` # get the load averages read one five fifteen rest < /proc/loadavg echo "$(tput setaf 2) .~~. .~~. `date +"%A, %e %B %Y, %r"` '. \ ' ' / .' `uname -srmo`$(tput setaf 1) .~ .~~~..~. : .~.'~'.~. : Uptime.............: ${UPTIME} ~ ( ) ( ) ~ Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total) ( : '~'.~.'~' : ) Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min) ~ .~ ( ) ~. ~ Running Processes..: `ps ax | wc -l | tr -d " "` ( : '~' : ) 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` '~ .~~~. ~' 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'` '~' $(tput sgr0)"
Source: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=23440
7 comments On Raspberry Pi – Awesome custom MOTD
Nice! that looks sweet.
I don’t know about the rPi version but on a “normal” debian install you’d make that it’s own script and put it in /etc/update-motd.d
If you would indulge an OCD sysadmin for a yarn:
eg.
1. Add a #!/bin/sh to the head of your script
2. Take your script and name it banner.sh
3. Move your script to /etc/update-motd.d and add a number to the front of it like ##-banner.sh
The number is the order. the higher the number the lower it will appear in the message
4. run sudo chmod a+x /etc/update-motd.d/*-banner.sh
There, a place for everything and everything in it’s place 🙂
if update-motd isn’t being used you can add this line to /etc/rc.local to get it working
[ -d /etc/update-motd.d ] && echo -n “” > /etc/motd && for f in `ls /etc/update-motd.d | sort`; do echo -e `etc/update-motd.d/$f` >> /etc/motd; done
Thanks for the great info!
Thanks for the information on motd. I made a couple of changes to get the update-motd.d script to output to multiple lines.
[ -d /etc/update-motd.d ] && echo -n > /etc/motd && for f in `ls /etc/update-motd.d | sort`; do /bin/bash `etc/update-motd.d/$f` >> /etc/motd; done
Using /etc/motd is definitely the proper way to do it, however on Raspbian there doesn’t seem to be a good way for it to update on login. The update-motd package isn’t available, and putting that line you provided (which is great) in rc.local will only update the motd on reboot, which won’t achieve the same effect if ssh’ing after boot. For that reason, simply printing to stdout from .bash_profile or /etc/profile seems to be the best way to achieve the same effect on the RPi.
Pingback: PI Update: I Made It Pretty! | I Am Not A Spoon ()
Hi,
it is very interesting MOTD.
Most interesant part of it is getting a weather via CURL, and parsing it with SED. That’s where my head is not enough.
Will you be able to customize the sed command that it will only display raw temperature number, eg. 27.
Many thanks,
Rob