Auto update Ubuntu PXE files

Update script

#!/bin/bash

MIRROR=http://archive.ubuntu.com/ubuntu/dists/SUITE/main/installer-ARCH/current/images/netboot/ubuntu-installer/ARCH
TFTPDIR=/var/lib/tftpboot/ubuntu/SUITE/ARCH

download() {
  SUITE=$1
        ARCH=$2
  FILE=$3
  
  echo -n "    - $3"

  MIRROR1=${MIRROR//SUITE/$SUITE}
  MIRROR_TMP=${MIRROR1//ARCH/$ARCH}

  TFTPDIR1=${TFTPDIR//SUITE/$SUITE}
  TFTPDIR_TMP=${TFTPDIR1//ARCH/$ARCH}

  if [ ! -d $TFTPDIR_TMP ]; then
    mkdir -p $TFTPDIR_TMP
  fi
  
  wget --quiet $MIRROR_TMP/$FILE -O $TFTPDIR_TMP/$FILE

  if [ $? == 0 ]; then
    printf "%20s\n" "OK"
  else
    printf "%20s\n" "ERROR"
    echo "$MIRROR_TMP/$FILE"
  fi
}

echo "Update Ubuntu netboot files:"
for SUITE in oneiric precise quantal; do
  echo "+ $SUITE"

  for ARCH in i386 amd64; do
    echo "  + $ARCH"
  
    for FILE in linux initrd.gz; do
      download $SUITE $ARCH $FILE
    done
  done
done
>

Create cronjob

#!/bin/sh

echo "update.ubuntu.pxe.files.cronjob $(date -I)" > /var/log/update.ubuntu.pxe.files.log

wget --quiet https://raw.github.com/panticz/preseed/master/pxe/scripts/update.ubuntu.pxe.files.sh -O - | bash -
>

Configure PXE
wget https://installit.googlecode.com/hg/preseed/preseed.precise.i386.conf -O /var/lib/tftpboot/pxelinux.cfg/preseed.precise.i386.conf
wget https://installit.googlecode.com/hg/preseed/preseed.precise.amd64.conf -O /var/lib/tftpboot/pxelinux.cfg/preseed.precise.amd64.conf
wget https://installit.googlecode.com/hg/preseed/preseed.quantal.i386.conf -O /var/lib/tftpboot/pxelinux.cfg/preseed.quantal.i386.conf
wget https://installit.googlecode.com/hg/preseed/preseed.quantal.amd64.conf -O /var/lib/tftpboot/pxelinux.cfg/preseed.quantal.amd64.conf

vi /var/lib/tftpboot/default
MENU SEPARATOR
MENU BEGIN
MENU TITLE + Preseed
    MENU INCLUDE pxelinux.cfg/preseed.oneiric.i386.conf
    MENU INCLUDE pxelinux.cfg/preseed.oneiric.amd64.conf
    MENU INCLUDE pxelinux.cfg/preseed.precise.i386.conf
    MENU INCLUDE pxelinux.cfg/preseed.precise.amd64.conf
    MENU INCLUDE pxelinux.cfg/preseed.quantal.i386.conf
    MENU INCLUDE pxelinux.cfg/preseed.quantal.amd64.conf
 
    MENU SEPARATOR
    LABEL Back
    MENU EXIT
MENU END