#! /bin/sh

killshell()
{
	for i in `pidof sh` ; do
		if [ -n "`ps -ef | grep $1 | grep $i`" ] ; then
			kill -9 $i
		fi
	done
}

kill1800()
{
	for i in `pidof sleep` ; do
		if [ -n "`ps -ef | grep sleep | grep $i`" ] ; then
			kill -9 $i
		fi
	done
}


# Stop all init scripts in /MMP/etc/start.d
# executing them in numerical order.
#
for i in /DISK2/etc/service.d/S??* ;do

     # Ignore dangling symlinks (if any).
     [ ! -f "$i" ] && continue

     case "$i" in
	*.sh)
	    # Source shell script for speed.
	    (
		trap - INT QUIT TSTP
		set stop
		. $i
	    )
	    ;;
	*)
	    # No sh extension, so fork subprocess.
	    $i stop
	    ;;
    esac
done

# User defined shell
# Stop all init scripts in /DISK2/etc/start.d
# executing them in numerical order.
#
for i in /DISK2/etc/start.d/S??* ;do

     # Ignore dangling symlinks (if any).
     [ ! -f "$i" ] && continue

     case "$i" in
	*.sh)
	    # Source shell script for speed.
	    (
		trap - INT QUIT TSTP
		set stop
		. $i
	    )
	    ;;
	*)
	    # No sh extension, so fork subprocess.
	    $i stop
	    ;;
    esac
done


chmod 755 /tmp/kill_EMUs.sh
/tmp/kill_EMUs.sh

/MMP/usr/bin/snice DStar +0
killall -9 JIPC_Server
killall -9 SDecoderServer
killall -9 event_dispatcher
killall -9 app_control
killall -9 ir_control
killall -9 file_control
killall -9 rssfeed
killall -9 Polaris
killall -9 browser_control
killall -9 emu_module
killall -9 sample_module
killall -9 CRTVSetup
killall -9 E_TUNER.A
killall -9 SeleneTVCore
killall -9 CRTVCore
killall -9 TEMSControl
killall -9 TVPortal_Player
killall -9 TVPortalCore
killall -9 youtube_player
killall -9 radio_test
killall -9 detector_test
killall -9 boot_controler
killall -9 update_agent
killall -9 inadyn-advanced
killall -9 DStar
killall -9 EStar
killall -9 JPlugins

killall -9 nmbd
killall -9 smbd

################################################# unmount djmount
UPNP_MNT_DIR=/DATA/upnp
/MMP/usr/bin/fusermount -u $UPNP_MNT_DIR
/MMP/etc/init.d/ushare stop
################################################# 

rm -rf /tmp/WriteDir

rmmod fuse
rmmod cdfs
rmmod sr_mod
rmmod cdrom
rmmod ftdi_sio
rmmod usbserial
rmmod sckernel
rmmod em8xxxfb
rmmod em8xxx
rmmod llad

rm -f /tmp/.start_ok
#if [ -f /tmp/.sleep ] && [ "`cat /tmp/.sleep | awk '{print $1}'`" = "1" ] ; then
#	killall -9 update_agent
#	killshell update_script.sh
#	kill1800
#	rm -f /tmp/.start_update
#	sync
	#/sbin/hdparm -S 1 /dev/hda
#	/MMP/usr/bin/sleep_agent &
#fi

