DISCLAIMER : Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility.If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.


Modern way of /etc/motd - FireMotd for linux

While developing, playing or working on Linux systems, a dynamic MotD generator script can quickly give you an overview of all used components of your Linux systems.
FireMotD can show you this information in a sanitized and colorful way while you log in with SSH or console.
Depending of the chosen theme FireMotD will output all information defined in the theme on your server.
We need EPEL repository to be installed and enabled in the server to install the dependency packages.

Install Dependencies


You need to install the required dependencies as shown below.
yum install bc sysstat jq moreutils
After installing the dependencies, clone/download or copy the FireMotd to the root directory as shown.
git clone https://github.com/OutsideIT/FireMotD.git
Change to the FireMotd directory and run the below commands
You need to have make installed on the system, if you want to use the Makefile.

To install to /usr/local/bin/FireMotD

sudo make install
With this you can probably run FireMotD from anywhere in your system. If not, you need to add /usr/local/bin to your $PATH variable. To adjust the installation path, change the var IDIR=/usr/local/bin in the Makefile to the path you want.

To install bash autocompletion support

sudo make bash_completion
With this you can use TAB to autocomplete parameters and options with FireMotD. Does not require the sudo make install above (system install), but requires the bash-completion package to be installed and working. Then you should logout-login or source the bash completion file, eg. $ . /etc/bash_completion.d/FireMotD

If you don't have root access, just install everything on your user's folder and source the file from your user's .profile file

Crontab to get system information


Root privilege is required for this operation. Only /etc/crontab and the files in /etc/cron.d/ have a username field.

The recommended way to generate /var/tmp/FireMotD.json is by creating a separate cron file for firemotd like this:

sudo vim /etc/cron.d/firemotd 

# FireMotD system updates check (randomly execute between 0:00:00 and 5:59:59) 0 0 
* * * root perl -e 'sleep int(rand(21600))' && /usr/local/bin/FireMotD -S &>/dev/null

But you can also put it in root's crontab (without the user field):

sudo crontab -e 

# FireMotD system updates check (randomly execute between 0:00:00 and 5:59:59) 0 0 
* * * perl -e 'sleep int(rand(21600))' && /usr/local/bin/FireMotD -S &>/dev/null

Adding FireMotD to run on login


Choosing where to run your script is kind of situational. Some files will only run on remote logins, other local logins, or even both. You should find out what suits best your needs on each case.

To add FireMotD to a single user


Edit the user's ~/.profile file, ~/.bash_profile file, or the ~/.bashrc file
nano ~/.profile

Add the FireMotD call at the end of the file (choose your theme)
/usr/local/bin/FireMotD -t blue

To add FireMotD to all users


You may call FireMotD from a few different locations for running globally.
Eg./etc/bash.bashrc, /etc/profile.

we use /etc/profile, so add the line to this file.

Color outputs :

Blue

FireMotD Blue

Red

FireMotD Red

Gray

MotD FireMotD Gray


Do you like this story?

No comments:

Post a Comment