-
-
Save clivewalkden/94bd15cb9af5cf3884e414fdf55b1b78 to your computer and use it in GitHub Desktop.
MOTD for Centos / RHEL
This file contains 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 | |
# This motd.sh file is to be placed in /etc/profile.d/ to be executed upon | |
# successful login. | |
# ------------------------------------------------------------------------- | |
# Copyright (c) 2018 Mike Centola (mikecentola.com) | |
# | |
# This program is free software: you can redistribute it and/or modify it under | |
# the terms of the GNU General Public License as published by the Free Software | |
# Foundation, either version 3 of the License, or (at your option) any later | |
# version. | |
# | |
# This program is distributed in the hope that it will be useful, but WITHOUT | |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
# | |
# For a copy of the GPL V3, see http://www.gnu.org/licenses/. | |
# | |
# Last Updated: 2018/12/18 | |
# ------------------------------------------------------------------------- | |
# OS | |
OS="`cat /etc/redhat-release`" | |
# KERNEL | |
KERN="`uname -r`" | |
# IP Address | |
IFACE="eth0" #SET TO YOUR IFACE | |
IPADDR="`ip addr show $IFACE |grep -w 'inet' | awk -F' ' '{print $2}'`" | |
# Uptime | |
UPTIME="`uptime | sed 's/^.*up *//;s/, *[0-9]* user.*$/m/;s/ day[^0-9]*/d, /;s/ \([hms]\).*m$/\1/;s/:/h, /'`" | |
# Load Avg | |
LOADAVG="`cat /proc/loadavg | awk -F' ' '{print $1"(1min) " $2"(5min) " $3"(15min)"}'`" | |
# Memory Free | |
MEMFREE="`free -m | grep "Mem" | awk '{print $3"MB / "$2"MB" }'`" | |
# Root Free | |
ROOTFREE="`df -h / | grep "/" | awk '{ print $3 "/" $2 " ("$5")"}'`" | |
# Logged In Users | |
USRS="`users | wc -w`" | |
# Setting variables for ANSI colors | |
WHITE="\033[1;49;97m" | |
BLUE="\033[1;49;96m" | |
GREY="\033[0;90;40m" | |
NC="\033[0m" # NO COLOR | |
####### START OUTPUT ####### | |
if [ "$(id -u)" != "0" ] && [[ ! $TERMCAP =~ screen ]]; then | |
echo -e "$BLUE" | |
cat << "EOF" | |
__ __ ___ _ _____ ___ ___ _ _ _____ ___ _ _ | |
| \/ |_ _| |/ | __/ __| __| \| |_ _/ _ \| | /_\ | |
| |\/| || || ' <| _| (__| _|| .` | | || (_) | |__ / _ \ | |
|_| |_|___|_|\_|___\___|___|_|\_| |_| \___/|____/_/ \_\ | |
EOF | |
echo -e " | |
$GREY=============================================================$BLUE | |
Welcome to $WHITE$(hostname)$BLUE | |
SYSTEM OS :$WHITE $OS $BLUE | |
KERNEL VERSION :$WHITE $KERN $BLUE | |
IP ADDR ($IFACE) :$WHITE $IPADDR $BLUE | |
UPTIME :$WHITE $UPTIME $BLUE | |
LOAD AVERAGE :$WHITE $LOADAVG $BLUE | |
FREE MEMORY :$WHITE $MEMFREE $BLUE | |
ROOT FREE :$WHITE $ROOTFREE $BLUE | |
LOGGED IN USERS :$WHITE $USRS $BLUE | |
You're currently logged in as $WHITE$(whoami)$GREY | |
=============================================================$NC" | |
echo | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment