#!/bin/sh
#
# (c)1997, 98, 99 Be, Inc. All rights reserved.

CMD_ESC='-'
ERR_NO_VOL='-2'

prog_name="${0}"

volume="${1}"
device="${2}"

# Check to see if we should do anything
if [ -z "${volume}" ] ; then
	echo "Usage: ${prog_name} VOLUME_NAME DEVICE_NAME"
	exit "${ERR_BAD_CMD}"
fi

# Check to see if the disk exists and is mounted
if ! cd /"${volume}" &>/dev/null ; then
	echo "${prog_name}: \"${volume}\" not mounted"
	exit "${ERR_NO_VOL}"
fi


#
# create var and tmp directory so the kernel can create the swap file
#
/bin/mkdir -p "/${volume}/var/tmp"


#
# First make this partition bootable
#

mountvolume -allbfs
installbootsector /"${volume}"/beos/system/zbeos

#
# now cleanup the mimetypes on the stuff installed from the common partition
#
mimeset -F /"${volume}"/optional/*



#
# Now install the boot manager
#

alert --warning --modal "Would you like to install the Be boot manager?

The Be boot manager will allow you to choose which operating system to boot when your computer starts up.

You should not do this if you have another boot manager such as PowerBoot or System Commander installed on your system." "Yes" "No"
_retval=$?
[ $_retval -eq 0 ] && /bin/bootman -d /"${volume}"/home/config/settings/bootman/MBR -b /"${volume}"


# arm the InstallerRebootScript so that old mime can be updated
mv "beos/system/boot/InstallerRebootScript.cd" "beos/system/boot/InstallerRebootScript" &>/dev/null

#
# Update existing printers with transport attributes (R4.1 only)
#

/bin/PrinterConverter "${volume}" >/dev/null
/bin/rm -f /bin/PrinterConverter

exit 0
