#!/usr/bin/csh
set ldmver = $1 # Pass the version of LDM to this script as an argument. 
echo "Starting the upgrade to LDM v. ${ldmver}"
cd /home/ldm
wget https://downloads.unidata.ucar.edu/ldm/${ldmver}/ldm-${ldmver}.tar.gz
gunzip -c ldm-${ldmver}.tar.gz | pax -r '-s:/:/src/:'
cd /home/ldm/ldm-${ldmver}/src
./configure
make install
cd /home/ldm
ldmadmin stop
echo "Removing runtime."
rm -f runtime
echo "Making a new soft-link to runtime."
ln -s ldm-${ldmver} runtime
echo "Upgrade to LDM v. ${ldmver} complete!"
echo "Cleaning up..."
ldmadmin clean
echo "Deleting the old queue."
ldmadmin delqueue
echo "Making the new queue."
ldmadmin mkqueue
echo "Starting a new log."
ldmadmin newlog
ldmadmin start
echo "Removing the .tar file."
rm /home/ldm/ldm-${ldmver}.tar.gz
echo "Upgrade to LDM v. ${ldmver} complete! Type ldmadmin watch to ensure the LDM is running."
