#!/bin/sh                                                                       

# update 20140122

uninstall_all()
{
		#clean old DuoKan script
		rm -f /etc/rcS.d/S79switch
		rm -f /etc/rc5.d/s96rundk
		rm -f /etc/rc5.d/S96rundk
		rm -f /etc/rc5.d/rundk.sh
		rm -f /etc/rc5.d/S95dkupdate
		sync
		
		#clean new DuoKan script
		# rm -f /etc/init.d/DK_update
		# rm -f /etc/rc5.d/S79DK_update
		rm -f /etc/init.d/DK_switch
		rm -f /etc/init.d/DK_run	
		rm -f /etc/rc5.d/S95DK_switch
		rm -f /etc/rc5.d/S96DK_run
		sync
		
		rm -rf /mnt/us/DK_System/
		rm -rf /test
		#uninstall Duokan
		rm -rf /DuoKan
		rm -rf /mnt/us/DK_Mbp/
		rm -rf /mnt/us/DK_User/
		rm	-f /mnt/base/?pdate*.bin
		sync
		
		#clean something we don't now
		rm -f /dev/viewinfodat1.txt
		rm -f /dev/viewinfodat.txt
		rm -f /dev/activeevent
		rm -f /dev/usbevent
		rm -f /dev/DK_Debug.log  
		rm -f /etc/rcS.d/S79showmenu
		rm -f /etc/init.d/usb_switch
		rm -f /etc/rc5.d/usbsingle.sh

        #clean tokens
		rm -rf /var/local/evernote
        rm -rf /var/local/xiaomi
        rm -rf /mnt/us/system/*.ini
        rm -rf /mnt/us/system/*.info
        rm -rf /mnt/us/system/userfile
        rm -rf /mnt/us/system/reading.dk

		sync
}


clean_repair()
{
	echo "clean_repair"		
	rm -f /var/local/upstart/*.restarts
	rm -f /var/local/system/.framework_reboots
	rm -f /var/local/system/.framework_retries
}

######## beign to run #######
clean_repair
eips -c
eips 10 20 "Duokan is uninstalling ......"

mntroot rw
uninstall_all
ln -s /etc/init.d/framework 	/etc/rc5.d/S95framework
sync
mntroot ro

eips -c
eips 10 20 "Duokan has been uninstalled."
eips 10 22 "Rebooting ....."
reboot -f
