#!/sbin/sh             
#
# "@(#)/sbin/lvmrc       $Revision: 74.1 $$Date: 95/03/06 10:12:00 $"
#   
#	This file controls the automatic activation of LVM volume groups 
#	during boot up. 
#
#   Do NOT edit this file.
#
#	The activation of volume groups can be customized by editing /etc/lvmrc.
#   The script in /sbin/lvmrc (this file) depends on the variables 
#   AUTO_VG_ACTIVATE and RESYNC, both of which are set in /etc/lvmrc.
#

#
# Ignore SIGHUP: allows multiple logical volumes to be sync'ed in the
# background.
#

trap "" 1

#
#	Default auto volume group activation
#

default_vg_activation()
{
	if [ -r /etc/lvmtab ]
	then
		/sbin/vgchange -a y -s
		if [ -f /sbin/vgsync ] 
		then
			VOLUME_GROUPS=`vgdisplay | \
			       awk '/VG Name/ { print $NF }'`
			{
			for VG in $VOLUME_GROUPS
			do
				{
				if /sbin/vgsync $VG > /dev/null
				then
					echo "Resynchronized volume group $VG"
				fi
				} &
				#
				# RESYNC is set in /etc/lvmrc
				#
				if [ $RESYNC = "SERIAL" ]
				then
					wait
				fi
			done
			} &
		fi			
	fi
}

#
# Source /etc/lvmrc to get current settings of AUTO_VG_ACTIVATE,
# RESYNC and custom_vg_activation()
#
if [ -r /etc/lvmrc ] ; then
. /etc/lvmrc
else
	echo "$0: Could not source /etc/lvmrc, activate all VG by default" 
	AUTO_VG_ACTIVATE=1
	RESYNC="SERIAL"
fi


#
#	Call the appropriate activation routine(s)
#

if [ ${AUTO_VG_ACTIVATE} -eq 0 ]
then
	custom_vg_activation
else
	default_vg_activation
fi
