Skip to content

Instantly share code, notes, and snippets.

@riipandi
Last active February 24, 2024 14:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save riipandi/9368730 to your computer and use it in GitHub Desktop.
Save riipandi/9368730 to your computer and use it in GitHub Desktop.
Dynamic SSH Banner (Tutorial by http://oitibs.com/debian-wheezy-dynamic-motd/)
#!/bin/sh
#
# 00-header - create the header of the MOTD
# Copyright (c) 2013 Nick Charlton
# Copyright (c) 2009-2010 Canonical Ltd.
#
# Authors: Nick Charlton <hello@nickcharlton.net>
# Dustin Kirkland <kirkland@canonical.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 2 of the License, or
# (at your option) any later version.
[ -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
#figlet $(hostname -f)
figlet "Murukusunu /"
#printf "\n"
#printf "Welcome to %s (%s).\n" "$DISTRIB_DESCRIPTION" "$(uname -r)"
#printf "\n"
#!/bin/sh
#
# 10-sysinfo - generate the system information
# Copyright (c) 2013 Nick Charlton
# Copyright (c) 2009-2010 Canonical Ltd.
#
# Authors: Nick Charlton <hello@nickcharlton.net>
# Dustin Kirkland <kirkland@canonical.com>
# http://oitibs.com/debian-wheezy-dynamic-motd/
#
# 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 2 of the License, or
# (at your option) any later version.
# time of day
HOUR=$(date +"%H")
if [ $HOUR -lt 12 -a $HOUR -ge 0 ]; then
TIME="morning"
elif [ $HOUR -lt 17 -a $HOUR -ge 12 ]; then
TIME="afternoon"
else
TIME="evening"
fi
# System uptime
uptime=`cat /proc/uptime | cut -f1 -d.`
upDays=$((uptime/60/60/24))
upHours=$((uptime/60/60%24))
upMins=$((uptime/60%60))
MEMORY1=`free -t -m | grep "buffers/cache" | awk '{print $3" MB";}'`
MEMORY2=`free -t -m | grep "Mem" | awk '{print $2" MB";}'`
# System + Memory
SYS_LOADS=`cat /proc/loadavg | awk '{print $1}'`
SWAP_USED=`free -m | tail -n 1 | awk '{print $3}'`
NUM_PROCS=`ps aux | wc -l`
IPADDRESS=`ifconfig | sed -n 's/.*inet addr:\([0-9.]\+\)\s.*/\1/p' | grep -v '127.0'`
# Cek Update
CEK_UPDATE1=`/usr/lib/update-notifier/apt-check --human-readable | grep "can be updated"`
CEK_UPDATE2=`/usr/lib/update-notifier/apt-check --human-readable | grep "security updates"`
echo "
===================================================================
- Good $TIME `whoami`. Wilujeng sumping !!
===================================================================
- Hostname............: `hostname -f`
- IP Address..........: $IPADDRESS
- Release.............: `uname -a | awk '{print $1" "$3" "$12}'`
- Users...............: Currently `users | wc -w` user(s) logged on
- Server Time.........: `date`
===================================================================
- System load.........: $SYS_LOADS / $NUM_PROCS processes running
- Memory used.........: $MEMORY1 / $MEMORY2
- Swap in use.........: $SWAP_USED MB
- System uptime.......: $upDays days $upHours hours $upMins minutes
===================================================================
- Available updates...: $CEK_UPDATE1
- Security updates....: $CEK_UPDATE2
===================================================================
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment