Skip to content

Instantly share code, notes, and snippets.

@obihann
Last active August 29, 2015 13:56
Show Gist options
  • Save obihann/8983004 to your computer and use it in GitHub Desktop.
Save obihann/8983004 to your computer and use it in GitHub Desktop.
Dynamic message of the day
#!/bin/bash
PROCCOUNT=`ps -l | wc -l`
PROCCOUNT=`expr $PROCCOUNT - 4`
if [[ $(groups) == *irc* ]]; then
ENDPROC=`cat /etc/security/limits.conf | grep "@irc" | grep nproc | awk {'print $4'}`
ENDSESSION=`cat /etc/security/limits.conf | grep "@irc" | grep maxlogins | awk {'print $4'}`
PRIVLAGED="IRC Account"
else
ENDPROC=`cat /etc/security/limits.conf | grep "*" | grep nproc | awk {'print $4'}`
ENDSESSION="Unlimited"
PRIVLAGED="Regular User"
fi
echo -e "
+++++++++++++++++: System Data :+++++++++++++++++++
+ Hostname = `hostname`
+ Distro = `cat /etc/*-release | head -1`
+ Address = 23.226.129.81
+ Kernel = `uname -r`
+ Uptime = `uptime | sed 's/.*up ([^,]*), .*/1/'`
+ Memory = `cat /proc/meminfo | grep MemTotal | awk {'print $2'}` kB
++++++++++++++++++: User Data :++++++++++++++++++++
+ Username = `whoami`
+ Privlages = $PRIVLAGED
+ Sessions = `who | grep $USER | wc -l` of $ENDSESSION MAX
+ Processes = $PROCCOUNT of $ENDPROC MAX
"

#Dynamic message of the day

A bash script to display a dynamic MOTD (message of the day) within SSH.

##Setup:

  • Download the file:

    $ wget http://git.io/vk0me -P /usr/local/bin/
    $ chmod +x /usr/local/bin/dynmotd
    

##Preview:

+++++++++++++++++: System Data :+++++++++++++++++++
+ Hostname = archinspiron
+ Distro =  NAME="Arch Linux"
+ Address = 23.226.129.81
+ Kernel = 3.18.5-1-ARCH
+ Uptime =  13:05:37 up 48 days, 15:41,  1 user,  load average: 0.01, 0.05, 0.06
+ Memory = 2052852 kB
++++++++++++++++++: User Data :++++++++++++++++++++
+ Username = jeff
+ Privlages = Regular User
+ Sessions = 1 of Unlimited MAX
+ Processes = 2 of  MAX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment