#!/bin/bash
#
# 7 Mar 2013 Mike Gore
# This script downloads Daily snapshots of Ubuntu and places them
# in two local repositories
# One is for PXE tftpbooting and live images, the other is for public CDROM burning
#
# Daily ISO Builds can be found here
MIRROR=http://cdimage.ubuntu.com/daily-live/current/
# Output directory for PUBLIC
TARGET=/images/rawiso/Ubuntu
# PXE/TFTPBOOT Liveboot ISO images on ASIMOV
TFTP_ISO=/tftpboot/pxes/iso
# Parse the Current Web page at the daily snapshot repository
# Daily Release Title
DAILYREL=`wget http://cdimage.ubuntu.com/daily-live/current/ -O - 2>/dev/null | grep "
Ubuntu.*Daily Build" | sed -e "s/[ ]*<[/]*title>//g"`
# Daily Release Full Name
RELNAME=`echo $DAILYREL | sed -e "s/^.*[(]//" | sed -e "s/[)].*$//"`
# Daily Release Short Name - inb lower case
RELSHORT=`echo $RELNAME | sed -e "s/ .*$//" | tr A-Z a-z`
# Release
RELEASE=$RELSHORT
# What version types we want
DISTS="desktop-amd64 desktop-i386 desktop-amd64+mac"
# File Extensions
TYPES="iso list manifest metalink"
# Echo a command and all its arguments - then run it
echo_run()
{
echo $@
$@
}
get()
{
# -N time stamping - we only download if newer
# -nH no Host directory prefix
# -q quiet
echo_run wget -q -nH -N $MIRROR/$1
}
cd "$TARGET"
if [ "`pwd`" != "$TARGET" ]
then
echo "$0 Error: can not change to $TARGET"
exit 1
fi
echo =====================================
echo "Fetching $RELEASE from $MIRROR"
echo "Daily Release Title: $DAILYREL"
echo "Daily Release Name: $RELNAME"
echo "Daily Release short name: $RELSHORT"
echo Start: `date`
echo =====================================
for i in $DISTS
do
ISO=$RELEASE-$i
echo =====================================
for j in $TYPES
do
echo Fetching $ISO.$j from $MIRROR
get $ISO.$j
chown cscf-adm:smbadm $ISO.$j
chmod g+w $ISO.$j
done
echo Copy $ISO.iso over to liveboot area on ASIMOV
echo_run rsync -au $ISO.iso $TFTP_ISO
done
echo =====================================
echo "End: `date`"
echo =====================================
# Restart tftpboot/pxes liveboot service
echo_run service tftpbootiso restart