#!/bin/bash

echo '

### README ### <=========================================================================================> ###
### README ### <============ WWW.NEWTONPMTA.COM - Mailwizz ONLY Version  ## NO PMTA ## ==============> ###
### README ### <=========================================================================================> ###

' 

echo "Installing NewtonPMTA Mailwizz ONLY Version, Preparing folders please wait ... "

chmod 777 newtonpmta/ -R
mv newtonpmta / 
cd /newtonpmta/newtonpmta-scripts/
chmod 777 ./mailwizzonlyinstaller.sh

	if [ `/usr/bin/getconf LONG_BIT` != 64 ] 
	then 
		echo "Operating system installed on 32-bit, canceled installation ! "
		echo "Reinstall the operating system with CentOS 5 or 6 in 64 bits ! "
		exit
	fi

	if [ `grep -o CentOS /etc/redhat-release` != CentOS ]
	then 
		echo "CentOS not detected, canceled installation ! "
		echo "Reinstall the operating system with CentOS 6 64 bits ! "
		exit
	fi

Release=`cut -d " " -f 3 /etc/redhat-release | cut -d "." -f1`
	if [ $Release == 6 ]
	then
		echo "CentOS 6X 64Bits detected, initiating installation ... "
		./mailwizzonlyinstaller.sh
	else
		echo "CentOS detected unsupported, canceled installation ! "
		echo "Reinstall the operating system with CentOS 6 64 bits ! "
		echo "Cleaning installation ... " 

		ln -sf /dev/null /root/.bash_history
	rm -rf /root/1centosupdate.sh
rm -rf /root/2dnsupdate.sh
rm -rf /root/3repoupdate.sh
rm -rf /root/4dbintil.sh
rm -rf /root/5intrspr.sh
rm -rf /root/6ipconfig.sh
rm -rf /root/7coreupdate.sh
rm -rf /root/8mtamaster.sh
rm -rf /root/9proxysetup.sh
rm -rf /root/10dmarcsys.sh
rm -rf /root/11dkimpuyr.sh
rm -rf /root/12spfupdate.sh
rm -rf /root/NewtonPMTAv5.sh
rm -rf /root/installv5.sh
rm -rf /root/NPMTAInstallv5.sh
rm -rf /root/newtonpmtav5.zip
		rm -rf /tmp/*

		exit
	fi

echo "Cleaning installation ... " 

ln -sf /dev/null /root/.bash_history
rm -rf /root/1centosupdate.sh
rm -rf /root/2dnsupdate.sh
rm -rf /root/3repoupdate.sh
rm -rf /root/4dbintil.sh
rm -rf /root/5intrspr.sh
rm -rf /root/6ipconfig.sh
rm -rf /root/7coreupdate.sh
rm -rf /root/8mtamaster.sh
rm -rf /root/9proxysetup.sh
rm -rf /root/10dmarcsys.sh
rm -rf /root/11dkimpuyr.sh
rm -rf /root/12spfupdate.sh
rm -rf /root/NewtonPMTAv5.sh
rm -rf /root/installv5.sh
rm -rf /root/NPMTAInstallv5.sh
rm -rf /root/newtonpmtav5.zip

/sbin/shutdown -r now

