Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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.manifest 2>/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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement