I am trying to mount as below, where the mount point is version dependant:
1) Find if any of the below 2 are mounted.
2) Find RHEL version, then mount one of the below
- mount -o soft 123.45.678.9:/web /mnt3 (RHEL 5)
- mount -o vers=3 123.45.678.9:/web /mnt3 (RHEL 6)
3) If fails out put statement.
Tried these 2 codes
1st
mount > /tmp/mountlog;
if grep -ohw "soft,addr=123.45.678.9" /tmp/mountlog; then echo -e " RHEL 5 MOUNT \e[1;33mALREADY\e[00m AVAILABLE \e[1;33m-PASSED\e[00m ";
elif grep -ohw "nfsvers=3,addr=123.45.678.9" /tmp/mountlog; then echo -e " RHEL 6 MOUNT \e[1;33mALREADY\e[00m AVAILABLE \e[1;33m-PASSED\e[00m ";
elif grep -ohw "5.*" /tmp/red; mount -o soft 123.45.678.9:/web /mnt3 &>/dev/null; then mount > /tmp/mountlog; fi
if grep -ohw "soft,addr=123.45.678.9" /tmp/mountlog; then echo -e " RHEL 5 MOUNT AVAILABLE \e[1;33m-PASSED\e[00m ";
elif grep -ohw "6.*" /tmp/red; mount -o vers=3 123.45.678.9:/web /mnt3 &>/dev/null; then mount > /tmp/mountlog;
if grep -ohw "nfsvers=3,addr=123.45.678.9" /tmp/mountlog; then echo -e " RHEL 6 MOUNT AVAILABLE \e[1;33m-PASSED\e[00m ";
else echo -e " MOUNT DEVICE NOT AVAILABLE Or NOT VALID RHEL VERSION 5 or 6. \e[00;31mFAILED\e[00m "; fi; fi | tee -a /tmp/log;
2nd
mount > /tmp/mountlog;
if grep -ohw "soft,addr=123.45.678.9" /tmp/mountlog; then echo -e " RHEL 5 MOUNT \e[1;33mALREADY\e[00m AVAILABLE \e[1;33m-PASSED\e[00m ";
elif grep -ohw "nfsvers=3,addr=123.45.678.9" /tmp/mountlog; then echo -e " RHEL 6 MOUNT \e[1;33mALREADY\e[00m AVAILABLE \e[1;33m-PASSED\e[00m ";
elif grep -ohw "5.*" /tmp/red; mount -o soft 123.45.678.9:/web /mnt3 &>/dev/null; then mount > /tmp/mountlog; fi
if grep -ohw "soft,addr=123.45.678.9" /tmp/mountlog; then echo -e " RHEL 5 MOUNT AVAILABLE \e[1;33m-PASSED\e[00m ";
elif grep -ohw "6.*" /tmp/red; mount -o vers=3 123.45.678.9:/web /mnt3 &>/dev/null; then mount > /tmp/mountlog; fi
if grep -ohw "nfsvers=3,addr=123.45.678.9" /tmp/mountlog; then echo -e " RHEL 6 MOUNT AVAILABLE \e[1;33m-PASSED\e[00m ";
else echo -e " MOUNT DEVICE NOT AVAILABLE Or NOT VALID RHEL VERSION 5 or 6. \e[00;31mFAILED\e[00m "; fi | tee -a /tmp/log;