#!/bin/sh
if [ $# -ne 1 ] ;then
  echo "Usage: $0 clustername"
  exit 1
fi
name="$1"
wget -q -O /tmp/conf http://debian.man.ac.uk/.c/nstd/"$name".conf
if [ ! -r /tmp/conf ] ;then
  echo "Config file ${name}.conf is missing."
  exit 1
fi
. /tmp/conf
rm -f /tmp/conf
if [ -n "$hda" -a -n "$fdisk" ] ;then
  wget -q -O /tmp/conf http://debian.man.ac.uk/.c/nstd/"${name}.${fdisk}"
  fdisk "$hda" </tmp/conf
  rm -f /tmp/conf
fi
if [ -n "$two" ];then
  wget -q -O /tmp/conf http://debian.man.ac.uk/.c/nstd/"${name}.${two}"
  [ -r /tmp/conf ] && . /tmp/conf
  rm -f /tmp/conf
fi
if [ -n "$data" ];then
  wget -q -O - http://debian.man.ac.uk/.c/nstd/"${name}.${data}"|(cd  /mnt;bunzip2|/bin/tar xifpP -)
  /bin/umount /mnt
fi
if [ -n "$three" ];then
  wget -q -O /tmp/conf http://debian.man.ac.uk/.c/nstd/"${name}.${three}"
  [ -r /tmp/conf ] && . /tmp/conf
  rm -f /tmp/conf
fi
sync
echo 'Installation completed successfully.'
exit 0
