motd on desktop

Everything about X, Gnome, KDE, ... and everything running on it

motd on desktop

Postby fmp » 2017-10-14 19:36

I've gotten motd to work on servers but can't seem to get it going on desktop.

I followed the tutorial here: https://eggplant.pro/blog/dynamic-motd- ... nd-ubuntu/

both variations:
Code: Select all
run-parts /etc/update-motd.d/ | sudo tee /etc/motd

Code: Select all
run-parts /etc/update-motd.d/ | sudo tee /etc/motd.tail

load the motd perfectly, it just doesn't update after logging out/rebooting and show once a terminal is opened.

from /etc/pamd./login:
Code: Select all
session    optional   pam_motd.so motd=/run/motd
#session    optional   pam_motd.so noupdate

(also tried leaving noupdate enabled, same deal)

Am I missing something?
fmp
 
Posts: 24
Joined: 2017-09-09 04:01

Re: motd on desktop

Postby fmp » 2017-10-15 22:48

came up with a band-aid solution (if anyone has a more efficient method, would love to hear it!)

If anyone else is interested in a motd banner on debian desktop:
Code: Select all
                          __| | ___| |__ (_) __ _ _ __ 
                         / _` |/ _ \ '_ \| |/ _` | '_ \
                        | (_| |  __/ |_) | | (_| | | | |
                         \__,_|\___|_.__/|_|\__,_|_| |_|
                                                       

   Debian GNU/Linux 9.1 (stretch)       Kernel: 4.9.0-4-amd64

      As of: Sun Oct 15 18:31:51 CDT 2017

   System load:   0.48      Processes:   196
   Memory usage:   0.0%      Uptime:      5:48 hours
   Disk usage:   17%      Swap:      0.0%


(the script assumes you've got lolcat & figlet installed)

1)
Code: Select all
apt install figlet lolcat


2) As the user you want to see the banner, run:
Code: Select all
pico ~/motd.sh


3) Paste the following:
Code: Select all
#!/bin/sh

LOLCAT=/usr/games/lolcat #whereis lolcat
BANNER=$(hostname) #custom name

[ -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 $BANNER -c | $LOLCAT -f
printf "\n"

printf "\t%s \t\tKernel: %s\n" "$DISTRIB_DESCRIPTION" "$(uname -r)"
printf "\n"

date=`date`
load=`cat /proc/loadavg | awk '{print $1}'`
root_usage=`df -h / | awk '/\// {print $(NF-1)}'`
memory_usage=`free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'`
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", "exit !$2;$3/$2*100") }'`
time=`uptime | grep -ohe 'up .*' | sed 's/,/\ hours/g' | awk '{ printf $2" "$3 }'`
processes=`ps aux | wc -l`
 
echo "\t\tAs of: $date"
echo
printf "\tSystem load:\t%s\t\tProcesses:\t%s\n" $load $processes
printf "\tMemory usage:\t%s\t\tUptime:\t\t%s\n" $memory_usage "$time"
printf "\tDisk usage:\t%s\t\tSwap:\t\t%s\n" $root_usage $swap_usage
echo


Save & exit

4)
Code: Select all
pico ~/.bashrc


5) Paste the following at the bottom:
Code: Select all
~/motd.sh


Save & exit.

6) Make motd.sh executable:
Code: Select all
chmod +x ~/motd.sh


Force update your bashrc and see the effect:
Code: Select all
. ~/.bashrc


Now when you open a terminal under this user, your motd/banner will show.
fmp
 
Posts: 24
Joined: 2017-09-09 04:01


Return to Desktop & Multimedia

Who is online

Users browsing this forum: Zarrie and 8 guests

fashionable