#!/bin/sh
#
# Several functions included by the shell scripts.
#
# lvol2uuid	converts disk name (/dev/sda1) to its Unique Universal Identifier
# check_root	exits if you are not root
# reconnect_md	reconnects all defined md devices
#





# Convert device to UUID
lvol2uuid()
{
	DISK=$1
	blkid $DISK -s UUID | sed 's/^.*: *//'
}



# ----- check if we are root
check_root()
{
	if test "$UID" "=" 0
	then
		echo "Run this script as ROOT ! like:" 
		echo "# su - root"
		echo "# sudo $0" 
		echo " "
		sleep 10;
		exit
	fi
}
# ----- yes, we are root


# ---- re-connect mirrored disks
reconnect_md()
{
	mdadm --auto-detect 2>/dev/null	# Just to be sure all MD's are working.
}




