ubuntu-dev-tools/ubuntu-sync
2007-07-17 09:01:45 +10:00

106 lines
2.4 KiB
Bash
Executable File

#!/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=0
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
;;
-g)
Image_Sets="${Image_Sets} gobuntu"
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 gobuntu"
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="desktop server serveraddon"
elif [ "${Current_Set}" == "ubuntu-server" ]; then
Flavors="server"
elif [ "${Current_Set}" == "gobuntu" ]; then
Flavors="alternate"
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 [ "${flavor}" == "desktop" ]; then
Is_Desktop=-live
fi
if [ "${arch}" == "powerpc" ]; then
Is_Ports=ports
fi
if rsync --partial-dir="${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}/.partial" "rsync://cdimage.ubuntu.com/cdimage/${Origin}/${Is_Ports}/daily${Is_Desktop}/current/${Dist}-${flavor}-${arch}.iso" "${Dist}-${flavor}-${arch}.iso" ; then
date > "${flavor}-${arch}-sync"
fi
unset Is_Desktop
unset Is_Ports
done
done
done
rm /tmp/ubuntu-sync.01532-lock