#!/bin/sh

# Version 1.03
# ------------

# Script to execute the "irflash.bin" binary for LINUX ONLY
# This script opens a node at run time. It gets the major
# no of the megadev and then opens a node with the major number.
# If the node is already present, it removes the node first
# and then creates a fresh node.
# The binary "irflash.bin" must be present in the same directoy
# where the script is invoked from.

# Get the major number of the megadev ioctl node
MAJOR=`grep megadev /proc/devices|awk '{print $1}'`

if [ ! x$MAJOR = x ]
then
	# major device number found
	rm -f /dev/megadev0 	# remove if already there, ignore if not.
	mknod /dev/megadev0  c $MAJOR 0
fi

# Execute the irflash binary 
#------------



#if [ `tty | grep -c pts` -gt 0 ]
#then

#if [ -f /etc/redhat-release ]
#then
#  grep -q unicode_start /etc/profile.d/lang.sh && unicode_stop && setfont
#fi

#if [ -f /etc/SuSE-release ]
#then
#	if [ -n "$LC_CTYPE" ]; then
#		case $LC_CTYPE in
#			en_US.UTF-8)	
#			;;
#			*)
#				$UNIFLAG=stopped
#				unicode_stop
#			;;
#		esac
#	fi
#fi

#fi

#OLD_TERM=$TERM
#case  $TERM in
 #    "xterm" | "linux")
#	;;
#     *) export TERM=linux;;
#esac

# Execute irflash code
/usr/sbin/irflash.bin $*
ret=$?

#----------------------------
#export TERM=$OLD_TERM
#if [ `tty | grep -c pts` -gt 0 ]
#then

#if [ -f /etc/redhat-release ]
#then
#  grep -q unicode_start /etc/profile.d/lang.sh && unicode_start && setfont
#fi

#if [ -f /etc/SuSE-release ]
#then
#	if [ -n "$LC_CTYPE" ]; then
#		case $LC_CTYPE in
#			en_US.UTF-8)	
#			if [ $UNIFLAG = "stopped" ]; then
#				unicode_start
#			fi
#			;;
#			*)
#			;;
#		esac
#	fi
#fi

#fi

exit $ret


