10.22. Customizing the Message of the Day (MOTD)

Virtuozzo Hybrid Server can display an informative message, known as the message of the day (MOTD), when a user logs in to the server. As a root user, you can customize the MOTD according to your needs, for example, to show a greeting, important system information, current resource consumption, or something else.

The vz-motd service generates the message of the day from the contents of the /etc/motd_user and /etc/motd files. The steps to customize these files differ depending on whether you want the MOTD to show static or dynamic information. They are described in the following sections.

10.22.1. Setting a Custom Static MOTD

To set the MOTD to display static information, for example, a greeting, do the following:

  1. Add the desired text to the /etc/motd_user file. For example:

    echo 'Welcome to Virtuozzo Hybrid Server' >> /etc/motd_user
    
  2. Restart the Virtuozzo Hybrid Server MOTD service:

    systemctl restart vz-motd
    

On the next successful login, you will see the following static message of the day:

Welcome to Virtuozzo Hybrid Server

10.22.2. Setting a Custom Dynamic MOTD

To set the MOTD to display dynamic information, for example, the current Virtuozzo Hybrid Server release and kernel versions as well as license status, do as follows:

  1. Create the /etc/vz/ifup.d directory and a shell script with a custom name in it, for example, motd.sh:

    mkdir /etc/vz/ifup.d
    vi /etc/vz/ifup.d/motd.sh
    
  2. Add the following lines to the script:

    #! /bin/bash
    
    echo -e "
    Welcome to `cat /etc/virtuozzo-release`
    vzkernel: `uname -r`
    License:
    `vzlicview | grep -E "(status|expiration)"`
    " >> /etc/motd
    chmod 644 /etc/motd
    
  3. Make the script executable:

    chmod 755 /etc/vz/ifup.d/motd.sh
    
  4. Restart the Virtuozzo Hybrid Server MOTD service:

    systemctl restart vz-motd
    

On the next successful login, you can see a message of the day similar to the following:

Welcome to Virtuozzo Hybrid Server release 7.0.9 (469)
vzkernel: 3.10.0-862.20.2.vz7.73.25
License:
    status="ACTIVE"
    expiration="02/15/2019 02:59:59"