#!/bin/bash
#------------------------------------------------------------------------
# this script use to setup envirnment for oracle
# wrote by dywer on Dec 18 2008, last modify 04/12/09
#------------------------------------------------------------------------
oracle_passwd=jkljkl   # oracle用户密码
setup_file_path=/dy/database  # 10g安装程序目录
install_to_path=/dy/oracle          # 安装路径
#----------------------------------------
grep oracle /etc/passwd &> /dev/null # 检查是否已经安装
if [ $? -eq 0 ]
then
clear
echo "oracle user is already exist!"
exit 1
fi
###################调整内核参数#############################
cat >> /etc/sysctl.conf << !
kernel.sem = 250 32000 100 128
fs.file-max = 65546
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 1048576
net.core.wmem_max = 1048576
!
sysctl -p  # 提交配置参数
###########################################################
#off Selinux
groupadd dba && groupadd oinstall
useradd -g oinstall -G dba -m oracle
echo $oracle_passwd | passwd oracle --stdin
mkdir -p $install_to_path
chown -R oracle.oinstall $install_to_path
##=============================================
cat >> /etc/pam.d/login << !
# Add content for oracle install
session required pam_limits.so
!
# turn on limits for oracle 10g
cat >> /etc/security/limits.conf << !
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 4096
oracle hard nofile 65535
!
##=============================================
#echo 'Red Hat Enterprise Linux Server release 4 (Tikanga)' > /etc/redhat-release
echo '
#--------------------------------------
# Set for Oracle10g Install           ;
#--------------------------------------
trap " " 0 1 2 3 5 9 15
trap clear 0
export TMP=/tmp
export TMPDIR=$TMP
' >> /home/oracle/.bash_profile
#============
echo "export ORACLE_BASE=$install_to_path" >> /home/oracle/.bash_profile
#============
echo '
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:$PATH
export LANG=en_US
' >> /home/oracle/.bash_profile
##=============================================
cd $install_file_path
chmod +x runInstaller
chmod +x doc/*
chmod +x install/*
chmod +x response/*
chmod +x stage/*
chmod +x install/.oui
# 用户ROOT登录在字符界面下
clear
echo "you can su - oracle in X and run runInstaller to install oracle now!"
#su - oracle
#startx -- :1
#./runInstaller   # 开始安装ORACLE