#!/bin/bash # Script to scan and mount etherdrive blades. If a directory exists, the blade should be mounted. # Newly detected blades will be mounted on $mountdir/XY if the device is /dev/etherd/eX.Y # Removes mount points for blades that have gone down # Mounts individual blades (no RAID) and checks for partition. Script will attempt to mount first partition. # # (w) Lance Mosher October 27 2004 # (m) Lance Mosher April 9 2005 mountdir=/data/eth blades=`aoe-stat | awk '{print $1}'` #This command lists all blades for bl in $blades; do #Cycle through each blade blade=/dev/etherd/$bl #Correct for formatting change in updated driver bladepos=`echo $blade | cut -c14,16` #Pull out XY from eX.Y bladedir=`ls $mountdir/ | grep $bladepos` #| These two lines check to see if | test=`echo $bladedir+err | cut -c2-4` #| mount point /data/eth/XY exists | echo "--------------------------------------------" stat=`aoe-stat | grep $bl | awk '{print $3}'` #Poles aoe-stat for blade status echo "The status of blade $blade is $stat"; if test ! $stat = down then echo "Searching for partitions on $blade" partition=`fdisk -l $blade | awk '{print $1}' | grep $blade` #First word will be "Disk" if no partitions found if test ! $partition = Disk then echo "Partition $partition found..." bladepos=`echo $blade | cut -c14,16` if test ! $test = err #If $test != err then mount point exists then echo "Directory $mountdir/$bladepos/ exists. Filesystem should be mounted." else mkdir $mountdir/$bladepos #If mount point doesn't exist make it and mount echo "Mounting as $mountdir/$bladepos/" mount $partition $mountdir/$bladepos fi else echo "No Partitions found..." if test ! $test = err then echo "No partitions, but directory exists. Removing directory..." #If no partitions remove directory if it exists rmdir $mountdir/$bladepos fi fi else if test ! $test = err then echo "Drive down, but directory exists. Removing directory..." #If status is down remove directory if it exists rmdir $mountdir/$bladepos fi fi done