#!/bin/sh
INSTDIR="$1"

sed s#_path_#"$INSTDIR"#g -i "$INSTDIR/etc/vizcam_1.04.emu"

if [ "/mnt/swapextensions" == "$INSTDIR" ]; then
	sed s#_type_#"MNT"#g -i "$INSTDIR/etc/vizcam_1.04.emu"
elif [ "/var/swap" == "$INSTDIR" ]; then
	sed s#_type_#"SWAP"#g -i "$INSTDIR/etc/vizcam_1.04.emu"
else
	sed s#_type_#"VAR"#g -i "$INSTDIR/etc/vizcam_1.04.emu"	
fi

if [ ! -e "$INSTDIR/keys/vizcam.srvid" ]; then
	echo "use ipk config file: vizcam.srvid"
	echo "rename $INSTDIR/keys/vizcam.srvid.vizcam > $INSTDIR/keys/vizcam.srvid"
	mv "$INSTDIR/keys/vizcam.srvid.vizcam" "$INSTDIR/keys/vizcam.srvid"
else
	echo "found user config file: vizcam.srvid"
	echo "skip ipk config file: vizcam.srvid.vizcam"
fi

if [ ! -e "$INSTDIR/keys/vizcam.provid" ]; then
	echo "use ipk config file: vizcam.provid"
	echo "rename $INSTDIR/keys/vizcam.provid.vizcam > $INSTDIR/keys/vizcam.provid"
	mv "$INSTDIR/keys/vizcam.provid.vizcam" "$INSTDIR/keys/vizcam.provid"
else
	echo "found user config file: vizcam.provid"
	echo "skip ipk config file: vizcam.provid.vizcam"
fi

if [ ! -e "$INSTDIR/keys/vizcam.conf" ]; then
	echo "use ipk config file: vizcam.conf"
	echo "rename $INSTDIR/keys/vizcam.conf.vizcam > $INSTDIR/keys/vizcam.conf"
	mv "$INSTDIR/keys/vizcam.conf.vizcam" "$INSTDIR/keys/vizcam.conf"
else
	echo "found user config file: vizcam.conf"
	echo "skip ipk config file: vizcam.conf.vizcam"
fi


exit 0