2007-03-27 20:23:31 +10:00
#!/bin/bash
2007-06-14 12:29:05 -07:00
set -e
2007-03-27 20:23:31 +10:00
# 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
2007-06-14 12:29:05 -07:00
Ubuntu_Distro_Dir="$HOME/distros/ubuntu"
2007-06-07 17:39:26 +02:00
Dist=gutsy
2007-03-27 20:23:31 +10:00
# Only sync the oldest images, and only i386 images if low bandwidth.
Low_Bandwidth=1
2007-06-14 12:29:05 -07:00
while [ -n "$1" ]; do
2007-03-27 20:23:31 +10:00
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
2007-06-14 12:29:05 -07:00
shift || true
2007-03-27 20:23:31 +10:00
done
if [ "${Low_Bandwidth}" == 1 ] && [ "${Image_Sets}" == "" ]; then
2007-06-14 12:29:05 -07:00
cd "${Ubuntu_Distro_Dir}"
Image_Sets=`ls -td1 */"${Dist}" | tail -1 | cut -f 1 -d /`
2007-03-27 20:23:31 +10:00
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
2007-06-14 12:29:05 -07:00
mkdir -p "${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}"/.partial
cd "${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}"
# Figure out remote path
2007-03-27 20:23:31 +10:00
if [ "${Current_Set}" == "ubuntu" ]; then
2007-06-14 12:29:05 -07:00
Origin=""
2007-03-27 20:23:31 +10:00
else
2007-06-14 12:29:05 -07:00
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"
2007-03-27 20:23:31 +10:00
fi
2007-06-14 12:29:05 -07:00
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
2007-03-27 20:23:31 +10:00
done
rm /tmp/ubuntu-sync.01532-lock