#!/bin/sh
#host=media/bs-rescue/bacula-rescue/clients/client1
#owd=""
usb=`blkid |grep bs-rescue|cut -d: -f1`
usb=${usb%?}
if [ -f $owd/$host/diskinfo/uuid.disks.with.no.uuid ];then
rm $owd/$host/diskinfo/uuid.disks.with.no.uuid
fi
 blkid | awk '{ print $1 }'|grep -v loop|grep -v md|grep -v mapper|grep -v $usb|while read line;do
line=${line%?}
l=`echo $line |cut -d"/" -f3`
echo "/dev/"$l > $owd/$host/diskinfo/uuid.$l
#hdparm -i $line |grep Serial|cut -d, -f3 >>$owd/$host/diskinfo/hdparm.$l

a=`blkid $line |wc -w|xargs expr`
while [ $a -ne 0 ];do
blkid $line |awk "{print \$$a}"|grep UUID >/dev/null 2>&1
if [ $? = 0 ];then
blkid $line |awk "{print \$$a}"|grep UUID>>$owd/$host/diskinfo/uuid.$l
break
fi
if [ $a = 1 ];then
echo $line >> $owd/$host/diskinfo/uuid.disks.with.no.uuid

fi
a=$(( a - 1))
done

done

fdisk -l |grep /dev|grep -v $usb|grep :|cut -d: -f1|cut -d" " -f2|while read line;do
l=`echo $line |cut -d"/" -f3`

dd if=$line of=$owd/$host/diskinfo/mbr.$l bs=1 count=512 >/dev/null 2>&1
done
