Introduction
Some notes on editing or removing the banner / motd that appears when you login over ssh. There are two main files to edit to change the bannerβs behavior.
- /DietPi/dietpi/func/dietpi-banner : Script for displaying the banner
- /DietPi/dietpi/login : Script Called on login, calls dietpi-banner
Removing Banner
In the login file find the entry for the type of login you want to change the banner for in the Main Loop of the script. The one I changed was Normal Login.
#----------------------------------------------------------------
#Normal Login
if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
/DietPi/dietpi/func/dietpi-banner 1
(( $AUTO_START_INDEX > 0 )) && Run_AutoStart
#----------------------------------------------------------------
To remove the menu completely just make the line that calls the banner script a comment.
#/DietPi/dietpi/func/dietpi-banner 1
To remove only the credits, you can change the banner script argument to 0. Using 0 as the argument will not clear the screen before printing meaning it is useful if you just want to append the dietpi banner to your own message of the day through /etc/update-motd.d
/DietPi/dietpi/func/dietpi-banner 0
If you would like to clear the system MOTD when using the 0 banner argument you have to edit the banner scriptβs Banner_Dietpi function, see βEditing Bannerβ for more instructions on editing the banner file directly.
Banner_Dietpi(){
if (( $INPUT == 1 )); then #"if(( $INPUT < 1)); then" will clear the MOTD when argument is 0
printf '\ec' # clear current terminal screen
fi
...
Editing Banner
The banner actually is a nice base if you add donβt want to make a motd script from scratch. The following is an example to display the $SHELL environment variable in the banner. If you would like to edit the DietPi banner first follow the instructions for removing it and then make a copy of dietpi-banner in /etc/update-motd.d or replace /etc/motd if you do not want the default motd to be shown with it. This will allow your changes to persist through an update but you might have to remove the default banner again after an update. The copy can be made with the following commands
sudo cp /DietPi/dietpi/func/dietpi-banner /etc/update-motd.d/
or
sudo mv /etc/motd /etc/motd.old && sudo cp /DietPi/dietpi/func/dietpi-banner /etc/motd
Create a function in dietpi-banner to echo out the information you want to display, I used a copy of the Hardware_Model_Print function and appended it to the Globals section.
ShellEnv_Print(){
echo -e " \e[1m"Shell Path"\e[0m \e[90m| $SHELL\e[0m\n \e[38;5;154mββββββββββββββββββββββββββββββββββββββββββββββββ\e[0m"
}
#/////////////////////////////////////////////////////////////////////////////////////
# Banner Print
#/////////////////////////////////////////////////////////////////////////////////////
In order to add your message to the banner edit the Banner_Dietpi function in the Banner Print section to include your function, this is also where you can remove any unwanted banner sections by commenting out or deleting their print function.
Banner_Dietpi(){
... # Terminal Clearing Code
echo -e " \e[38;5;154mββββββββββββββββββββββββββββββββββββββββββββββββ\e[0m\n \e[1mDietPi\e[0m $TEXT_TOP\n \e[38;5;154mββββββββββββββββββββββββββββββββββββββββββββββββ\e[0m"
#Hardware_Model_Print
IPAddress_Print
ShellEnv_Print
}
This should allow you to add any entry you need to the banner, the rest of the dietpi-banner script is also a good example however hopefully this gave you an idea where to start.