Skip to content

Instantly share code, notes, and snippets.

@apinter
Created August 18, 2022 06:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apinter/c0143784347dfc9cab0f82bd546792a5 to your computer and use it in GitHub Desktop.
Save apinter/c0143784347dfc9cab0f82bd546792a5 to your computer and use it in GitHub Desktop.
Automated tool/distrobox upgrade with systemd

Create the update script, nothing fancy. Save it under $HOME/bin. Make it executable.

#!/bin/bash

set -e 
echo ================================================================
echo "Updating the TW box"
echo ================================================================
distrobox-enter tw2 -- sudo zypper ref
distrobox-enter tw2 -- sudo zypper dup -y
echo ================================================================
echo "Updating the Ubuntu box"
echo ================================================================
distrobox-enter ubuntu-box -- sudo apt update 
distrobox-enter ubuntu-box -- sudo apt upgrade -y
echo ================================================================
echo "Updating the Fedora box"
echo ================================================================
distrobox-enter fedora-box -- sudo dnf upgrade -y
echo ================================================================
echo "Updating the Arch box"
echo ================================================================

Create the service: $HOME/.config/systemd/system/update-user-distrobox.service

[Unit]
Description=Update user distroboxes

[Service]
Type=oneshot
ExecStart=/home/apinter/bin/ddup

[Install]
WantedBy=default.target

Create the timer: $HOME/.config/systemd/system/update-user-distrobox.timer

[Unit]
Description=Update user distroboxes daily

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target

Enable timer: systemctl --user daemon-reload && systemctl --user enable --now update-user-distrobox.timer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment