#!/bin/sh
TMP=/tmp/.keys
PLUGINDIR=/var/keys
PLUGINDIR=/var/bin
CONFIGDIR=/var/etc
echo "successfully installed"
echo "syncing disk"
sync
if [ `df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | tail -n1 | wc -l` -eq 1 ]; then
	SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | tail -n1`
	FREE=`expr $SPACE - 100`
	echo new freespace size $FREE kb
fi

if [ ! -e /var/keys/cwshare.cfg ]; then
	echo "use ipk config file: cwshare.cfg"
	echo "rename /var/keys/cwshare.cfg.kbox > /var/keys/cwshare.cfg"
	mv /var/keys/cwshare.cfg.kbox /var/keys/cwshare.cfg
else
	echo "found user config file: cwshare.cfg"
	echo "skip ipk config file: cwshare.cfg.kbox"
fi

if [ ! -e /var/keys/kbox_cfg ]; then
	echo "use ipk config file: kbox_cfg"
	echo "rename /var/keys/kbox_cfg.kbox > /var/keys/kbox_cfg"
	mv /var/keys/kbox_cfg.kbox /var/keys/kbox_cfg
else
	echo "found user config file: kbox_cfg"
	echo "skip ipk config file: kbox_cfg.kbox"
fi

if [ ! -e /var/keys/nwcdcs.cfg ]; then
	echo "use ipk config file: nwcdcs.cfg"
	echo "rename /var/keys/nwcdcs.cfg.kbox > /var/keys/nwcdcs.cfg"
	mv /var/keys/nwcdcs.cfg.kbox /var/keys/nwcdcs.cfg
else
	echo "found user config file: nwcdcs.cfg"
	echo "skip ipk config file: nwcdcs.cfg.kbox"
fi

exit 0