ubuntu-dev-tools/ubuntu-sync

92 lines
2.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
set -e
# Syncronise new ubuntu CD images, depending on command-line flags given.
# If none are given, sync all images.
if [ -e /tmp/ubuntu-sync.01532-lock ]; then
echo "Another copy of the script is running."
exit 1
fi
Ubuntu_Distro_Dir="$HOME/distros/ubuntu"
Dist=gutsy
# Only sync the oldest images, and only i386 images if low bandwidth.
Low_Bandwidth=1
while [ -n "$1" ]; do
case "$1" in
-u)
Image_Sets="${Image_Sets} ubuntu"
break
;;
-k)
Image_Sets="${Image_Sets} kubuntu"
break
;;
-e)
Image_Sets="${Image_Sets} edubuntu"
break
;;
-x)
Image_Sets="${Image_Sets} xubuntu"
break
;;
-s)
Image_Sets="${Image_Sets} ubuntu-server"
break
;;
esac
shift || true
done
if [ "${Low_Bandwidth}" == 1 ] && [ "${Image_Sets}" == "" ]; then
cd "${Ubuntu_Distro_Dir}"
Image_Sets=`ls -td1 */"${Dist}" | tail -1 | cut -f 1 -d /`
elif [ "${Low_Bandwidth}" == 0 ] && [ "${Image_Sets}" == "" ]; then
Image_Sets="ubuntu xubuntu ubuntu-server edubuntu kubuntu"
fi
# Sync images.
if [ ! -e /tmp/ubuntu-sync.01532-lock ]; then
touch /tmp/ubuntu-sync.01532-lock
fi
for Current_Set in ${Image_Sets}
do
mkdir -p "${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}"/.partial
cd "${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}"
# Figure out remote path
if [ "${Current_Set}" == "ubuntu" ]; then
Origin=""
else
Origin="${Current_Set}"
fi
# Which flavors to download
if [ "${Current_Set}" == "edubuntu" ]; then
Flavors="install live"
elif [ "${Current_Set}" == "ubuntu-server" ]; then
Flavors="server live"
else
Flavors="alternate desktop"
fi
# Which archs to download
if [ "${Low_Bandwidth}" == 0 ]; then
Archs="i386 powerpc"
#Archs="i386 amd64 powerpc"
else
Archs="i386"
fi
for arch in $Archs; do
for flavor in $Flavors; do
if rsync --partial-dir="${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}/.partial" "rsync://cdimage.ubuntu.com/cdimage/${Origin}/daily/current/${Dist}-${flavor}-${arch}.iso" "${Dist}-${flavor}-${arch}.iso" ; then
date > "${flavor}-${arch}-sync"
fi
done
done
done
rm /tmp/ubuntu-sync.01532-lock