oracledba.help
Scripts

DBA Script

<- Scripts

#!/bin/bash
# File: initNFS.sh (Mounts NFS directory).
# Ver:  2019.02
# To unmount: umount -f <LocalDir>  Example: umount -f /u03

# User Vars
sNfsSrv_IP="10.4.0.15";            # <NfsSrvIp> Test: 10.4.0.15, Prod: 10.230.2.220
sNfsSrv_ExpStr="$sNfsSrv_IP:/u01"; # <NfsSrvIp:/NfsSrvMountedDrv> Ex: sNfsSrv_IP:/u01
sNfsOptions="-o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,actimeo=0,vers=3,timeo=600";
# RAC: "-o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,actimeo=0,vers=3,timeo=600"
# Std: "-o rw,soft" 
sLocalDir="/u03"                   # Local dir to create NFS mount point. Ex: /u03
nWait=120;                         # How many seconds to wait for NFS Service to start.

# Start
nExit=1;
printf "$(basename ""$0""): Started $(date "+%Y-%m-%d %H:%M:%S")\n"
printf "Waiting $nWait seconds...\n"
sleep $nWait

# Can We Reach the NFS Server?
ping -q -c 3 $sNfsSrv_IP > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
   printf "NFS Server: Cannot Reach $sNfsSrv_IP\n"
else
   printf "NFS Server: OK\n"

   # Can We Mount NFS Path?
   mount -t nfs $sNfsOptions $sNfsSrv_ExpStr $sLocalDir
   if [[ $? -ne 0 ]]; then
      printf "NFS Mount Status: Could Not Mount $sNfsSrv_ExpStr\n"
   else
      printf "NFS Mount Status: $sLocalDir Mounted OK\n"
      nExit=0;
   fi
fi

# End
printf "$(basename ""$0""): Ended $(date "+%Y-%m-%d %H:%M:%S")\n"
exit $nExit