Skip to content

Instantly share code, notes, and snippets.

@denhamparry
Created July 2, 2019 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denhamparry/229c5a994c291b0c944d417b7b425677 to your computer and use it in GitHub Desktop.
Save denhamparry/229c5a994c291b0c944d417b7b425677 to your computer and use it in GitHub Desktop.
Change welcome message in Ubuntu

Change welcome message in Ubuntu

$ sudo apt-get install figlet lolcat strace
$ sudo mv /etc/update-motd.d/00-header /etc/update-motd.d/00-header-old
$ sudo chmod -x /etc/update-motd.d/*
$ sudo touch /etc/update-motd.d/00-header
$ sudo chmod +x /etc/update-motd.d/00-header
$ sudo vi /etc/update-motd.d/00-header
#!/bin/sh

# redirect errors to stdout -- just in case
exec 2>&1

[ -r /etc/lsb-release ] && . /etc/lsb-release

if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
   # Fall back to using the very slow lsb_release utility
   DISTRIB_DESCRIPTION=$(lsb_release -s -d)
fi

# lolcat MIGHT NOT BE IN $PATH YET, SO BE EXPLICIT
LOLCAT=/usr/games/lolcat

# UPPERCASE HOSTNAME, APPLY FIGLET FONT "block" AND CENTERING
INFO_HOST=$(echo $(hostname) | awk '{print toupper($0)}' | figlet -tc -f block)

# GET OS/ARCH/DATE, APPLY FIGLET FONT "term" AND CENTERING
INFO_OS=$(printf "%s (%s)\n%s" "$DISTRIB_DESCRIPTION" "$(uname -r)" "$(date)" | figlet -tc -f term)

# RUN IT ALL THROUGH lolcat FOR COLORING
# NOTE: needs -f to force color output since intermediate file is not a TTY
printf "%s\n%s\n" "$INFO_HOST" "$INFO_OS" | $LOLCAT -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment