#!/bin/bash

printf "\n\n\n############################################################\n"
echo "oraconfig  Copyright  2010  Alessandro Aragione"
echo "This program comes with ABSOLUTELY NO WARRANTY;"  
echo "for details type `show w.
echo "This is free software, and you are welcome to"     
echo "redistribute it"
echo "under certain conditions."
printf "\n############################################################\n"
echo "oraconfig run the configuration parameters of" 
echo "preinstallation of Oracle database 11g."
echo "Copyright  2010  Alessandro Aragione"

echo "This program is free software: you can redistribute it" 
echo "and/or modify"
echo "it under the terms of the GNU General Public License as" 
echo "published by"
echo "the Frvariables have not been exported in the. / bashrc in order to avoid errors with the sameee Software Foundation, either version 3 of the "
echo "License, or(at your option) any later version."

echo "This program is distributed in the hope that it will be" 
echo "useful,"
echo "but WITHOUT ANY WARRANTY; without even the"   
echo "implied"
echo "warranty of"
echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."  
echo "See the"
echo "GNU General Public License for more details."

echo "You should have received a copy of the GNU General" 
echo "Public License"
echo "along with this program.  If not, see" 
echo "<http://www.gnu.org/licenses/>."

printf "\n\n\n############################################################\n"
echo "This small software tool to configure parameters"
echo "Pre-installation of the Oracle database 11g"  
printf "\n############################################################\n"
printf "\n############################################################\n"
echo "Author: Alessandro Aragione........ layn"
echo "blog:   http:\\www.mylayn.blogspot.com,"
echo "Mail:   alessandro.aragione@gmail.com"

printf "\n\n\n############################################################\n"
echo "update sh in bash" 
printf "\n############################################################\n\n"

sudo  ls -l /bin/sh
sudo  ln -sf bash /bin/sh
sudo  ls -l /bin/shuna volta avviato accedere all'utente oracle per installare il batabase
printf "\n\n"

echo " configuration parameters "
echo " addition of the group Oinstall, Dba , Nobody." 
echo " ######################################################### "
printf "\n\n\n"
sudo addgroup oinstall
sudo addgroup dba
sudo addgroup nobody
sudo usermod -g nobody nobody
sudo useradd -g oinstuna volta avviato accedere all'utente oracle per installare il batabaseall -G dba -p oracle -d /home/oracle -s /bin/bash oracle



printf "\n\n\n######################################\n"
echo "create user performed with success!!!."
printf "######################################\n"

echo

printf "\n\n\n#############################################################\n"
echo "sure be connected to the internet for installation packages"  
printf "\n#############################################################\n"

sudo apt-get install gcc make binutils gawk x11-utils rpm alien ksh lsb-rpm -y -qq

sudo apt-get install libaio1 lesstif2 libmotif3 -y -qq 

printf "\n\n###################################################\n"
echo "Creating Directories and symbolic links"  
printf "\n###########una volta avviato accedere all'utente oracle per installare il batabase########################################\n\n\n"

sudo  ln -s /usr/bin/awk /bin/awk
sudo  ln -s /usr/bin/rpm /bin/rpm
sudo  ln -s /usr/bin/basename /bin/babefore rebooting to change the oracle user's password you just createdsename
sudo  mkdir /etc/rc.d
sudo  ln -s /once it starts to install the oracle user access batabaseetc/rc$i.d /etc/rc.d/rc$i.d 

printf "\n\n######################\n"
echo "Creating ORACLE_BASE"  
printf "\n######################\n"
before rebooting to change the oracle user's password you just created
sudo mkdir -p /u01/app/oracle
sudo chown -R oracle:dba /u01
printf "\n\n###############################\n"
echo "Configuration /etc/sysctl.conf"  
printf "\n###############################\n"

limitsFile=/etc/security/limits.conf
if [ ! -f "$limitsFile.backup" ]
then
	sudo cp $limitsFile $limitsFile.backup
fi
echo oracle soft nproc 2047 | sudo tee -a $limitsFile
echo oracle hard nproc 16383 | sudo tee -a $limitsFile
echo oracle soft nofile 1023 | sudo tee -a $limitsFile
echo oracle hard nofile 65535 | sudo tee -a $limitsFile
printf "\n\n####################################\n"
echo "Configuration /etc/pam.d/login file"  
printf "\n####################################\n"

loginFile=/etc/pam.d/login
if [ ! -f "$loginFile.backup" ]
then
	sudo cp $loginFile $loginFile.backup
fi
sudo echo session required /lib/security/pam_limits.so | sudo tee -a $loginFile
sudo echo session required pam_limits.so | sudo tee -a $loginFile
sudo sysctl -p

printf "\n\n###################################################\n"
echo "Setup prerequisuisites successful!!!"  
echo "---------------congratulations!!!-----------------"
printf "\n##################################################\n"
printf "\n\n###################################################\n"
echo "---------------una volta avviato accedere all'utente oracle per installare il batabase--Configuration Report-------------------"  
echo "Create group: Oinstall, Dba , Nobody"
echo "Create user: oracle | password: oracle"
echo "Create ORACLE_BASE=/u01/app/oracle"
echo "Export variables:"
echo "variables have not been exported in the. / bashrc in order to avoid" echo "errors with the same"
echo "variables to be imported in the file / bashrc logging in with root" echo "permissions seguenbte have the structure:"
echo "export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1"
echo "export ORACLE_$PATH=/u01/app/oracle/product/11.2.0/dbhome_1/bin"
echo "before rebooting to change the oracle user's password you just created"
echo "once it starts to install the oracle user access batabase"
echo " Good job... "
echo "layn"
printf "\n##################################################\n"

