#!/usr/bin/env bash

# Read in language
source ${BBROOTDIR}/lang/${BBLANG}/mount.lang

# Read in functions
source ${BBROOTDIR}/misc/commonfunctions.sh
source ${BBROOTDIR}/func/mountfunc.sh

#####PROGRAM START#####
while true; do
# This is for the numbering of the menu choices. It is
# updated once before each entry printout in the menu
# except exit which should always be 0. The variable must
# be reset within this while loop or bad things will happen.
(( bb_m_c = 0 ))
# <colors>
#source "$BBROOTDIR"/misc/colors.idx
# </colors>
clear
# <table>
echo -e "${BBTABLECOLOR}${BBDECOLINE}"
echo -e "${BBTABLECOLOR}|${BBHEADCOLOR} ${BBVERSION} ${BBTABLECOLOR}|"
echo -e "${BBTABLECOLOR}${BBDECOLINE}"
echo -e "${BBTABLECOLOR}|"
echo -e "${BBTABLECOLOR}|-(${BBSUBCOLOR}$bb_mnt_menu_title${BBTABLECOLOR})"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_mnt_menu_1"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_mnt_menu_2"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_mnt_menu_3"
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} 0) $bb_mnt_menu_0"
echo -e "${BBTABLECOLOR}|"
echo -n -e "${BBINPUTCOLOR}$bb_mnt_menu_input[0-$bb_m_c] |>${BBMAINCOLOR} "
read action
echo -e "${BBCOLOROFF}"
# </table>

case $action in
	1)      # Mount device
		mount_device
		;;
	2)	# Unmount device
		umount_device
		;;
	3)	# Eject device
		eject_device
		;;
	0)	# Back to main
		break
		;;
	*)
		echo "$bb_mnt_error[0-$bb_m_c]"
		wait_for_enter
		continue
		;;
esac
done

