Situatie
Vrem sa montam un sher de tip NFS
Solutie
Pasi de urmat
Executam comanda : pico nfsmount.sh
Inseram scriptul
#!/bin/sh
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
# Nume server care trebuie accesat
remotesystem=myremoteserver
# Nume sher care trebuie accesat
remoteshare=/nfsexports/backupshare
# Unde sa fie montat shere-ul NFS
mountpoint=/localbackups/TRANSFERS/${myremoteserver}
# fila ce indica starea Mount-ului
testfile=$mountpoint/.myremoteservertransfers
# — end variables —
# Rezultat ping catre ServerNFS (2 sec timeout); not empty is OK
remoteping=`ping -c1 -o -q -t2 ${remotesystem} | grep ” 0.0%”`
if [ “${remoteping}” != “” ] ; then
# server is available so query availability of the remote share; not empty is OK
offsiteshare=`showmount -e ${remotesystem} | grep “${remoteshare}”`
# Asigurare ca mount-pointul local nu este activ; not empty is OK
localmount=`/sbin/mount | /usr/bin/grep “${mountpoint}”`
if [ “${offsiteshare}” != “” ] ; then
if [ ! -e ${testfile} ] ; then
if [ “${localmount}” = “” ] ; then
mount -r -t nfs ${remotesystem}:${remoteshare} ${mountpoint}
fi
fi
fi
fi
exit 0
Salvam
Executam comanda chmod +x nfsmount.sh
Executam scriptul
sh nfsmount.sh
Leave A Comment?