#!/bin/bash
#########################################################
# Copies the inputstyle file. Called by DTB Server at startup.          
# Usage: ./dtb-inputstyle                               
#                  
# Changelog:                                      
# rpm80 - initial creation
#########################################################

# Import definitions
CMD=$(basename $0)
if [ -f /opt/dtb/bin/_common_definitions ]; then
	. /opt/dtb/bin/_common_definitions
else
	logger -t $CMD -p ERROR -s "The /opt/dtb/bin/_common_definitions file does not exist, exiting the script..."
	exit 1
fi

style=$(readConfigXML "inputstyle")
	
plog "Reading the inputstyle..."
if [ "$style" != "" ]; then # This file is created by the portal
	newfile="$DTB_DRBD_SHARE/DTBServer/winedir/inputstyle.txt"
	touch $newfile
	if [[ "$style" == "D" ]]; then
		plog "The input style is D (DTB)"
		echo "4" > $newfile
		exit 4
	elif [[ "$style" == "S" ]]; then
		plog "The input style is S (SMS)"
		echo "5" > $newfile
		exit 5
	else
		plog "The input style is unknown. Exiting the script..."
		exit 1
	fi
else
	plog "ERROR: The inputstyle parameter does not exist, exiting the script..."
	exit 1
fi
