<- Scripts
#!/bin/bash
# Script: initLnxOra19_3.sh
# Version: 2024.04.05
# Comments: Run this AFTER running Oracle Preinstallation rpm.
# Ensure all files for install are in SW_SRC_DIR.
# Option Vars
optCopyFilesFromMedia=1
optInitUsers=0
optInitDirs=0
optDisableFirewall=0
optInstallPkgs=0
optVBoxChanges=0
# User Vars
GRID_ENV=0
ORACLE_USR_PW="go";
GRID_USR_PW="$ORACLE_USR_PW";
VERSION="19.3.0.0.0";
SW_SRC_DIR="/tmp/orasw"
SW_DEST_DIR="/u01/orasw"
PATCH_DBRU="p35742413_190000_Linux-x86-64.zip";
PATCH_OJVM="";
APP_DIR="/u01/app";
DB_HOME="$APP_DIR/oracle/product/$VERSION/dbhome_1"
GI_BASE="$APP_DIR/grid"
GI_HOME="$APP_DIR/$VERSION/grid"
# Confirmation
printf "+--------------------------------------------+\n"
printf "| Init the oracle and grid User Environments |\n"
printf "| |\n"
printf "| Post Oracle rpm Changes |\n"
printf "+--------------------------------------------+\n"
printf "optCopyFilesFromMedia: $optCopyFilesFromMedia\n"
printf "optInitUsers: $optInitUsers\n"
printf "optInitDirs: $optInitDirs\n"
printf "optDisableFirewall: $optDisableFirewall\n"
printf "optInstallPkgs: $optInstallPkgs\n"
printf "optVBoxChanges: $optVBoxChanges\n"
printf "\n"
printf "SW_SRC_DIR: $SW_SRC_DIR\n"
printf "SW_DEST_DIR: $SW_DEST_DIR\n"
printf "\n"
printf "GRID_ENV: $GRID_ENV\n"
printf "DB_HOME: $DB_HOME\n"
printf "GI_HOME: $GI_HOME\n"
printf "GI_BASE: $GI_BASE\n"
printf "\n"
printf "Ensure you have run Oracles Preinstallation rpm BEFORE running this!\n\n"
read -p "Are you sure want to continue [y\n]? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
printf "\n"
exit 1
fi
printf "\n"
##################################################################
# System Prep Actions
##################################################################
printf "\nValidating Dirs...\n"
# Oracle Dirs\Volumes
if [[ ! -d "/u01" ]]; then
printf "\nCreating Oracle Dirs\Volumes (\\\u01 & \\\u02) \n"
mkdir -p /u01
mkdir -p /u02
fi
# Init SW Dir
if [[ ! -d $SW_DEST_DIR ]]; then
printf "\nCreating $SW_DEST_DIR... \n"
mkdir -p $SW_DEST_DIR
mkdir -p $SW_DEST_DIR/patches
fi
##################################################################
# User Set Actions
##################################################################
# CopyFilesFromMedia
if [[ $optCopyFilesFromMedia -eq 1 ]]; then
if [ -z "$(ls -A $SW_SRC_DIR)" ]; then
printf "$SW_SRC_DIR has no files - exiting.\n"
exit
fi
printf "\nCopying Files\n"
printf "From: $SW_SRC_DIR\n"
printf "To: $SW_DEST_DIR\n\n"
cd $SW_SRC_DIR
cp -f $SW_SRC_DIR/LINUX.X64_193000_db_home.zip $SW_DEST_DIR/
if [[ -f $SW_SRC_DIR/p6880880_190000_Linux-x86-64.zip ]]; then
cp $SW_SRC_DIR/p6880880_190000_Linux-x86-64.zip $SW_DEST_DIR/
fi
if [[ -f $SW_SRC_DIR/$PATCH_DBRU ]]; then
cp $SW_SRC_DIR/$PATCH_DBRU $SW_DEST_DIR/
fi
if [[ -f $SW_SRC_DIR/$PATCH_OJVM ]]; then
cp $SW_SRC_DIR/$PATCH_OJVM $SW_DEST_DIR/
fi
if [[ $GRID_ENV -eq 1 ]]; then
cp -f $SW_SRC_DIR/LINUX.X64_193000_grid_home.zip $SW_DEST_DIR/
fi
read -p "Copy Files From Media: Completed - Press [Enter] to continue."
fi
# Init User Accounts
if [[ $optInitUsers -eq 1 ]]; then
printf "\nSetting User Passwords...\n\n"
echo "$ORACLE_USR_PW" | passwd --stdin oracle
if [[ $GRID_ENV -eq 1 ]]; then
useradd -u 54331 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba grid
echo "$GRID_USR_PW" | passwd --stdin grid
fi
printf "\n"
read -p "OS Account Changes: Completed - Press [Enter] to continue."
fi
# Init Directories
if [[ $optInitDirs -eq 1 ]]; then
printf "\nInit Directories...\n\n"
# Init /u01
printf "Init /u01\n"
chown -R oracle:oinstall $SW_DEST_DIR
chmod -R 775 /u01/
# Homes
printf "\nCreating Home Dirs...\n\n"
mkdir -p $DB_HOME
cp $SW_DEST_DIR/LINUX.X64_193000_db_home.zip $DB_HOME/
cd $DB_HOME
unzip LINUX.X64_193000_db_home.zip
rm -f LINUX.X64_193000_db_home.zip
chown -R oracle:oinstall $APP_DIR
if [[ $GRID_ENV -eq 1 ]]; then
mkdir -p $GI_BASE
mkdir -p $GI_HOME
cp $SW_DEST_DIR/LINUX.X64_193000_grid_home.zip $GI_HOME/
cd $GI_HOME
unzip LINUX.X64_193000_grid_home.zip
rm -f LINUX.X64_193000_grid_home.zip
chown -R grid:oinstall /u01
chown -R oracle:oinstall /u01/app/oracle
fi
# oraInventory
printf "\nCreating oraInventory Dir...\n\n"
mkdir /u01/app/oraInventory
if [[ $GRID_ENV -eq 1 ]]; then
chown grid:oinstall /u01/app/oraInventory
else
chown oracle:oinstall /u01/app/oraInventory
fi
chmod -R 775 /u01/app/oraInventory
printf "\nInit Directories: Completed \n\n"
read -p "Press [Enter] to continue."
fi
# Disable Firewall
if [[ $optDisableFirewall -eq 1 ]]; then
printf "\nOS Configuration Changes...\n"
printf "\nOnly making changes Oracles Preinstallation rpm does not do.\n\n"
# Stop Firewall
printf "\nFirewall Changes\n\n"
service iptables stop
chkconfig iptables off
systemctl disable firewalld
systemctl stop firewalld
# Disable SELINUX
printf "\nDisable SELINUX \n"
if grep -q SELINUX=enforcing "/etc/sysconfig/selinux"; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
fi
if grep -q SELINUX=enforcing "/etc/selinux/config"; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
fi
# Disable avahi Daemon Service
printf "\nDisabling avahi Daemon Service...\n"
systemctl stop avahi-dnsconfd
systemctl stop avahi-daemon
rm '/etc/systemd/system/dbus-org.freedesktop.Avahi.service'
rm '/etc/systemd/system/multi-user.target.wants/avahi-daemon.service'
rm '/etc/systemd/system/sockets.target.wants/avahi-daemon.socket'
printf "Firewall Changes: Completed\n\n"
printf "NEXT\n"
printf "1. shutdown -r now\n"
printf "2. Install LINUX Packages\n\n"
read -p "Press [Enter] to continue."
fi
# Install LINUX Packages
if [[ $optInstallPkgs -eq 1 ]]; then
printf "\nInstalling LINUX Packages...\n\n"
for PKG in bc binutils elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libXrender libX11 libXau libXi libXtst libgcc libnsl librdmacm libstdc++ libstdc++-devel libxcb libibverbs make smartmontools sysstat
do
yum install $PKG -y
done
for PKG in libnsl2 libnsl2-devel
do
yum install $PKG -y
done
# ME
yum install dnsmasq -y
printf "Install LINUX Packages: Completed\n\n\n"
printf "NEXT\n"
printf "shutdown -r now\n"
read -p "Press [Enter] to continue."
fi
# optVBoxChanges
if [[ $optVBoxChanges -eq 1 ]]; then
printf "\nMaking VirtualBox Changes \n\n"
usermod -aG vboxsf oracle
if [[ $GRID_ENV -eq 1 ]]; then
usermod -aG vboxsf grid
fi
chmod 755 $SW_SRC_DIR
read -p "VirtualBox Changes: Completed - Press [Enter] to continue."
fi
# END
printf "\n*** Process Ended ***\n\n"