个人工具

“UbuntuHelp:RsyncCdImage”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第9行: 第9行:
 
A number of the Ubuntu servers also work as rsync servers with quite similar URIs to the websites.  For example:
 
A number of the Ubuntu servers also work as rsync servers with quite similar URIs to the websites.  For example:
 
<pre><nowiki>
 
<pre><nowiki>
rsync -zhhP rsync://cdimage.ubuntu.com/cdimage/daily-live/current/hardy-desktop-i386.iso .
+
rsync -zhhP rsync://cdimage.ubuntu.com/cdimage/daily-live/current/intrepid-desktop-i386.iso .
 
</nowiki></pre>
 
</nowiki></pre>
will sync the server's daily Hardy 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 (not in Dapper (2.6.6) though), and -P is a progress indicator.
+
will sync the server's daily Intrepid 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 (not in Dapper (2.6.6) though), and -P is a progress indicator.
 
'''Note:''' If you are using other flavors of Ubuntu don't forget to add the flavor's name in the rsync-path after cdimage/, e.g.
 
'''Note:''' If you are using other flavors of Ubuntu don't forget to add the flavor's name in the rsync-path after cdimage/, e.g.
 
<pre><nowiki>
 
<pre><nowiki>
rsync -zhhP rsync://cdimage.ubuntu.com/cdimage/kubuntu/daily-live/current/hardy-desktop-i386.iso .
+
rsync -zhhP rsync://cdimage.ubuntu.com/cdimage/kubuntu/daily-live/current/intrepid-desktop-i386.iso .
 
</nowiki></pre>
 
</nowiki></pre>
 
A slightly more advanced script will automate much of the syncing process.  To run this script successfully, you will need to set the ISO, DIR, and ISOPATH variables according to your needs.   
 
A slightly more advanced script will automate much of the syncing process.  To run this script successfully, you will need to set the ISO, DIR, and ISOPATH variables according to your needs.   
第20行: 第20行:
 
#!/bin/bash
 
#!/bin/bash
 
#Script for updating individual ISO image at cdimage.ubuntu.com (daily/current versions).
 
#Script for updating individual ISO image at cdimage.ubuntu.com (daily/current versions).
#Orginal script written by Henrik Omma, slightly adjusted by Bert Verhaeghe
+
#Orginal script written by Henrik Omma, slightly adjusted by Bert Verhaeghe, then a bit by Victor Van Hee
  
ISO="hardy-desktop-i386.iso"
+
# Change this next line to the directory where your previously downloaded iso image sits.
DIR="/data/software/iso-files/ubuntu/hardy"
+
DIR="/home/username/Desktop/intrepid"
ISOPATH="cdimage.ubuntu.com/cdimage/xubuntu/daily-live/current"
+
 
 +
# Choose only one of the iso files below and uncomment it
 +
ISO="intrepid-desktop-amd64.iso"
 +
# ISO="intrepid-desktop-i386.iso"
 +
# ISO="intrepid-alternate-amd64.iso"
 +
# ISO="intrepid-alternate-i386.iso"
 +
 
 +
# Uncomment the first line below for the Live CD, or the second one for the Alternate CD
 +
ISOPATH="cdimage.ubuntu.com/cdimage/daily-live/current"
 +
# ISOPATH="cdimage.ubuntu.com/cdimage/daily/current"
  
 
cd $DIR
 
cd $DIR
echo "###################"
 
echo "# rsync iso image #"
 
echo "###################"
 
rsync -avzhhP --progress rsync://$ISOPATH/$ISO $ISO
 
  
md5sum $ISO | sed -e "s/  / */" > $ISO.md5.local #create identical formatted md5sum file from local copy
+
md5sum $ISO | sed -e "s/  / */" > $ISO.md5.local  
wget http://$ISOPATH/MD5SUMS  
+
# ^ create identical formatted md5sum file from local copy
 +
echo ""
 +
echo "########################################"
 +
echo "# diff'ing MD5SUMs : local <-> server  #"
 +
echo "########################################"
 +
 
 +
wget -q http://$ISOPATH/MD5SUMS  
 
grep $ISO MD5SUMS > $ISO.md5.server
 
grep $ISO MD5SUMS > $ISO.md5.server
 
rm MD5SUMS
 
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 .
 +
else
 +
        echo ""
 +
        echo "MD5SUMs identical -- no need to Rsync"
 +
        echo ""
 +
        exit 0
 +
fi
 
echo ""
 
echo ""
 
echo "########################################"
 
echo "########################################"
 
echo "# diff'ing MD5SUMs : local <-> server  #"
 
echo "# diff'ing MD5SUMs : local <-> server  #"
 
echo "########################################"
 
echo "########################################"
 +
 +
md5sum $ISO | sed -e "s/  / */" > $ISO.md5.local
 
diff -q $ISO.md5.local $ISO.md5.server
 
diff -q $ISO.md5.local $ISO.md5.server
echo ""
+
 
 
if [ ! $? -eq "0" ]; then
 
if [ ! $? -eq "0" ]; then
 +
        echo ""
 
         echo "!!! MD5SUMs differ !!!"
 
         echo "!!! MD5SUMs differ !!!"
 +
echo "!!! Rsync failed!  !!!"
 
else
 
else
 +
        echo ""
 
         echo "MD5SUMs identical"
 
         echo "MD5SUMs identical"
 +
echo "SUCCESS!"
 
fi
 
fi
 +
echo ""
 
</nowiki></pre>
 
</nowiki></pre>
This script does two things.  First, it syncs your local ISO image to the most recent ISO image on the Ubuntu servers.  It then creates files containing the MD5SUMs of both the local and server images, and outputs if the MD5SUMs are identical or not.   
+
This script does three things.  First, it creates files containing the MD5SUMs of both the current local and server images, and outputs if the MD5SUMs are identical or not. If they are not identical, it syncs your local ISO image to the most recent ISO image on the Ubuntu servers.  It then rechecks the new local MD5SUM and compares it to the server image, and outputs if the MD5SUMs are identical or not.   
 
[[category:CategoryDocumentation]]
 
[[category:CategoryDocumentation]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2008年10月19日 (日) 17:10的版本

rsync is a wonderful piece of software that only downloads the parts of a file that have changed. https://launchpad.net/products/rsync is a good resource for more information. 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 rsync. Since the daily CDs generally change quite little, it can be processed quite quickly.

Acquiring the ISO

The various files that you need are at http://cdimage.ubuntu.com It's best to use the torrent file if you can. 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.

Updating the ISO

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/intrepid-desktop-i386.iso .

will sync the server's daily Intrepid 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 (not in Dapper (2.6.6) though), and -P is a progress indicator. Note: If you are using other flavors of Ubuntu don't forget to add the flavor's name in the rsync-path after cdimage/, e.g.

rsync -zhhP rsync://cdimage.ubuntu.com/cdimage/kubuntu/daily-live/current/intrepid-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 ISO, DIR, and ISOPATH variables according to your needs.

#!/bin/bash
#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

# Change this next line to the directory where your previously downloaded iso image sits.
DIR="/home/username/Desktop/intrepid"

# Choose only one of the iso files below and uncomment it
ISO="intrepid-desktop-amd64.iso"
# ISO="intrepid-desktop-i386.iso"
# ISO="intrepid-alternate-amd64.iso"
# ISO="intrepid-alternate-i386.iso"

# Uncomment the first line below for the Live CD, or the second one for the Alternate CD
ISOPATH="cdimage.ubuntu.com/cdimage/daily-live/current"
# ISOPATH="cdimage.ubuntu.com/cdimage/daily/current"

cd $DIR

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 "########################################"

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 .
else
        echo ""
        echo "MD5SUMs identical -- no need to Rsync"
        echo ""
        exit 0
fi
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 ""

This script does three things. First, it creates files containing the MD5SUMs of both the current local and server images, and outputs if the MD5SUMs are identical or not. If they are not identical, it syncs your local ISO image to the most recent ISO image on the Ubuntu servers. It then rechecks the new local MD5SUM and compares it to the server image, and outputs if the MD5SUMs are identical or not.