#!/sbin/sh -
# %W% %G% %U% - %Q%
#ident "%Z%unixvm:%M% %I%"

# Copyright (c) 2000 VERITAS Software Corporation.  ALL RIGHTS RESERVED.
# UNPUBLISHED -- RIGHTS RESERVED UNDER THE COPYRIGHT
# LAWS OF THE UNITED STATES.  USE OF A COPYRIGHT NOTICE
# IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
# OR DISCLOSURE.
# 
# THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND
# TRADE SECRETS OF VERITAS SOFTWARE.  USE, DISCLOSURE,
# OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
# EXPRESS WRITTEN PERMISSION OF VERITAS SOFTWARE.
# 
#               RESTRICTED RIGHTS LEGEND
# USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT IS
# SUBJECT TO RESTRICTIONS AS SET FORTH IN SUBPARAGRAPH
# (C) (1) (ii) OF THE RIGHTS IN TECHNICAL DATA AND
# COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013.
#               VERITAS SOFTWARE
# 1600 PLYMOUTH STREET, MOUNTAIN VIEW, CA 94043


: ${VOLROOT_DIR:=$__VXVM_ROOT_DIR}
. ${VOL_SCRIPTS_LIB:-$VOLROOT_DIR/usr/lib/vxvm/lib}/vxcommon

VOLADM_CURRENT_MENU=
export VOLADM_CURRENT_MENU

diskadd_lockfile=${VOL_LOCK_DIR}/.DISKADD.LOCK

diskadd_lock_cleanup()
{
	rm -f $diskadd_lockfile
}

if [ -f $diskadd_lockfile ]
then
	export diskadd_lockfile; ewritemsg -M vxvmshm:395 \
"The vxdiskadd or vxdiskadm program is already being run and
  these programs cannot run concurrently.  Please retry this at a
  later time.  If you are certain that no other users are running
  any of these programs, you can remove the file:

	$diskadd_lockfile

  Removing this file will allow you to run vxdiskadm.

"
	exit 1
fi

add_cleanup diskadd_lock_cleanup
2> /dev/null > $diskadd_lockfile
if [ $? -ne 0 ]
then
	progname=$0 diskadd_lockfile="$diskadd_lockfile" egettxt \
		"$progname: Cannot create lock file $diskadd_lockfile" \
		vxvmshm:1026 $progname "$@" >&2
	exit 1
fi

check_exclude_files
if [ $? -ne 0 ]
then
	ewritemsg -M vxvmshm:250 \
"Please correct the problem listed above before re-running vxdiskadm."
else
	voladm_menu_push VolumeManager
	doit "$VOLADM_BIN/disk.menu" $v_opt
fi

if [ -f $excltmpfile2 ]
then
	rm -f $excltmpfile2
	ewritemsg -M vxvmshm:1231 \
"The system must be shut down and rebooted for the device suppression/
  unsuppression operations you have performed to take effect. To shutdown your
  system, cd to / and type

	shutdown -g0 -y -i6

  Do not attempt to use the device suppression/unsuppression operations
  again before the system is rebooted."
	echo ""
elif [ -f $excltmpfile1 ]
then
        rm -f $excltmpfile1
	vxdmpadm doioctl 2>/dev/null
	ewritemsg -M vxvmshm:1187 \
"Please wait while the device suppression/unsuppression operations take effect."
	vxdctl enable
fi

egettxt "\nGoodbye." vxvmshm:527

quit 0
