#! /bin/sh
# XPD_BUS	- bus name
# XPD_NAME	- xpd name
# XPD_TYPE	- xpd type number (from protocol reply):
#			3 - FXS
#			4 - FXO
# XPD_REVISION	- xpd revision number

set -e

LOGGER="logger -i -t `basename $0`"

INIT_DIR=`dirname $0`
BASE=/proc/xpp

SLICS="$BASE/$XPD_BUS/$XPD_NAME/slics"
FILE="$INIT_DIR/init_data_${XPD_TYPE}_${XPD_REVISION}.cmd"

if [ ! -f "$SLICS" ]; then
	$LOGGER "missing slics file '$SLICS'"
	exit 1
fi

if [ ! -f "$FILE" ]; then
	$LOGGER "missing register initialization file '$FILE'"
	exit 1
fi

case "$XPD_TYPE" in
3|4)
	cat "$FILE" > "$SLICS" 
	;;
*)
	$LOGGER "Unknown type '$XPD_TYPE'"
	exit 2
esac
$LOGGER "Wrote '$FILE' into '$SLICS'"

exit 0
