TrueNAS: Run MOTD Startup Script

For a number of reasons it may be helpful for you to edit the message of the day (MOTD) script that is displayed when you login to your TrueNAS jail. This TrueNAS: Run MOTD Startup Script will show you how to create this login message. After setting up my VPN as outlined in the TrueNAS: Add VPN Connection to a Jail article, I wanted a quick way to ensure that my VPN was still connected and so I opted to write a simple script to have my MOTD display my public IP address. This is a very quick article which will show you how to create an MOTD to display your public ip address.

This is part of my ongoing series of TrueNAS and FreeNAS setup, configuration and install articles.

Create a Script and Run it at Login

First we are going to create a simple script using nano /etc/ipcheck.sh which looks something like this:

#!/bin/bash
printf "\\33[0;34mYour public IP address is:\033[0;31m\n"
wget -qO - http://wtfismyip.com/text
printf "\\033[0m"

Paste the above code into nano and then save the file (Ctrl-X and then select ‘Y’). As we want this script to be able to run, we need to set securities with chmod to make executable using this command:
chmod +x /etc/ipcheck.sh

Now we will need to add the script to the login file by editing it with this command:
nano ~/.login

In this file, we will add this line:
/bin/sh /etc/ipcheck.sh

That is it. You’ve completed this TrueNAS: Run MOTD Startup Script article! If you log out and back in you should see your public IP address in your login message of the day (MOTD).

Happy TrueNASin’!

~digiMoot

Liked it? Take a second to support digiMoot on Patreon!

4 thoughts on “TrueNAS: Run MOTD Startup Script

Leave a Reply

Your email address will not be published. Required fields are marked *