Ubuntu MATE daily iso painless update script

As you may know, Ubuntu MATE 21.04 is coming soon (in about 3 months) and you can already test the daily *.iso images in order to help the devs or tinker with new features.

"Problem" is, the ISO is updated daily and it can be a hassle to download ~2.5-2.8gb every day if you have a bandwidth limit or crappy internet. Luckily, there's a little utility called zsync that allows you to update your current iso with the new content from the latest one.

So how does Zsync work ?

  • Download the Ubuntu MATE daily ISO
    Grab hirsute-desktop-amd64.iso from the daily Ubuntu MATE 21.04 website or if you prefer with a terminal:
    wget https://cdimage.ubuntu.com/ubuntu-mate/daily-live/current/hirsute-desktop-amd64.iso
  • Install zsync with sudo apt install -y zsync
  • Move your iso to a folder you'd like to use for this purpose, for example ~/Downloads/umdaily/.
  • Once a new iso is available, move to that folder, in this case cd ~/Downloads/umdaily/ and then use zsync -i *.iso http://cdimage.ubuntu.com/ubuntu-mate/daily-live/current/hirsute-desktop-amd64.iso.zsync to update your iso to the newest one. Once complete, the old iso will be renamed with a *.zs-old extension.

As I'm quite lazy I decided to make a little script to automate the process with a bash script:
1 - Install Zsync if not already done:
sudo apt install -y zsync
2 - Creating the testing ISO folder:
First, In order to use the script you need to create the folder used for that sole purpose where your daily Ubuntu MATE iso will be stored/modified.
3 - Editing the script:
Then At the top of the script, there are two variables. FOLDER and CODENAME.
You need to edit the path from the FOLDER variable with the directory chosen for your isos. Default is /home/user/Documents/umdailyiso/.
The CODENAME one allows you to be lazy in the future with the next testing windows. Let's say, if Ubuntu 21.10 is named inestimable iguana for instance, just replace hirsute with inestimable and it will download the right iso. hirsute (21.04) is the default at the time of this post.
4 - Saving the script and making it executable:
Then, save the content of the script to a file, save it as zsum for example. Store it with your other scripts.
Then you need to make it executable (chmod +x zsum in the folder it's located in or right click on the file, properties, permissions and tick the case to allow it to be executed as a program).
To run it, open a terminal in the folder where the script is stored and type ./zsum
5 - Achieving the pinnacle of laziness with a .bashrc alias:
If you want to make it easier, add it to your .bashrc aliases.
To do so, edit your .bashrc file (pluma ~/.bashrc or nano ~/.bashrc) and at the bottom with the other aliases add this one:
zsum='/path/to/your/script'
Edit it of course with the path to your script, for example /home/yourname/Documents/scripts/zsum then save it, open a terminal and enter source ~/.bashrc.
Now, when you type zsum in a terminal, it will download/update your daily Ubuntu MATE iso in the folder specified in the script.

The script itself:

#!/bin/bash

#  Ubuntu MATE daily iso updater
FOLDER='/home/user/Documents/umdailyiso/'
CODENAME='hirsute'

function noiso()
{
echo 'Ubuntu MATE daily iso not found...'
echo 'Downloading the latest Ubuntu MATE daily iso...'
cd $FOLDER
wget https://cdimage.ubuntu.com/ubuntu-mate/daily-live/current/$CODENAME-desktop-amd64.iso
echo 'Download complete.'
}

function iso()
{
echo 'Ubuntu MATE daily iso spotted...'
echo 'Updating the daily Ubuntu MATE iso...'
cd $FOLDER
zsync -i *.iso http://cdimage.ubuntu.com/ubuntu-mate/daily-live/current/$CODENAME-desktop-amd64.iso.zsync
echo 'Update complete.'
echo 'Deleting previous iso...'
rm *-old
}

if [ $(cd $FOLDER && ls *.iso | grep -sw $CODENAME | wc -l) = "0" ] ; then
  noiso
elif [ $(cd $FOLDER && ls *.iso | grep -sw $CODENAME | wc -l) = "1" ] ; then
  iso
else 
  exit
fi

Note: comment the rm *-old line if you want to keep the previous daily iso.

Have fun !

7 Likes

I have a single line alias to update my zsync's for each iso I use:

alias zsynck="cd /media/vmc/xSSD/ISO && zsync -i kubuntu.iso http://cdimage.ubuntu.com/kubuntu/daily-live/current/hirsute-desktop-amd64.iso.zsync -o kubuntu.iso"
alias zsyncm="cd /media/vmc/xSSD/ISO && zsync -i mate.iso http://cdimage.ubuntu.com/ubuntu-mate/daily-live/current/hirsute-desktop-amd64.iso.zsync -o mate.iso"
alias zsyncu="cd /media/vmc/xSSD/ISO && zsync -i ubuntu.iso http://cdimage.ubuntu.com/daily-live/pending/hirsute-desktop-amd64.iso.zsync -o ubuntu.iso"
alias zsyncx="cd /media/vmc/xSSD/ISO && zsync -i xubuntu.iso http://cdimage.ubuntu.com/xubuntu/daily-live/current/hirsute-desktop-amd64.iso.zsync -o xubuntu.iso"
alias zsyncl="cd /media/vmc/xSSD/ISO && zsync -i lubuntu.iso http://cdimage.ubuntu.com/lubuntu/daily-live/current/hirsute-desktop-amd64.iso.zsync -o lubuntu.iso"
I "cd" to iso location to remove "old". Also look at sizes to see if increase/decrease.

Then in my "grub.cfg" I have a ISO loopback menu to load or install any of the Ubuntu's iso's:

menuentry "ISO" {
rmmod tpm
set isofile="/ISO/ubuntu.iso"
loopback loop (hd1,1)$isofile
linux (loop)/casper/vmlinuz boot=casper toram maybe-ubiquity iso-scan/filename=$isofile noprompt noswap noeject
initrd (loop)/casper/initrd
}

Then I just edit the grub.cfg set isofile to the one I want to boot, for either checking, testing, installing.

2 Likes