Skip to main content
All CollectionsNode Maintenance and Service Management | MystNodes Help Center
How to setup automatic node updates on Ubuntu/Debian/RaspberryPi
How to setup automatic node updates on Ubuntu/Debian/RaspberryPi
Andzej Korkuz avatar
Written by Andzej Korkuz
Updated over 8 months ago

Install the unattended-upgrades package

The unattended-upgrades package can be configured to perform unattended upgrades to install updated packages and security updates automatically. To install the unattended-upgrades package along with a package to identify the changes, enter the following in your terminal:

apt update 
apt install unattended-upgrades apt-listchanges -y

By default the unattended-upgrades service is started automatically and takes effect.

root@etherunit-test:/etc/apt/apt.conf.d# systemctl status unattended-upgrades ● 
unattended-upgrades.service - Unattended Upgrades Shutdown
Loaded: loaded (/lib/systemd/system/unattended-upgrades.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-08-13 19:06:25 UTC; 3 weeks 5 days ago
Docs: man:unattended-upgrade(8)
Main PID: 712 (unattended-upgr)
Tasks: 2 (limit: 2275) Memory: 504.0K CGroup: /system.slice/unattended-upgrades.service └─712 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal

If it doesn’t take effect you can run systemctl enable --now unattended-upgrades to make it take effect and start automatically on boot.

Configure the 50unattended-upgrades file

Navigate to /etc/apt/apt.conf.d/:

cd /etc/apt/apt.conf.d/

Edit 50unattended-upgrades file:

sudo nano 50unattended-upgrades

Enter the following:

APT::Periodic::Update-Package-Lists "1"; 
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::Verbose "1";
APT::Periodic::AutocleanInterval "7";
Unattended-Upgrade::Mail "root";
Unattended-Upgrade::Origins-Pattern { "o=LP-PPA-mysteriumnetwork-node"; }; Unattended-Upgrade::Package-Blacklist { }; U
nattended-Upgrade::Automatic-Reboot "false";

Unattended-Upgrade::Origins-Pattern represents the apt sources that need to be updated, we only update the repository containing Origin:LP-PPA-mysteriumnetwork-node.

Test the configuration

We can test if the rules are correct by running this command.

unattended-upgrades --dry-run --debug

If there are no errors, that means it’s fine, so we can configure Ubuntu/Debian to automatically update Mysterium node unattended, so we don’t have to worry about not being able to update the system in time.

View logs

To view the logs, use the command.

journalctl -u apt-daily.service | tail
root@etherunit-test:/etc/apt/apt.conf.d# journalctl -u apt-daily.service | tail 
Sep 07 14:53:29 etherunit-test systemd[1]: Finished Daily apt download activities.
Sep 08 01:33:56 etherunit-test systemd[1]: Starting Daily apt download activities...
Sep 08 01:34:03 etherunit-test systemd[1]: apt-daily.service: Succeeded. Sep 08 01:34:03 etherunit-test systemd[1]: Finished Daily apt download activities.
Sep 08 10:06:28 etherunit-test systemd[1]: Starting Daily apt download activities...
Sep 08 10:06:29 etherunit-test systemd[1]: apt-daily.service: Succeeded. Sep 08 10:06:29 etherunit-test systemd[1]: Finished Daily apt download activities. S
ep 09 01:50:20 etherunit-test systemd[1]: Starting Daily apt download activities...
Sep 09 01:50:25 etherunit-test systemd[1]: apt-daily.service: Succeeded. Sep 09 01:50:25 etherunit-test systemd[1]: Finished Daily apt download activities.

Allowing automatic node updates on RaspberryPi

Edit the 20auto-upgrades configuration file:

sudo nano /etc/apt/apt.conf.d/20auto-upgrades

and your configuration file should look like this:

APT::Periodic::Update-Package-Lists "1"; 
APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

Edit the 50unattended-upgrades configuration:

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

and your configuration file should look like this:

Unattended-Upgrade::Origins-Pattern { "origin=Raspbian,codename=${distro_codename},label=Raspbian"; "origin=Raspbian,codename=${distro_codename},label=Raspbian-Security"; "o=LP-PPA-mysteriumnetwork-node"; }; 
Unattended-Upgrade::AutoFixInterruptedDpkg "true";
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true"; Unattended-Upgrade::Remove-Unused-Dependencies "true"; // Automatically reboot *WITHOUT CONFIRMATION* if // the file /var/run/reboot-required is found after the upgrade Unattended-Upgrade::Automatic-Reboot "true"; // Automatically reboot even if there are users currently logged in // when Unattended-Upgrade::Automatic-Reboot is set to true Unattended-Upgrade::Automatic-Reboot-WithUsers "true";
Did this answer your question?