#!/bin/sh

if [ "$1" = "start" -o "$1" = "restart" ]
then
     echo "************** SOFTWARE VERSION CMS5_BB_03.17 *****************"

     /usr/bin/vol_cntrl 10

     cp /media1/sda1/UPGRADE_FILES/BB/APPS/INIT_FILES/cms5_flash_manager /etc/rc.d/init.d/

     cp /media2/sda1/UPGRADE_FILES/BB/APPS/INIT_FILES/cms5_flash_manager /etc/rc.d/init.d/

     cp /media1/sda/UPGRADE_FILES/BB/APPS/INIT_FILES/cms5_flash_manager /etc/rc.d/init.d/

     cp /media2/sda/UPGRADE_FILES/BB/APPS/INIT_FILES/cms5_flash_manager /etc/rc.d/init.d/

     chmod 777 /etc/rc.d/init.d/cms5_flash_manager
#To increase file index limit
	ulimit -n 65536     
     sync

# tmpfs filesystm is mounted on /var for handling usb sqlite db. 
    mount -vt tmpfs tmpfs /var
    mount -vt tmpfs tmpfs /tmp
   
    echo "Starting the System Init: "
	/usr/bin/systemInit &
    
	/usr/bin/vol_cntrl 0
    echo "Starting the PCM Init: "
	/usr/bin/SetFormat &

    echo "Loading the Radio Driver: "
	insmod /usr/bin/radio-i2c-si470x.ko

    echo "Starting the SysStateMachine Manager: "
         nice -n -11 /usr/bin/sysstatemachine &

    echo "Starting the Clarion DM Manager: "
	nice -n -8 /usr/bin/DisplayManager &

    echo "Starting the Clarion MW4 Manager: "
	/usr/bin/DM_MW4_ifl &

    echo "Starting the Clarion MW1 Manager: "
	/usr/bin/DM_MW1 &

	sleep 5

    echo "Starting the SiriusXM server Applications: "
	/usr/bin/SiriusXM &

    echo "Starting the Clarion AUX Applications: "
	    nice -n -10 /usr/bin/audiomuxserver &

    echo "Starting the Clarion Video Applications: "
	    nice -n -10 /usr/bin/videomuxserver &

    echo "Starting the Clarion Tuner Applications: "
	/usr/bin/tunermanager &
   
    echo "Starting the USB Audio server Applications: "
    nice -n -19 /usr/bin/usbaudioserver &

    echo "Starting the USB 1 Media server Applications: "
        nice -n -12 /usr/bin/usbmediaserver 1 &

    echo "Starting the USB 2 Media server Applications: "
        nice -n -12 /usr/bin/usbmediaserver 2 &


    echo "Starting the Audio server Applications: "
	    nice -n -8 /usr/bin/audioserver &

    sleep 2

    echo "Starting the Ipod server Applications: "
	    /usr/bin/ipodMediaServer &

    echo "Starting the Pandora Applications: "
	/usr/bin/Pandora &

	sleep 5

    echo "Starting the BT Media server Applications: "
	/usr/bin/btmserver &

    echo "Starting the HF server Applications: "
	/usr/bin/hfserver &

    echo "Starting Can interface ....."	
 	ifconfig can0 up	

 	ifconfig can1 up			
fi
