Wiki Ubuntu-it

Indice
Partecipa
FAQ
Wiki Blog
------------------
Ubuntu-it.org
Forum
Chiedi
Chat
Cerca
Planet
  • Pagina non alterabile
  • Informazioni
  • Allegati
  • Differenze per "FabioMarconi/prove2"
Differenze tra le versioni 17 e 18
Versione 17 del 01/04/2010 15.40.47
Dimensione: 6791
Commento:
Versione 18 del 13/04/2010 10.28.43
Dimensione: 6514
Commento:
Le cancellazioni sono segnalate in questo modo. Le aggiunte sono segnalate in questo modo.
Linea 64: Linea 64:
A slightly more advanced script will automate much of the syncing process. To run this script successfully, you will need to set the DIR variable according to your needs. You can set ISO inside the script or simply pass it in on the command-line (to make it easier to sync multiple ISO images). In some cases you may need to manually set ISOPATH if you're downloading an image not automatically detected. Assure you have "#!/bin/bash" as the first line of the script. A slightly more advanced script will automate much of the syncing process. To run this script successfully, you will need to set the DIR variable according to your needs. You can set ISO inside the script or simply pass it in on the command-line (to make it easier to sync multiple ISO images). In some cases you may need to manually set ISOPATH if you're downloading an image not automatically detected.
Linea 68: Linea 68:
#Script for updating individual ISO image at cdimage.ubuntu.com (daily/current versions).
#Orginal script written by Henrik Omma, slightly adjusted by Bert Verhaeghe, then a bit by Victor Van Hee
#Jeremy Yoder made it try to automatically pick an ISOPATH, adapted to lucid by Fabio Marconi.
# Copyright 2010 Aaditya Bhatia http://www.dragonsblaze.com/
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# See GNU General Public License at <http://www.gnu.org/licenses/>.
Linea 72: Linea 76:
# Change this next line to the directory where your previously downloaded iso image sits.
DIR="/home/USERNAME/Desktop/lucid"
# This script updates individual ISO image from cdimage.ubuntu.com via rsync
# Orginal script written by Henrik Omma, slightly adjusted by Bert Verhaeghe,
# then a bit by Victor Van Hee.
# Jeremy Yoder made it try to automatically pick an ISOPATH,
# adapted to karmic by Christian Bangerter.
# And then Aaditya pimped it up a little (curl, stdout text, md5 logic)
Linea 75: Linea 83:
# Choose only one of the iso files below and uncomment it
ISO="lucid-desktop-amd64.iso"
# ISO="lucid-desktop-i386.iso"
# ISO="lucid-alternate-amd64.iso"
# ISO="lucid-alternate-i386.iso"

# Uncomment the line below if you want a different image not listed below
# This is how you adjust the ISOPATH, in case you need to.
Linea 84: Linea 86:
# Default ISO to the first command-line parameter
if [ "$1" != "" ]; then
  ISO=$1
# If a command line argument is present, use that as ISO name
if [ -n "$1" -a $(expr "$1" : '.*\.iso$') -gt 4 ]; then
 ISO=`basename $1`;
 cd `dirname $1`;
else
 echo -e "\nUsage:\n\t$(basename $0) UBUNTU-IMAGE-FILENAME.iso\n";
 exit 1;
Linea 90: Linea 96:
  if [[ "$ISO" =~ "-desktop-" ]]; then
    ISOPATH="cdimage.ubuntu.com/cdimage/daily-live/current"
  elif [[ "$ISO" =~ "-alternate-" ]]; then
    ISOPATH="cdimage.ubuntu.com/cdimage/daily/current"
  elif [[ "$ISO" =~ "-dvd-" ]]; then
    ISOPATH="cdimage.ubuntu.com/cdimage/dvd/current"
  elif [[ "$ISO" =~ "-netbook-remix-" ]]; then
    ISOPATH="cdimage.ubuntu.com/cdimage/ubuntu-netbook-remix/daily-live/current"
  elif [[ "$ISO" =~ "-server-" ]]; then
    ISOPATH="cdimage.ubuntu.com/cdimage/ubuntu-server/daily/current"
  else
    echo "Unrecognized distribution, set ISOPATH manually"
    exit 1
 
fi
 if [[ "$ISO" =~ "-desktop-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/daily-live/current"
 elif [[ "$ISO" =~ "-alternate-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/daily/current"
 elif [[ "$ISO" =~ "-dvd-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/dvd/current"
 elif [[ "$ISO" =~ "-netbook-remix-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/ubuntu-netbook-remix/daily-live/current"
 elif [[ "$ISO" =~ "-server-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/ubuntu-server/daily/current"
 else
 echo "Unrecognized distribution, set \$ISOPATH manually"
 exit 2;
fi
Linea 106: Linea 112:
if [ ! -d $DIR ]; then
  echo "Sorry, $DIR does not exist"
  exit
curl -sI "http://$ISOPATH/$ISO" | head -1 | grep 200 > /dev/null;

if [ $? -eq 0 ]; then
 echo "Location: rsync://$ISOPATH/$ISO";
else
 echo "Not Found: http://$ISOPATH/$ISO";
 exit 2;
fi;


echo -n "Fetching latest md5sum from the server... "
curl -s http://$ISOPATH/MD5SUMS | grep $ISO > $ISO.md5
echo "done"

echo -n "Comparing local and server MD5SUMs... "
md5sum --status -c $ISO.md5

if [ $? -eq 0 ]; then
 echo "match!"
 echo "Local copy is up to date."
 rm $ISO.md5;
 exit 0
else
 echo "mismatch!"
 echo "Performing rsync..."
 rsync -avzhhP rsync://$ISOPATH/$ISO .
Linea 111: Linea 140:
cd $DIR echo -n "Comparing local and server MD5SUMs one more time... "
Linea 113: Linea 142:
md5sum $ISO | sed -e "s/ / */" > $ISO.md5.local
# ^ create identical formatted md5sum file from local copy
echo ""
echo "########################################"
echo "# diff'ing MD5SUMs : local <-> server #"
echo "########################################"
md5sum --status -c $ISO.md5
Linea 120: Linea 144:
wget -q http://$ISOPATH/MD5SUMS
grep $ISO MD5SUMS > $ISO.md5.server
rm MD5SUMS
diff -q $ISO.md5.local $ISO.md5.server

if [ ! $? -eq "0" ]; then
        echo ""
        echo "!!! MD5SUMs differ !!!"
        echo "...Performing rsync..."
        echo "###################"
        echo "# rsync iso image #"
        echo "###################"
        rsync -avzhhP rsync://$ISOPATH/$ISO .
if [ $? -eq 0 ]; then
 echo "match!"
 echo "Success!"
 rm $ISO.md5;
Linea 134: Linea 149:
        echo ""
        echo "MD5SUMs identical -- no need to Rsync"
        echo ""
        exit 0
 echo "mismatch!"
 echo "FAILED!"
 rm $ISO.md5;
 exit 2;
Linea 139: Linea 154:
echo ""
echo "########################################"
echo "# diff'ing MD5SUMs : local <-> server #"
echo "########################################"

md5sum $ISO | sed -e "s/ / */" > $ISO.md5.local
diff -q $ISO.md5.local $ISO.md5.server

if [ ! $? -eq "0" ]; then
        echo ""
        echo "!!! MD5SUMs differ !!!"
        echo "!!! Rsync failed! !!!"
else
        echo ""
        echo "MD5SUMs identical"
        echo "SUCCESS!"
fi
echo ""

BR Indice(depth=2 align=right)

Intro

zsync is a wonderful piece of software that downloads only the parts of a file that are changed, so as to avoid downloading a full copy everytime.

A nice thing about the way the Ubuntu CDs are constructed is that it's quite easy to keep an up to date local install CD using zsync. Since the daily CDs generally change quite little, it can be processed quite quickly. zsync also perform a checksum comparison making it possible to change the flavour of the ISO (e.g. you have an ISO of Ubuntu and you want to change it on Kubuntu. Simply copy/paste the right line for Kubuntu and it'll download just the parts that differs from the two versions).

Installing zsync

Install [apt://zsync zsync] package.

Acquiring the ISO

All Ubuntu's CD images are stored on http://cdimage.ubuntu.com. It's best to use the torrent file if you can.

Updating the ISO

Ubuntu archives provide .zsync files using quite similar URIs about the various flavours. For example:

zsync http://cdimage.ubuntu.com/daily-live/current/lucid-desktop-i386.iso.zsync

will sync the server's daily Lucid desktop image (for i386) to your local system with an older desktop image already stored on your hard drive.

Note 1: If you are using other flavours of Ubuntu don't forget to add the flavour's name in the rsync path after cdimage/, e.g.

zsync http://cdimage.ubuntu.com/kubuntu/daily-live/current/lucid-desktop-i386.iso.zsync

Note 2: If you are using another architecture don't forget to change i386 in the zsync path with the correct architecture name, e.g.

zsync http://cdimage.ubuntu.com/daily-live/current/lucid-desktop-amd64.iso.zsync

Updating with rsync instead

Another way to update your ISO is by using rsync. It's another implementation of the same algorithm that zsync uses, but it requires special software at the server end and it seems to be less efficient (require more data to be downloaded) for ISO images. https://launchpad.net/products/rsync is a good resource for more information. A number of the Ubuntu servers also work as rsync servers with quite similar URIs to the websites. For example:

rsync -zhhP rsync://cdimage.ubuntu.com/cdimage/daily-live/current/lucid-desktop-i386.iso .

will sync the server's daily Lucid desktop image (for i386) to your local system with an older desktop image already stored on your hard drive. -z is compression, -hh is human readable file size (in KB or MB), and -P is a progress indicator. If you have a local Ubuntu archive mirror or cache, you can also use Jigdo, rsync is handy for finishing up Jigdo downloads that still have a few missing pieces.

Note: If you are using other flavours of Ubuntu don't forget to add the flavour's name in the rsync path after cdimage/, e.g.

rsync -zhhP rsync://cdimage.ubuntu.com/cdimage/kubuntu/daily-live/current/lucid-desktop-i386.iso .

A slightly more advanced script will automate much of the syncing process. To run this script successfully, you will need to set the DIR variable according to your needs. You can set ISO inside the script or simply pass it in on the command-line (to make it easier to sync multiple ISO images). In some cases you may need to manually set ISOPATH if you're downloading an image not automatically detected.

#    Copyright 2010 Aaditya Bhatia http://www.dragonsblaze.com/
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    See GNU General Public License at <http://www.gnu.org/licenses/>.

# This script updates individual ISO image from cdimage.ubuntu.com via rsync
# Orginal script written by Henrik Omma, slightly adjusted by Bert Verhaeghe,
# then a bit by Victor Van Hee. 
# Jeremy Yoder made it try to automatically pick an ISOPATH,
# adapted to karmic by Christian Bangerter.
# And then Aaditya pimped it up a little (curl, stdout text, md5 logic)

# This is how you adjust the ISOPATH, in case you need to.
# ISOPATH="cdimage.ubuntu.com/cdimage/LOCATION/current"

# If a command line argument is present, use that as ISO name
if [ -n "$1" -a $(expr "$1" : '.*\.iso$') -gt 4 ]; then
 ISO=`basename $1`;
 cd `dirname $1`;
else
 echo -e "\nUsage:\n\t$(basename $0) UBUNTU-IMAGE-FILENAME.iso\n";
 exit 1;
fi

if [ "$ISOPATH" = "" ]; then
 if [[ "$ISO" =~ "-desktop-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/daily-live/current"
 elif [[ "$ISO" =~ "-alternate-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/daily/current"
 elif [[ "$ISO" =~ "-dvd-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/dvd/current"
 elif [[ "$ISO" =~ "-netbook-remix-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/ubuntu-netbook-remix/daily-live/current"
 elif [[ "$ISO" =~ "-server-" ]]; then
 ISOPATH="cdimage.ubuntu.com/cdimage/ubuntu-server/daily/current"
 else
 echo "Unrecognized distribution, set \$ISOPATH manually"
 exit 2;
 fi
fi

curl -sI "http://$ISOPATH/$ISO" | head -1 | grep 200 > /dev/null;

if [ $? -eq 0 ]; then
 echo "Location: rsync://$ISOPATH/$ISO";
else
 echo "Not Found: http://$ISOPATH/$ISO";
 exit 2;
fi;


echo -n "Fetching latest md5sum from the server... "
curl -s http://$ISOPATH/MD5SUMS | grep $ISO > $ISO.md5
echo "done"

echo -n "Comparing local and server MD5SUMs... "
md5sum --status -c $ISO.md5

if [ $? -eq 0 ]; then
 echo "match!"
 echo "Local copy is up to date."
 rm $ISO.md5;
 exit 0
else
 echo "mismatch!"
 echo "Performing rsync..."
 rsync -avzhhP rsync://$ISOPATH/$ISO .
fi

echo -n "Comparing local and server MD5SUMs one more time... "

md5sum --status -c $ISO.md5

if [ $? -eq 0 ]; then
 echo "match!"
 echo "Success!"
 rm $ISO.md5;
else
 echo "mismatch!"
 echo "FAILED!"
 rm $ISO.md5;
 exit 2;
fi

This script downloads MD5SUMs from the server, checks it against the local copy's MD5SUM. If they are not identical, it syncs the local ISO image to the most recent ISO image on the Ubuntu servers. Then it compares the new local MD5SUM against the server's copy again to check whether the sync process was successful diplaying the result.


CategoryHomepage