#!/bin/bash

if [ -f /etc/fstab -a  ! -z /etc/fstab ]
then
    cp -f /etc/fstab /etc/fstab.orig
    if [ $? != 0 ]
    then
	echo "Error making reserve copy of fstab. Stopping script"
	exit 1
    fi
else
    echo "Smth wrong with /etc/fstab. Stopping script"
    exit 1
fi

cat /etc/fstab |\
    while read line; do
	if [ `echo $line |grep ^UUID|wc -l` != 0 ]
	then
	    UUIDline=`echo $line |cut -d' ' -f 1`
    	    blkid |sed s/\"// |grep "$UUIDline" |\
	    while read blkidline; do
		inblk=$blkidline
		dev="`echo -n $inblk |cut -d: -f 1`"
		rest="`echo $line |sed s/$UUIDline//`"
		echo "$dev $rest"
	    done
	else 
	    echo $line
	fi
    done
	

