I normally keep these scripts organized in different directories but for the use of this tutorial they can all be dropped in the same directory and ran.
<File Server> = A shared file server where software is kept
<File Server Share Directory> = The share directory on the file server where software and scripts live.
mkdir /software
chmod 775 /software
mount <File Server>: <File Server Share Directory>/software /software
mkdir /software/ossupport/configs/oel6up2 –p
mkdir /software/ossupport/scripts/new_install_scripts –p
cd /software/ossupport/scripts/
Install the below scripts
./oel6up2_appserver_postinstall.sh
vi oel6up2_appserver_postinstall.sh
dt_cmd=`/bin/date +%Y%m%d%H%M`
# Start Configuration Section Here #
# Check to make sure the script is running as root.
backup_path=/appbackup
backup_location=$backup_path/backup.$dt_cmd
ntp[1]='server 192.168.0.211’ config_file_dir=/software/ossupport/configs/oel6up2
# End Configuration Section #
source check_user.sh# Check to make sure the latest patches have been applied.
source install_os_updates.sh# Verify the hostname is set correctly.
source check_hostname.sh# Back up Base OS files
source backup_system_config_files.sh# Configure Mount points not in /etc/fstab these mounts will load after os
#source check_etc_rc.local.sh# Configure the clock server
source check_ntp.sh# Replace static os files
source replace_os_files.sh# Create password history file
source setup_password_file.sh# Install resolv.conf
#source install_resolv.conf# Create application monitoring account
#source create-dbosmon-user.sh# Create oracle account
source create-oracle-account-yum.sh
vi new_install_scripts/check_user.sh
USER=`whoami`
# Check to make sure the account is root
if [ $USER != root ]; then
echo "Must be root to run this script, please login as root and re-try"
exit
fi
vi new_install_scripts/install_os_updates.sh
echo "Installing OS Updates";
yum install sendmail tigervnc tigervnc-server tigervnc-server-module firefox
yum list updates
yum update exclude=kernel*
vi new_install_scripts/check_hostname.sh
HOSTNAME=`hostname`
echo "Verify Hostname"
echo "When using dhcp the dhcp server may assign an invalid hostname verify the correct hostname is set."
echo "Hostname: "$HOSTNAME
echo "Is "$HOSTNAME" the correct hostname? (y/n)"
read response
if [ $response != "y" ]; then
echo "Please enter the correct hostname"
read response
hostname $response
HOSTNAME=`hostname`
echo "Replacing hostname in /etc/sysconfig/network file."
old_hostname=`cat /etc/sysconfig/network | grep HOSTNAME`
echo "Old Hostname setting: "$old_hostname
if [ "$old_hostname" == "" ]; then
echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network
else
sed -ie "s/$old_hostname/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network
fi
new_hostname=`cat /etc/sysconfig/network | grep HOSTNAME`
echo "New Hostname setting: "$new_hostname
fi
vi new_install_scripts/backup_system_config_files.sh
# Do not recover sysctl edit this file by hand
alias cp='cp'
echo "Back Up Location: "$backup_location
echo "Creating Initial Backup"fnBackUpFile()
{
if [ -f "$1" ]; then
cp $1 $backup_location
echo "Backing Up "$1
fi
}fnBackUpFile /etc/samba/smb.conf
fnBackUpFile /etc/selinux/config
fnBackUpFile /etc/pam.d/system-auth
fnBackUpFile /etc/bashrc
fnBackUpFile /etc/pam.d/login
fnBackUpFile /etc/pam.d/halt
fnBackUpFile /etc/pam.d/reboot
fnBackUpFile /etc/pam.d/poweroff
fnBackUpFile /etc/csh.login
fnBackUpFile /etc/passwd
fnBackUpFile /etc/group
fnBackUpFile /etc/shadow
fnBackUpFile /etc/profile
fnBackUpFile /etc/rc.d/rc.local
fnBackUpFile /etc/pam.d/login
fnBackUpFile /etc/security/limits.conf
fnBackUpFile /etc/csh.login
fnBackUpFile /etc/sysctl.conf
fnBackUpFile /etc/sysconfig/network-scripts/ifcfg-eth0
fnBackUpFile /etc/sysconfig/network
fnBackUpFile /etc/resolv.conf
fnBackUpFile /etc/hosts
fnBackUpFile /etc/sysctl/sysconfig/nfs
fnBackUpFile /etc/rc.d/rc.local
fnBackUpFile /etc/sudoers
fnBackUpFile /etc/inittab
fnBackUpFile /etc/ntp.conf
fnBackUpFile /etc/init/control-alt-delete.conf
# Only required for oracle databases with asm
fnBackUpFile /etc/oracle/ocr.loc
fnBackUpFile /etc/oratab
fnBackUpFile /etc/oraInst.localias cp='cp -i'
vi new_install_scripts/check_ntp.sh
echo "Configuring ntp server"
for ((count = 1;count <= 1;count++ ))
do
defaultntp=`grep "${ntp[count]}" /etc/ntp.conf`
if [ "$defaultntp" = "" ]; then
echo "Adding ${ntp[count]} to /etc/ntp.conf...."
sed "1i ${ntp[count]}" /etc/ntp.conf >> /etc/ntp.conf.new
mv -f /etc/ntp.conf.new /etc/ntp.conf
else
echo "${ntp[count]} already configured in ntp.conf...."
fi
doneecho ${ntp[1]} > /etc/ntp/step-tickers
hwclock --systohc
chkconfig ntpd on
service ntpd stop
service ntpd start
vi new_install_scripts/replace_os_files.sh
fnReplaceOSFile()
{
if [ -f "$1" ]; then
cp $1 $2
echo "Copying $1 to $2."
fi
}fnReplaceOSFile $config_file_dir/inittab /etc/inittab
fnReplaceOSFile $config_file_dir/halt /etc/pam.d/halt
fnReplaceOSFile $config_file_dir/reboot /etc/pam.d/reboot
fnReplaceOSFile $config_file_dir/poweroff /etc/pam.d/poweroff
fnReplaceOSFile $config_file_dir/sudoers /etc/sudoers
fnReplaceOSFile $config_file_dir/bashrc /etc/bashrc
fnReplaceOSFile $config_file_dir/system-auth /etc/pam.d/system-auth
fnReplaceOSFile $config_file_dir/opasswd /etc/security/opasswd
fnReplaceOSFile $config_file_dir/smb.conf /etc/samba/smb.conf
fnReplaceOSFile $config_file_dir/control-alt-delete.conf /etc/init/control-alt-delete.conf
vi new_install_scripts/setup_password_file.sh
chown root:root /etc/security/opasswd
chmod 600 /etc/security/opasswd
vi new_install_scripts/create-oracle-account-yum.sh
echo "Is this install for oracle database or oracle application server? (y/n)"
read response
if [ "$response" == "y" ]; then
oracle_exists=`cat /etc/passwd | grep oracle`
echo "ORACLE ACCOUNT: "$oracle_exists
if [ "$oracle_exists" == "" ]; then
mkdir -p /app/oracle/product
chmod -R 775 /app
groupadd -g 501 oracle
groupadd -g 503 dba
groupadd -g 504 oinstall
useradd -u 501 -g oinstall -G dba oracle
passwd oracle
chown -R oracle:oinstall /app
else
echo "Oracle account already exists"
fi
echo "Is this insatll for an oracle database? (y/n)"
read response
if [ "$response" == "y" ]; then
yum install oracle-rdbms-server-11gR2-preinstall
yum install oracleasm-support
fi
cat /etc/group | egrep -i 'dba|oinstall'
cat /etc/passwd | grep oracle
fi