#!/bin/bash ################################################################# # /usr/local/bin/mtnfs rm20090204 # This script is used to check and see if a fileserver is up # when a workstation boots. If server is not up the nfs shares # are not mounted. This avoids long waits while the workstation # tries to mount nfs shares listed in /etc/fstab if the file- # server is not up. I run it from /etc/rc.d/rc.local on # Slackware boxes. # # Note that mounting shared directories like this instead of # listing them in /etc/fstab may cause your system to hang at # shutdown unless you umount them manually and early. To do # that in Slackware I create a rc.local_shutdown script in # /etc/rc.d. If this script is executable it will be run # early from rc.0. For me that script looks like this: # #!/bin/bash # # /etc/rc.d/rc.local-shutdown # # This script will be run at the beginning of # # /etc/rc.d/rc.0 which is the script run for # # level 0, i.e. shutdown. # # umount /videos/archives # umount /videos # umount /var/backups ################################################################# # Manually edit this variable to correct server ip IP1=192.168.1.4 # Use ping -c1 to send one packet only # Use > /dev/null 2>&1 to redirect standard out and # error to /dev/null because we don't need to see it ping -c1 $IP1 > /dev/null 2>&1 # Ping will return a zero if there was a packet returned # from the server and the three NFS shares will be mounted if [ $? -eq 0 ];then echo "Server up. Mounting NFS shares" mount -t nfs 192.168.1.4:/var/backups/ /var/backups -o rw,hard,intr,rsize=24576,wsize=245760 mount -t nfs 192.168.1.4:/videos /videos -o rw,hard,intr,rsize=32768,wsize=32768 mount -t nfs 192.168.1.4:/videos/archive /videos/archive -o rw,hard,intr,rsize=32768,wsize=32768 else echo -e "The server is not up. No NFS shares to mount." fi #End of script