#!/bin/bash

#Written by Marcos F. - (marcos.f@hostdime.com) on March 26, 2009
#This script is meant to grab VPS template files (for both template and samples) from the corp server and update the ones running on the node with the most up-to-date versions.


#Change to the directory which contains the VPS template file.
cd /vz/template/cache

#Check to see if the template file already exists in that directory.
#If it does, the existing version will be removed and replaced with the most recent version from the corp server.
if [ -f "centos-5.2-i386-cpanel.tar.gz" ];
        then
                rm -rf "centos-5.2-i386-cpanel.tar.gz"
                wget http://hostdime.com/res/vps_templates/centos-5.2-i386-cpanel.tar.gz

        else
                wget http://hostdime.com/res/vps_templates/centos-5.2-i386-cpanel.tar.gz
fi

#Change to the directory which contains the VPS sample file.
cd /etc/sysconfig/vz-scripts


#Check to see if the VPS1 (vps.low) sample file already exists in that directory.
#If it does, the existing version will be removed and replaced with the most recent version from the corp server.
if [ -f "ve-vps.low.conf-sample" ];
        then
                rm -rf "ve-vps.low.conf-sample"
                wget http://hostdime.com/res/vps_templates/ve-vps.low.conf-sample
        else
                wget http://hostdime.com/res/vps_templates/ve-vps.low.conf-sample
fi


#Check to see if the VPS2 (vps.medium) sample file already exists in that directory.
#If it does, the existing version will be removed and replaced with the most recent version from the corp server.
if [ -f "ve-vps.medium.conf-sample" ];
        then
                rm -rf "ve-vps.medium.conf-sample"
                wget http://hostdime.com/res/vps_templates/ve-vps.medium.conf-sample
        else
                wget http://hostdime.com/res/vps_templates/ve-vps.medium.conf-sample
fi


#Check to see if the VPS3 (vps.high) sample file already exists in that directory.
#If it does, the existing version will be removed and replaced with the most recent version from the corp server.
if [ -f "ve-vps.high.conf-sample" ];
        then
                rm -rf "ve-vps.high.conf-sample"
                wget http://hostdime.com/res/vps_templates/ve-vps.high.conf-sample
        else
                wget http://hostdime.com/res/vps_templates/ve-vps.high.conf-sample
fi
