Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A convenient motd-creation script for Gentoo servers. See: http://cl.ly/3v1T1m2F1I151U2i301Q
#!/bin/sh
# Place in /etc/motd.d and drop the .sh suffix.
echo -e "\n\033[1mWelcome to Gentoo Linux!\033[0m"
echo -e "\nThis server is maintained by \033[1m$(cat /etc/maintainer)\033[0m."
echo -e "Contact \033[1m$(cat /etc/maintainer-address)\033[0m for support."
echo en "\n \033[1;32m*\033[0m "
lsb_release -d -s | sed s/\"//g
echo -en " \033[1;32m*\033[0m "
uname -snmpr
MAX=$(($(cat /proc/cpuinfo | grep processor | wc -l) - 1))
LOAD=$(cat /proc/loadavg | cut -d '.' -f 1)
if [ $LOAD -gt $(($MAX * 4)) ]
then echo -en " \033[1;31m*\033[0m"
elif [ $LOAD -gt $MAX ]
then echo -en " \033[1;33m*\033[0m"
else echo -en " \033[1;32m*\033[0m"
fi
uptime
echo -en " \033[1;32m*\033[0m IPv4 Network Interfaces: \033[1m"
ifconfig | grep 'inet ' | cut -d ' ' -f 10 | tr '\n' ' '
echo -e "\033[0m"
echo -en " \033[1;32m*\033[0m IPv6 Network Interfaces: \033[1m"
ifconfig | grep 'inet6 ' | cut -d ' ' -f 10 | tr '\n' ' '
echo -e "\033[0m"
#!/bin/bash
# Place in /etc/motd.d and drop the .sh suffix.
if [ ! -e /var/tmp/.updates ] ; then
/usr/local/sbin/check-updates > /var/tmp/.updates
fi
cat /var/tmp/.updates
#!/bin/sh
# Place in /usr/local/sbin and drop the .sh suffix.
SYS=$(emerge -uDNpq system | grep ebuild | wc -l)
WRL=$(emerge -uDNpq world | grep ebuild | wc -l)
SEC=$(glsa-check -l affected 2> /dev/null | grep \\[ | wc -l)
TOT=$(glsa-check -l all 2> /dev/null | grep \\[ | wc -l)
NEWS=$(eselect news list | grep unread | wc -l)
SYSC="\033[1;32m"
WRLC=$SYSC
SECC=$SYSC
if [ $SYS -gt 0 ] ; then
SYSC="\033[1;33m"
fi
if [ $WRL -gt 0 ] ; then
WRLC="\033[1;33m"
fi
if [ $SEC -gt 0 ] ; then
SECC="\033[1;31m"
fi
echo -e "\nPortage and GLSA status:\n"
echo -e " ${SYSC}* ${SYS}\033[0m system packages have updates available."
echo -e " ${SECC}* ${SEC}\033[0m of \033[1m${TOT}\033[0m security advisories affect this server."
echo -e " ${WRLC}* ${WRL}\033[0m packages in total can be updated."
if [ $NEWS -gt 0 ] ; then
echo -e "\n\033[1;33mImportant:\033[0m There are \033[1m${NEWS}\033[0m unread news items."
fi
#!/bin/bash
# Place in /usr/local/sbin and drop the .sh suffix.
# Configure this to run between once every minute and once every five.
cd /etc/motd.d
rm -f /tmp/motd-tmp
touch /mtp/motd-tmp
for SCRIPT in $(ls); do
test -x ${SCRIPT} || continue
./${SCRIPT} >> /tmp/motd-tmp
done
echo >> /tmp/motd-tmp
mv /tmp/motd-tmp /etc/motd
#!/bin/sh
# Place in /etc/portage/postsync.d and drop the .sh suffix.
# Would be nice if this could also run after every package installation.
rm /var/mtp/.updates
@Kami-no

This comment has been minimized.

Copy link

commented Jan 19, 2015

Sure about this?
update-motd.sh row #9
z-motd.sh row #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.