Below sections are listing the scripts with various examples on different situations and work that a linux system administrator has to do, I have written these scripts to automate some common and reoccuring tasks, find below the list of scripts –
SCRIPT 1 : This Script will extract, check environment, do the logging and run the script on Linux server to apply the Quarterly patch provided by Oracle. Below is the reference of a script for applying a oracle weblogic patch –
######################### #Written by Pankaj Kumar# #Version 1.0 # #Dated 03052024 # # # # # ######################## echo "Middleware Patching ----" echo "Pass argument like sh patchapply.sh p34080315_122140_Generic.zip WLS_SPB_12.2.1.4.240405" echo "Check JAVA Processes " echo "" cdate=$(date +"%d%m%y%H%M") #cdate=$(date +"%F") echo "" plog=patchlogs_$cdate.log echo "" MW_HOME=/u01/forms/products/Middleware JAVA_HOME=/u01/forms/products/jdk1.8.0_333 echo "##########Quarterly Patching######" >> $plog echo "######Date $cdate ########" >> $plog dcheckforms=$(df -TH /u01/forms/products | awk '//{print $1, $5 }' | awk '//{print $2 }'|awk 'NR==2 {print $1}' |sed s/'\G*$'//) if [[ $dcheckforms -ge 15 ]]; then echo "Enough Space on file system - forms" df -TH /u01/forms/products echo "Enough Space on file system - forms" >> $plog echo "" echo "" echo "Proceeding with backups ..." echo "" >> $plog echo "Proceeding with Middleware Backups " >> $plog echo "" >> $plog cp -r $MW_HOME /u01/forms/products/Middleware.bkp.$cdate cp -r $JAVA_HOME /u01/forms/products/jdk1.8.0_333.bkp.$cdate echo "" >> $plog else echo "Please increase the disk space on forms" df -TH /u01/forms/products echo "Installation is aborted ...." exit 1 fi echo "" >> $plog . ~/.profile stopAll ####ENable this check if pidof -x java > /dev/null then echo "JAVA processes are already running, please stop ALL and proceed again" >> $plog exit 1 fi echo "creating /tmp/fuser" >> $plog touch /tmp/fuser DOMAIN_HOME=/u01/forms/products/Middleware/user_projects/domains/cs365_domain ##export FORMS_PATH=/APPL/CRE/CRE:/APPL/CRE/CRE_SRC/Common/Lib:/u01/app/oracle/product/12.2.1/forms:/u01/app/oracle/product/12.2.1/user_projects/domains/base_domain/config/fmwconfig/components/FORMS/instances/forms1 ##export REPORTS_PATH=/APPL/CRE/CRE:/APPL/CRE/CRE_SRC/Common/Lib:/u01/app/oracle/product/12.2.1/reports:/u01/app/oracle/product/12.2.1/user_projects/domains/base_domain/reports #export TWO_TASK=ORCL export TNS_ADMIN=$DOMAIN_HOME/config/fmwconfig/ export TERM=vt220 export ORACLE_TERM=$TERM ##. .profile # Reports server: Adjust as required to allow forms to get the reports server name # using "tool_env.getvar('REPORTS_SERVER_NAME', v_rep_server);" export REPORTS_SERVER_NAME= export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P15 export INSTANCE_HOME=$DOMAIN_HOME/config/fmwconfig/components/OHS/instances/ohs1 ##. ./.aliases OPATCH_NO_FUSER=true export PATH=/tmp:$PATH patchdir=/tmp echo "" echo "" cd /tmp echo "Patch Validation check " >> $plog echo "" >> $plog echo " $1 " >> $plog sleep 5 if [ -f "$1" ]; then echo "Proceeding to apply $1 patch .... " >> $plog cd /tmp ## cp /tmp/$1 $patchdir/ ## cd $patchdir echo "OPATCH Update ... " echo "" >> $plog echo "Proceeding with Patch Unzip operation " >> $plog echo "" >> $plog echo $(PWD) echo "" echo "y" | unzip -q $1 echo "" echo "" echo "cd into PATCH DIR ....... " echo "" echo "" sleep 15 cd $2/tools/spbat/generic/SPBAT . ~/.profile ./spbat.sh -phase precheck -oracle_home $ORACLE_HOME echo "" >> $plog echo "" >> $plog opatch lsinventory | tail -n 20 >> $plog ./spbat.sh -phase apply -oracle_home $ORACLE_HOME echo "" else echo "$1 does not exist." echo "" >> $plog fi echo "" echo "" echo "#######################################" >> $plog echo "Script finished at $cdate " >> $plog echo "#######################################" >> $plog echo "" echo ""
SCRIPT 2 : This script is to check application parameters for webtier installation on Linux system
#!/usr/bin/bash #RPMS check filename="$1" while read -r line do small=`echo $line|awk -F '[:.]' '{print $1}'` if [ `rpm -qa|grep $small|wc -l` -lt 1 ]; then isok='notok' else isok='ok' fi echo '\n' echo $line "-->" $isok echo "--------------------------------------------------------------" echo $small rpm -qa|grep $small done < "$filename" #check SHMMAX if [ `cat /etc/sysctl.conf|grep SHMMAX|awk -F[:=] '{print $2}'` -gt 4294967295 ]; then echo "SHMMAX value is " `cat /etc/sysctl.conf|grep SHMMAX|awk '{print $2}'` " ---> This is OK" else echo "SHMMAX value is " `cat /etc/sysctl.conf|grep SHMMAX|awk '{print $2}'` " ---> WHICH IS NOT OK" echo "Change the value of SHMMAX to a value higher than 4294967295 by including the following line in /etc/sysctl.conf:kernel.shmmax = value" echo "Activate the new SHMMAX setting by running the command:/sbin/sysctl -p" echo "Start the Oracle Universal Installer and install your software" fi #Chek /etc/hosts if [ `cat /etc/hosts|grep 127.0.0.1|wc -l` -lt 1 ] && [ `cat /etc/hosts|grep $iphost|wc -l` -lt 1 ]; then echo "Modify the /etc/hosts file to contain the following entries" echo "127.0.0.1 loopback localhost" echo "IPADDRESS HOSTNAME HOSTNAME.EUROPE.INTRANET" else echo "/etc/hosts entries ---> OK" fi # Check NPTL if [ `getconf GNU_LIBPTHREAD_VERSION|wc -l` -lt 1 ]; then echo "NTPL setup is not proper ------------> NOTOK" echo "If you are installing Oracle HTTP Server on a Linux operating system, the operating system needs to set Native POSIX Threads Library (NPTL) as the default threads-implementation." else echo "NTPL setup is ----------> OK" echo "----------------------------" getconf GNU_LIBPTHREAD_VERSION fi #Checking the Open File Limit cat /etc/passwd|grep fb_| awk -F':' '{print $1}' >> /tmp/user_list while read -r line do if [ `cat /etc/security/limits.conf|grep $line|grep soft|grep nofile |awk '{print $4}'` -ne 4096 ] && [ `cat /etc/security/limits.conf|grep $line|grep hard|grep nofile |awk '{print $4}'` -ne 65536 ] && [ `cat /etc/security/limits.d/90-nproc.conf|grep $line|grep soft|grep nproc |awk '{print $4}'` -ne 2047 ] && [ `cat /etc/security/limits.d/90-nproc.conf|grep $line|grep hard|grep nproc |awk '{print $4}'` -ne 16384 ]; then echo "Open File Limit are NOTOK" echo "As root add the following lines to /etc/security/limits.conf" echo "As root add the following lines to /etc/security/limits.d/90-nproc.conf" else echo "Open File Limit are OK" echo "--------------------------------------------------------------------------" cat /etc/security/limits.conf|grep 'hard\|soft' fi done < /tmp/user_list AWK Reference - find in a file if userid with 0 exist more then once - awk -F: '($3 == "0") {print}' /etc/passwd
SCRIPT 3: – Linux Script to check if Answer is Yes or No, Y or N , y or n —
Script to start the Managed Servers
Version 1.0 16102018 by Pankaj Kumar
Updated Pankaj Kumar 07072021
echo “”
echo “”
echo “Make sure from previous step environment is restarted ..”
echo “”
echo “”
echo “have you updated the server name in RegisterMachine.py script ?”
read yn
if [[ “$yn” =~ ^([yY][eE][sS]|[yY])$ ]]
then
MIDDLEWARE_HOME=/u01/forms/products/Middleware
WLS_HOME=/u01/forms/products/Middleware/wlserver
script_dir=/u01/forms/bin
script_dir=$(pwd)
sh ${MIDDLEWARE_HOME}/oracle_common/common/bin/wlst.sh
Change to the scripts directory
. $WLS_HOME/server/bin/setWLSEnv.sh
java weblogic.WLST $script_dir/RegisterMachine.py
else
echo “Please update the Server Name in script RegisterMachine.py …. “
exit 1
fi