Skip to content

Instantly share code, notes, and snippets.

@threesquared
Created January 7, 2019 09:33
Show Gist options
  • Save threesquared/cf811684a58c8529033ea2b53ceae950 to your computer and use it in GitHub Desktop.
Save threesquared/cf811684a58c8529033ea2b53ceae950 to your computer and use it in GitHub Desktop.
Custom MOTD Script
#!/bin/sh
# Save file as /etc/update-motd.d/01-custom and make executable. Requires figlet.
export TERM=xterm-256color
read one five fifteen rest < /proc/loadavg
echo "$(tput setaf 2)
`figlet -f graffiti "d-formed" | sed 's/^/ /'`
$(tput setaf 7)
`date +"%A,%e %B %Y, %r"`
`uname -srmo`
Host...............: `hostname`
Last Login.........: `last -i $USER | grep -v 'still logged' | head -1 | awk '{print $4, $5 ,$6 ,$7, "from", $3}'`
Uptime.............: `awk '{print int($1/86400)" days "int($1/3600%24)" hours "int(($1%3600)/60%60)" minutes "int($1%60)" seconds"}' /proc/uptime`
Memory.............: `free -h | gawk '/Mem:/{print $7}'` (Available) / `free -h | gawk '/Mem:/{print $2}'` (Total)
Load Averages......: ${one} (1min) ${five} (5mins) ${fifteen} (15mins)
Running Processes..: `ps ax | wc -l | tr -d " "` total running of which `ps -U $USER | wc -l | tr -d " "` are yours
Disk Usage.........: `/bin/df -h / | awk '!/Used/ {print $4}'` free on / and `/bin/df -h /home | awk '!/Used/ {print $4}'` free on /home
SSH Logins.........: There are currently `who | sort --key=1,1 --unique | wc --lines` users logged in
IP Addresses.......: `ip a | grep glo | awk '{print $2}' | head -1 | cut -f1 -d/` 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)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment