[root@www ~]# cat env.sh
#!/bin/bash
grid_pwd="grid"
oracle_pwd="oracle"
rac1='$rac1'
rac1_vip='$rac1-vip'
rac1_priv='$rac1_priv'
rac2='$rac2'
rac2_vip='$rac2-vip'
rac2_priv='$rac2-priv'
scan='$scan'
cat >>/etc/hosts <<EOF
192.168.179.99 $rac1
192.168.179.100 $rac1_vip
10.10.10.1 $rac1_priv
192.168.179.101 $rac2
192.168.179.102 $rac2_vip
10.10.10.2 $rac2_priv
192.168.179.103 $scan
EOF
need_packages="binutils compat-libstdc++-33 compat-libstdc++-296 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++"
echo -e "\033[32m***********************************************************\033[0m"
echo -e "\033[32m System environment check \033[0m"
missing_packages=`rpm -q $need_packages | grep "not installed"`
if [ -z "$missing_packages" ];then
echo -e "\033[32mPackages check passed.\033[0m"
else
echo -e "\033[32m${missing_packages} Please insert the os or Disc dvd to downloader the packages.\033[0m"
echo -e "\033[32mWhere is your operation system installation media?\033[0m"
fi
read -p "please input your choice dvd or iso:" input
case $input in
dvd)
mkdir -p /mnt/dvd
mount /dev/cdrom /mnt/dvd
;;
iso)
mkdir -p /mnt/dvd
read -p "Where is the iso?(in absolute path,e.g., /u01/rhel-server-6/7.x-x86_64-dvd.iso)" iopath
mount $iopath -o loop /mnt/dvd
test $? -ne 0 && echo -e "\033[32mError occured while mounting the media,exit!! please check and try again!\033[0m" &&exit
;;
*)
echo -e "\033[32mplease input dvd or iso,please try again exit!!\033[0m"
exit
;;
esac
cat > /etc/yum.repos.d/rhel6.repo<<EOF
[local]
name=redhat-local
baseurl=file:///mnt/cdrom
gpgcheck=0
EOF
yum install $need_packages -y
groupadd -g 600 oinstall
groupadd -g 601 asmadmin
groupadd -g 602 asmdba
groupadd -g 603 asmoper
useradd -u 600 -g oinstall -G asmadmin,asmdba,asmoper grid
id grid
echo $grid_pwd | passwd grid --stdin
groupadd -g 604 dba
groupadd -g 605 oper
useradd -u 601 -g oinstall -G dba,oper,asmdba oracle
id oracle
echo $oracle_pwd | passwd oracle --stdin