#! /bin/sh -efu

#
# Moodle install tools
#
# @package   mt-install
# @copyright 2012 Aleksey Avdeev <solo@altlinux.ru>
# @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later
#

PROG="${0##*/}"

PATH="/usr/sbin:$PATH"

moodledir='/var/www/webapps/moodle'
configfilename='config.php'
configfile="$moodledir/$configfilename"

. shell-error

TEMP=`getopt -n "$PROG" -o c:,f: -l config:,file: -- "$@"`
eval set -- "$TEMP"

while :; do
	case "$1" in
		--)
			shift
			break
			;;
		-c|-f|--config|--file)
			shift
			configfile="$1"
			;;
		*) fatal "Unrecognized option: $1"
			;;
	esac
	shift
done

if [ -r "$configfile" ]; then
	mt-getCFG --file="$configfile" dbtype 2>/dev/null
else
	fatal "No read $configfile"
fi
