Estoy tratando de montar como a continuación, donde el punto de montaje depende de la versión:
1) Encuentre si alguno de los 2 siguientes están montados.
2) Encuentre la versión RHEL, luego monte uno de los siguientes
- mount -o soft 123.45.678.9:/web / mnt3 (RHEL 5)
- mount -o vers = 3 123.45.678.9:/web / mnt3 (RHEL 6)
3) Si falla, ponga la declaración.
Probé estos 2 códigos
Primero
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;
2do
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;