Creating an auto-update script for the Datto Linux Agent

Topic

This article describes the process of creating a script that will automatically update your Datto Linux Agent (DLA). Follow this workflow on each of your protected Linux servers to keep the Linux agent certificate on the protected endpoint up-to-date.

Environment

  • Datto Linux Agent

Description

This article assumes you have basic knowledge of the Linux command line and have root-level access to your Linux system via a command-line interface. For assistance with creating an auto-update script for the Datto Linux Agent, contact your Linux System Administrator.

Script creation

The Datto Linux Agent installs updates through the Linux distribution's package management system, rather than through a DLA command, so each distribution type will need a slightly different command to perform the update. You can put these commands into a script that is called by a cron job (external link). The cron job will automatically run the update script each day.

Use the following steps to create a script.

  1. Create the script file (all distros).
    You can create the script in whatever directory you would like to keep it in. For this example, we will use root's home directory, but you can replace the path to suit your own installation needs.

    ~/dla_update.sh
    chmod +x ~/dla_update.sh

  2. Enter the script file contents.
    Cut and paste the appropriate block into the ~/dla_update.sh file you just created.

    For Debian/Ubuntu systems

    #!/bin/bash
    apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 370C85D709D26407
    bash -c "echo 'deb [arch=amd64] https://cpkg.datto.com/datto-deb/public/$(lsb_release -sc) $(lsb_release -sc) main' > /etc/apt/sources.list.d/datto-linux-agent.list"
    apt-get update
    apt-get install dlad

    For Red Hat/CentOS systems

    #!/bin/bash
    yum update dlad

    For OpenSUSE/SLE systems

    #!/bin/bash
    zypper install dlad

    For Fedora systems

    #!/bin/bash
    dnf install dlad

Cron job creation (all distros)

To create the cron job that will run the script, follow the steps below.

  1. Run the following command as root.

    crontab -e

  2. Add the line below to create a cron job that will run the update every day at midnight.

    0 0 * * * ~/dla_update.sh

  3. Save and exit the editor.

  4. You can view the new crontab file to confirm that the new job is in place by running:

    crontab -l

Service restart

To activate the new cron job, restart the cron service according to your Linux distribution's init system type. To determine your init system type, check the documentation for your specific Linux distribution.

EXAMPLE  
/etc/init.d/cron restart
service cron restart
systemctl restart crond.service

Additional Resources