I've been tinkering with my CentOS server login procedure, I want to have my MOTD update using the linux_logo program. I've already tried doing this in a few ways, but didn't get the desired effect. I have started with this command:
/usr/bin/linux_logo -c -u -y -t "$R" > /etc/motd
The key info to be updated here is the uptime.
I have tried adding it to my .bashrc file, and adding the command to a new bash script in /etc/profile.d/ folder, and making it executable. Both of these methods make it run at login, but only after the MOTD has been printed, so it's one login behind.
I also created an init script with the command in it using chkconfig to set it to start at runtime levels 345, this I believe just made it run the script during boot.
I have also tried adding the following to my sshd_config file:
ForceCommand /usr/bin/linux_logo -c -u -y -t "$R" > /etc/motd
This had the effect of closing my ssh connection every time I logged in :/
These were all suggestions from similar posts I found when googling for this, so I think I am missing something, at this point some help would be appreciated.
To summarise, I want the following, or similar command to run at login, prior to the motd being printed. Is this possible?
if [ -f /usr/bin/linux_logo ]; then
/usr/bin/linux_logo -c -u -y -t "$R" > /etc/motd
fi