#!/bin/bash

echo '

### README ### <=========================================================================================> ###
### README ### <============ WWW.NEWTONPMTA.COM - Interspire & PowerMTA Version ==============> ###
### README ### <=========================================================================================> ###

' 

echo "Installing NewtonPMTA Interspire Version, Preparing folders please wait ... "

chmod 777 newtonpmta/ -R
mv newtonpmta / 
cd /newtonpmta/newtonpmta-scripts/
chmod 777 ./interspireinstaller6.sh
chmod 777 ./interspireinstaller7.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 6 or 7 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

Release6=`cut -d " " -f 3 /etc/redhat-release | cut -d "." -f 1`
Release7=`cut -d " " -f 4 /etc/redhat-release | cut -d "." -f 1`
	if [ $Release6 == 6 ]
	then
		echo "CentOS 6 64Bit detected, initiating installation ... "
		./interspireinstaller6.sh
		elif [ $Release7 == 7 ]
	then
		echo "CentOS 7 64Bit detected by starting installation ... "
		./interspireinstaller7.sh
	else
		echo "CentOS detected unsupported, canceled installation ! "
		echo "Reinstall the operating system with CentOS 6 or 7 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

