A script I wrote to quickly download the daily builds

Jeff Stone stone1343 at gmail.com
Thu Aug 26 22:11:09 UTC 2010


I hope this is appropriate to share here, I've written the following script
to help download daily builds. I call it zsync-ubuntu-daily-live. As it is
right now, if you execute it with no parameters, it will automatically
download the ubuntu and ubuntu-netbook daily build, but it also supports
kubuntu and xubuntu. Extending it for other *buntus is straightforward.
First it checks for a new build by comparing the timestamp of MD5SUMS. If
there's a new build, it will use zsync or wget as appropriate. You need the
zsync package installed.

#!/usr/bin/env bash

# function
zsync-one-iso () {
if [ "$1" == "ubuntu" ]; then
      WEBDIR=""
      ISONAME="maverick-desktop-i386"
   elif [ "$1" == "kubuntu" ]; then
      WEBDIR="kubuntu/"
      ISONAME="maverick-desktop-i386"
   elif [ "$1" == "xubuntu" ]; then
      WEBDIR="xubuntu/"
      ISONAME="maverick-desktop-i386"
   elif [ "$1" == "ubuntu-netbook" ]; then
      WEBDIR="ubuntu-netbook/"
      ISONAME="maverick-netbook-i386"
   else
      echo "$0 [ubuntu|kubuntu|xubuntu|ubuntu-netbook]"
      exit 1
   fi

   WEBDIR=$WEBDIR"daily-live/current"

   if [ ! -d ~/Downloads/$1 ]; then
      mkdir -p ~/Downloads/$1
   fi
   cd ~/Downloads/$1

   # phase 1
   if [ "$2" == 1 ]; then
      # Get MD5SUMS, keeping the previous version
      if [ -e MD5SUMS ]; then
         if [ -e MD5SUMS.prv ]; then
            rm MD5SUMS.prv
         fi
         mv MD5SUMS MD5SUMS.prv
      fi
      wget http://cdimage.ubuntu.com/$WEBDIR/MD5SUMS 2>/dev/null
      if [ ! -e MD5SUMS ]; then
         echo "WGET did not get MD5SUMS"
         if [ -e MD5SUMS.prv ]; then
            mv MD5SUMS.prv MD5SUMS
            exit 1
         fi
      fi

      # This check also succeeds if MD5SUMS.prv doesn't exist
      if [ MD5SUMS -nt MD5SUMS.prv ]; then
         echo "Getting $1 ISO..."
         # Get the manifest and ISO
         if [ -e $ISONAME.manifest ]; then
            rm $ISONAME.manifest
         fi
         wget -N http://cdimage.ubuntu.com/$WEBDIR/$ISONAME.manifest2>/dev/null
         if [ -e $ISONAME.iso ]; then
            zsync http://cdimage.ubuntu.com/$WEBDIR/$ISONAME.iso.zsync
         else
            wget http://cdimage.ubuntu.com/$WEBDIR/$ISONAME.iso 2>/dev/null
         fi
      else
         echo "No new build for $1"
      fi
   # phase 2
   else
      echo "Checking $1 ISO..."
      # nice trick to skip other files in MD5SUMS besides $ISONAME
      cat MD5SUMS | grep $ISONAME | md5sum -c
   fi
}

# main

# call the function for phase 1 (get ISO)
if [ -z "$1" ]; then
   zsync-one-iso "ubuntu" 1
   zsync-one-iso "ubuntu-netbook" 1
   # zsync-one-iso "kubuntu" 1
   # zsync-one-iso "xubuntu" 1
else
   zsync-one-iso $1 1
fi

# call the function for phase 2 (check ISO)
if [ -z "$1" ]; then
   zsync-one-iso "ubuntu" 2
   zsync-one-iso "ubuntu-netbook" 2
   # zsync-one-iso "kubuntu" 2
   # zsync-one-iso "xubuntu" 2
else
   zsync-one-iso $1 2
fi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-quality/attachments/20100826/90cd1782/attachment.html>


More information about the Ubuntu-qa mailing list