Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.idea/
.DS_Store
.vscode/
.codex
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
# Description: Setup the Linux kernel parameter inside the container. Note that some parameter need to be set on container host.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

rpm -Uvh "$GRID_HOME/cv/rpm/cvuqdisk*"
rpm -Uvh $GRID_HOME/cv/rpm/cvuqdisk*
echo "oracle soft nofile 1024" > /etc/security/limits.conf
echo "oracle hard nofile 65536" >> /etc/security/limits.conf
echo "oracle soft nproc 16384" >> /etc/security/limits.conf
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 2018,2025 Oracle and/or its affiliates.
#
# Since: January, 2018
# Author: sanjay.singh@oracle.com, paramdeep.saini@oracle.com
# Description: Common Function File
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#

export logfile=/tmp/orod.log
export logdir=/tmp
export STD_OUT_FILE="/proc/1/fd/1"
export STD_ERR_FILE="/proc/1/fd/2"
export TOP_PID=$$

###### Function Related to printing messages and exit the script if error occurred ##################
error_exit() {
# shellcheck disable=SC2155
local NOW=$(date +"%m-%d-%Y %T %Z")
# Display error message and exit
# echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
echo "${NOW} : ${PROGNAME}: ${1:-"Unknown Error"}" | tee -a $logfile > $STD_OUT_FILE
kill -s TERM $TOP_PID
}

print_message ()
{
# shellcheck disable=SC2155
local NOW=$(date +"%m-%d-%Y %T %Z")
# Display message and return
echo "${NOW} : ${PROGNAME} : ${1:-"Unknown Message"}" | tee -a $logfile > $STD_OUT_FILE
return $?
}

#####################################################################################################

####### Function related to IP Checks ###############################################################

validating_env_vars ()
{
local stat=3
local ip="${1}"
local alive="${2}"

print_message "checking IP is in correct format such as xxx.xxx.xxx.xxx"

if valid_ip "$ip"; then
print_message "IP $ip format check passed!"
else
error_exit "IP $ip is not in correct format..please check!"
fi

# Checking if Host is alive

if [ "${alive}" == "true" ]; then

print_message "Checking if IP is pingable or not!"

if host_alive "$ip"; then
print_message "IP $ip is pingable ...check passed!"
else
error_exit "IP $ip is not pingable..check failed!"
fi

else

print_message "Checking if IP is pingable or not!"

if host_alive "$ip"; then
error_exit "IP $ip is already allocated...check failed!"
else
print_message "IP $ip is not pingable..check passed!"
fi

fi
}

check_interface ()
{
local ethcard=$1
local output

ip link show | grep "$ethcard"

output=$?

if [ $output -eq 0 ];then
return 0
else
return 1
fi
}

valid_ip()
{
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
# shellcheck disable=SC2206
ip=($ip)
IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
return $stat
}

host_alive()
{

local ip_or_hostname=$1
local stat=1
ping -c 1 -W 1 "$ip_or_hostname" >& /dev/null

if [ $? -eq 0 ]; then
stat=0
return $stat
else
stat=1
return $stat
fi

}

resolveip(){

local host="$1"
if [ -z "$host" ]
then
return 1
else
# shellcheck disable=SC2155,SC2178
local ip=$( getent hosts "$host" | awk '{print $1}' )
# shellcheck disable=SC2128
if [ -z "$ip" ]
then
# shellcheck disable=SC2178
ip=$( dig +short "$host" )
# shellcheck disable=SC2128
if [ -z "$ip" ]
then
print_message "unable to resolve '$host'"
return 1
else
print_message "$ip"
return 0
fi
else
print_message "$ip"
return 0
fi
fi
}

##################################################################################################################

############################################Match an Array element#######################
isStringExist ()
{
local checkthestring="$1"
local stringtocheck="$2"
local stat=1

IFS=', ' read -r -a string_array <<< "$checkthestring"

for ((i=0; i < ${#string_array[@]}; ++i)); do
if [ "${stringtocheck}" == "${string_array[i]}" ]; then
stat=0
fi
done
return $stat
}


#########################################################################################


##################################################Password function##########################

setpasswd ()
{

local user=$1
local pass=$2
echo "$pass" | passwd "$user" --stdin
}

##############################################################################################
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# Run:
# $ podman build -t oracle/database:26.0.0-rac .
#

# hadolint global ignore=SC2086,SC3014
ARG SLIMMING=false
ARG BASE_OL_IMAGE=oraclelinux:9
Expand Down Expand Up @@ -93,6 +92,7 @@ ENV SETUP_LINUX_FILE="setupLinuxEnv.sh" \
ORACOMMON="oracommon.py" \
ORASSHSETUP="orasshsetup.py" \
ORASETUPENV="orasetupenv.py" \
ORAOPS="oraops.py" \
DB_USER="oracle" \
GRID_USER="grid" \
SLIMMING=$SLIMMING \
Expand Down Expand Up @@ -137,7 +137,7 @@ COPY $VERSION/$SETUP_LINUX_FILE $VERSION/$GRID_SETUP_FILE $VERSION/$DB_SETUP_FIL
# Setup Scripts
COPY $VERSION/$RUN_FILE $VERSION/$GRID_SAMPLE_RESPONSE_FILE $VERSION/$DBCA_SAMPLE_RESPONSE_FILE $VERSION/$INITSH $SCRIPT_DIR/

COPY $RAC_SCRIPTS_DIR/$ORAFACTORY $RAC_SCRIPTS_DIR/$MAINPY $RAC_SCRIPTS_DIR/$ORAASMCA $RAC_SCRIPTS_DIR/$CMDEXEC $RAC_SCRIPTS_DIR/$SETUPSSH $RAC_SCRIPTS_DIR/$ORAMACHINE $RAC_SCRIPTS_DIR/$ORALOGGER $RAC_SCRIPTS_DIR/$ORAFACTORY $RAC_SCRIPTS_DIR/$ORAGIADD $RAC_SCRIPTS_DIR/$ORARACDEL $RAC_SCRIPTS_DIR/$ORARACSTDBY $RAC_SCRIPTS_DIR/$ORAENV $RAC_SCRIPTS_DIR/$ORARACPROV $RAC_SCRIPTS_DIR/$ORACVU $RAC_SCRIPTS_DIR/$MAINPY $RAC_SCRIPTS_DIR/$ORAMISCOPS $RAC_SCRIPTS_DIR/$ORAGIPROV $RAC_SCRIPTS_DIR/$ORARACADD $RAC_SCRIPTS_DIR/$ORACOMMON $RAC_SCRIPTS_DIR/$ORASSHSETUP $RAC_SCRIPTS_DIR/$ORASETUPENV $VERSION/$RESET_FAILED_UNITS $SCRIPT_DIR/scripts/
COPY $RAC_SCRIPTS_DIR/$ORAFACTORY $RAC_SCRIPTS_DIR/$MAINPY $RAC_SCRIPTS_DIR/$ORAASMCA $RAC_SCRIPTS_DIR/$CMDEXEC $RAC_SCRIPTS_DIR/$SETUPSSH $RAC_SCRIPTS_DIR/$ORAMACHINE $RAC_SCRIPTS_DIR/$ORALOGGER $RAC_SCRIPTS_DIR/$ORAFACTORY $RAC_SCRIPTS_DIR/$ORAGIADD $RAC_SCRIPTS_DIR/$ORARACDEL $RAC_SCRIPTS_DIR/$ORARACSTDBY $RAC_SCRIPTS_DIR/$ORAENV $RAC_SCRIPTS_DIR/$ORARACPROV $RAC_SCRIPTS_DIR/$ORACVU $RAC_SCRIPTS_DIR/$MAINPY $RAC_SCRIPTS_DIR/$ORAMISCOPS $RAC_SCRIPTS_DIR/$ORAGIPROV $RAC_SCRIPTS_DIR/$ORARACADD $RAC_SCRIPTS_DIR/$ORACOMMON $RAC_SCRIPTS_DIR/$ORASSHSETUP $RAC_SCRIPTS_DIR/$ORASETUPENV $RAC_SCRIPTS_DIR/$ORAOPS $VERSION/$RESET_FAILED_UNITS $SCRIPT_DIR/scripts/


RUN chmod 755 $INSTALL_SCRIPTS/*.sh && \
Expand Down Expand Up @@ -173,7 +173,7 @@ COPY $VERSION/$SETUP_LINUX_FILE $VERSION/$GRID_SETUP_FILE $VERSION/$DB_SETUP_FIL
# Setup Scripts
COPY $VERSION/$RUN_FILE $VERSION/$GRID_SAMPLE_RESPONSE_FILE $VERSION/$DBCA_SAMPLE_RESPONSE_FILE $VERSION/$INITSH $SCRIPT_DIR/

COPY $RAC_SCRIPTS_DIR/$ORAFACTORY $RAC_SCRIPTS_DIR/$MAINPY $RAC_SCRIPTS_DIR/$ORAASMCA $RAC_SCRIPTS_DIR/$CMDEXEC $RAC_SCRIPTS_DIR/$SETUPSSH $RAC_SCRIPTS_DIR/$ORAMACHINE $RAC_SCRIPTS_DIR/$ORALOGGER $RAC_SCRIPTS_DIR/$ORAFACTORY $RAC_SCRIPTS_DIR/$ORAGIADD $RAC_SCRIPTS_DIR/$ORARACDEL $RAC_SCRIPTS_DIR/$ORARACSTDBY $RAC_SCRIPTS_DIR/$ORAENV $RAC_SCRIPTS_DIR/$ORARACPROV $RAC_SCRIPTS_DIR/$ORACVU $RAC_SCRIPTS_DIR/$MAINPY $RAC_SCRIPTS_DIR/$ORAMISCOPS $RAC_SCRIPTS_DIR/$ORAGIPROV $RAC_SCRIPTS_DIR/$ORARACADD $RAC_SCRIPTS_DIR/$ORACOMMON $RAC_SCRIPTS_DIR/$ORASSHSETUP $RAC_SCRIPTS_DIR/$ORASETUPENV $VERSION/$RESET_FAILED_UNITS $SCRIPT_DIR/scripts/
COPY $RAC_SCRIPTS_DIR/$ORAFACTORY $RAC_SCRIPTS_DIR/$MAINPY $RAC_SCRIPTS_DIR/$ORAASMCA $RAC_SCRIPTS_DIR/$CMDEXEC $RAC_SCRIPTS_DIR/$SETUPSSH $RAC_SCRIPTS_DIR/$ORAMACHINE $RAC_SCRIPTS_DIR/$ORALOGGER $RAC_SCRIPTS_DIR/$ORAFACTORY $RAC_SCRIPTS_DIR/$ORAGIADD $RAC_SCRIPTS_DIR/$ORARACDEL $RAC_SCRIPTS_DIR/$ORARACSTDBY $RAC_SCRIPTS_DIR/$ORAENV $RAC_SCRIPTS_DIR/$ORARACPROV $RAC_SCRIPTS_DIR/$ORACVU $RAC_SCRIPTS_DIR/$MAINPY $RAC_SCRIPTS_DIR/$ORAMISCOPS $RAC_SCRIPTS_DIR/$ORAGIPROV $RAC_SCRIPTS_DIR/$ORARACADD $RAC_SCRIPTS_DIR/$ORACOMMON $RAC_SCRIPTS_DIR/$ORASSHSETUP $RAC_SCRIPTS_DIR/$ORASETUPENV $RAC_SCRIPTS_DIR/$ORAOPS $VERSION/$RESET_FAILED_UNITS $SCRIPT_DIR/scripts/

# hadolint ignore=SC2086
RUN chmod 755 $INSTALL_SCRIPTS/*.sh && \
Expand Down Expand Up @@ -282,4 +282,4 @@ WORKDIR $WORKDIR

# Define default command to start Oracle Grid and RAC Database setup.
# hadolint ignore=DL3025
ENTRYPOINT /usr/bin/$INITSH
ENTRYPOINT /usr/bin/$INITSH
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ temp_var1=`hostname`
mkdir -p /home/grid/.ssh && \
chmod 700 /home/grid/.ssh && \
unzip -q "$INSTALL_SCRIPTS"/"$INSTALL_FILE_1" -d "$GRID_HOME" && \
"${GRID_HOME}"/gridSetup.sh -silent -setupHome -OSDBA asmdba -OSOPER asmoper -OSASM asmadmin -ORACLE_BASE ${GRID_BASE} -INVENTORY_LOCATION ${INVENTORY} -ignorePrereqFailure || true
"${GRID_HOME}"/gridSetup.sh -silent -setupHome -OSDBA asmdba -OSOPER asmoper -OSASM asmadmin -ORACLE_BASE ${GRID_BASE} -INVENTORY_LOCATION ${INVENTORY} -ignorePrereqFailure || true
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ if [ "${systemctl_state}" != "running" ]; then
touch "/tmp/$new_failed_unit_file_name"
else
touch "/tmp/$passed_unit_file_name"
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ if [ "${SLIMMING}x" != 'truex' ] ; then
echo "export GRID_BASE=$GRID_BASE" >> /home/"${GRID_USER}"/.bashrc
echo "export DB_HOME=$DB_HOME" >> /home/"${GRID_USER}"/.bashrc
fi

Loading
Loading