#!/bin/sh
ifconfig
read -p "Network Card Name(1/eth0,2/venet0,3/Entry Network Card): " Network_Card
if [ "${Network_Card}" == '1' ]; then
	Network="eth0"
elif [ "${Network_Card}" == '2' ]; then
	Network="venet0"
elif [ "${Network_Card}" == '3' ]; then
	read -p "Please Enter Network Card Name: " Network
else
    echo "Not Input Network Card!"
	exit 1;
fi
read -p "Is it OpenVZ Or Xen architecture?(1/yes,2/no): " is_OpenVZ
if [[ ! ${is_OpenVZ} =~ ^[1-2]$ ]]; then
    echo "OpenVZ Or Xen architecture?  Entry 1-2"
	exit 1;
fi
read -p "Install USA Mirrors?(1/CN,2/US,3/EU): " UsaMirrors
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
if [ "${UsaMirrors}" == '1' ]; then
	curl -o /etc/yum.repos.d/CentOS-Base.repo https://soft.shaobing.hk/CentOS/kernel/centos6-cn.repo
elif [ "${UsaMirrors}" == '2' ]; then
	curl -o /etc/yum.repos.d/CentOS-Base.repo https://soft.shaobing.hk/CentOS/kernel/centos6-us.repo
elif [ "${UsaMirrors}" == '3' ]; then
	curl -o /etc/yum.repos.d/CentOS-Base.repo https://soft.shaobing.hk/CentOS/kernel/centos6-eu.repo
else
        mv /etc/yum.repos.d/CentOS-Base.repo.backup /etc/yum.repos.d/CentOS-Base.repo
fi
yum makecache
echo "unset MAILCHECK">> /etc/profile
TZ='Asia/Shanghai';
rm /etc/sysconfig/clock -rf
echo 'ZONE="Asia/Shanghai"'>> /etc/sysconfig/clock
rm /etc/localtime -rf
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
yum install epel-release -y && yum install -y gcc build-essential tar
wget https://soft.shaobing.hk/Nginx/vnstat-1.18.tar.gz
tar -xvf vnstat-1.18.tar.gz
cd vnstat-1.18
mkdir /var/lib/vnstat
./configure
make && make install
cp examples/init.d/centos/vnstat /etc/init.d/ && chmod +x /etc/init.d/vnstat && chkconfig --add vnstat && chkconfig vnstat on
cd ../
vnstat -u -i $Network
service vnstat start
chkconfig vnstat on
sed -i "/^VNSTAT_OPTIONS=\"-u -i eth0\"/ c\VNSTAT_OPTIONS=\"-u -i ${Network}\"" /etc/sysconfig/vnstat
sed -i "/^Interface \"eth0\"/ c\Interface \"${Network}\"" /usr/local/etc/vnstat.conf
vnstat -u -i $Network
ln -s /usr/local/sbin/vnstatd /usr/sbin/vnstatd
service vnstat restart
yum install epel-release -y && yum install -y wget screen htop zip gcc unzip python libcurl-dev libcurl-devel openssl-devel c++ gcc gcc-c++ git yum-utils smartmontools intltool gcc gcc-c++ gcc-g77 gcc++ openssl-devel glibc-static libstdc++-static make automake autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel automake autoconf make gcc gcc-c++ libtool zlib zlib-devel curl curl-devel alsa-lib alsa-lib-devel gettext gettext-devel expat expat-devel build-essential openssl libssl-dev mercurial cpulimit centos-release-scl cmake3 hwloc-devel libmicrohttpd-devel openssl-devel devtoolset-4-gcc* xz tar nfs-utils portmap nfs4-acl-tools rpcbind portmap lsof
yum update -y
if [ "$is_OpenVZ" == '2' ] ; then
rpm -ivh http://soft.shaobing.hk/CentOS/kernel/kernel-ml-4.12.10-1.el6.elrepo.x86_64.rpm
sed -i '/^default=1/ c\default=0' /boot/grub/grub.conf
reboot
fi

