#!/bin/bash
#auto to install the software of soc
#created by piao.xiong
############################### Configured the network ##################################
function network()
{
Net_dir=/etc/sysconfig/network-scripts
cd $Net_dir
sed -e 's/IPADDR=[1-9][0-9]\{1,2\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/IPADDR=11.11.11.11/' ifcfg-eth3 > ifcfg-ethn
rm -rf ifcfg-eth3 && mv ifcfg-ethn ifcfg-eth3
sed -e 's/IPADDR=[1-9][0-9]\{1,2\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/IPADDR=192.168.1.100/' ifcfg-eth0 > ifcfg-ethm
rm -rf ifcfg-eth0 && mv ifcfg-ethm ifcfg-eth0
rm -rf /etc/resolv.conf && touch /etc/resolv.conf
echo -en "\033[32m [Network is OK]"
echo -e "\n"
service network restart
security
}
############################### Enforce the linux os ##################################
function enforce()
{
cd ~
if [ -e ~/centos_linux_security_enhence.sh ];then
bash centos_linux_security_enhence.sh
fi
return 2
}
function security()
{
enforce
# --------------- $? <==> the exit code
if [ $? -eq 2 ];then
nmap -v -A 192.168.1.100 >> /root/sec.tmp &
sleep 2
killall nmap
total=`grep -i 'Discovered open port 3306/tcp on 192.168.1.100' /root/sec.tmp |wc -l`
if [ $total -ge 1 ]; then
rm -rf /root/sec.tmp
jdk
else
echo "enforce the linux'os fail"
fi
fi
############################### Install jdk enviremnet ################################
function jdk()
{
cd ~
if [ -e ~/jdk1.6.0_20.tar.gz ];then
tar zxvf ~/jdk1.6.0_20.tar.gz
mv ~/jdk1.6.0_20 /usr/local
cd /usr/local
ln -s jdk1.6.0_20 jdk
SN=`ls -l |grep 'jdk -> jdk1.6.0_20' |wc -l`
if [ $SN -ge 1 ];then
soc_install
fi
fi
#else
# echo -en "\033[31m Please upload jdk-6u20-linux-x64.bin"
# echo -e "\n"
#fi
}
################################ install soc software ####################################
function soc_install()
{
if [ -e ~/soc-installer-1.0.2.1996-bin.tar.gz ];then
tar zxvf ~/soc-installer-1.0.2.1996-bin.tar.gz &&
cd ~/soc-installer-1.0.2.1996/bin/
bash install.sh
else
echo -en "\033[31m Please upload soc-installer-1.0.2.1758-bin.tar.gz"
echo -e "\n"
fi
}
#jdk
network