#!/bin/sh

echo "========================================="
echo "1. sync for /core/Coredump.gz"
echo "========================================="
echo "sync"
sync
echo "sync"
sync

echo ""
echo "========================================="
echo "2. Insert usb modules"
echo "========================================="

/etc/Scripts/usb_start.sh

if [ -e /dtv/usb/sda1 ]
then
	UDIR=/dtv/usb/sda1
fi
if [ -e /dtv/usb/sda ]
then
	UDIR=/dtv/usb/sda
fi
if [ -e /dtv/usb/sda0 ]
then
	UDIR=/dtv/usb/sda0
fi
if [ -e /dtv/usb/sda2 ]
then
	UDIR=/dtv/usb/sda2
fi
if [ -e /dtv/usb/sdb ]
then
	UDIR=/dtv/usb/sdb
fi
if [ -e /dtv/usb/sdc ]
then
	UDIR=/dtv/usb/sdc
fi
if [ -e /dtv/usb/sdb1 ]
then
	UDIR=/dtv/usb/sdb1
fi
if [ -e /dtv/usb/sdc1 ]
then
    	UDIR=/dtv/usb/sdc1
fi

echo "========================================="
echo "3. Copy /core/Coredump.gz to usb"
echo "========================================="

cp /core/Coredump*.gz $UDIR

dmesg > $UDIR/kmsg.txt
cp -a /mtd_rwcommon/error_log $UDIR

echo ""
echo "========================================="
echo "4. sync for Coredump.gz in usb"
echo "========================================="
echo "sync"
sync
echo "sync"
sync

echo ""
echo "========================================="
echo "5. Copying is ended... please remove USB"
echo "========================================="
