#!/bin/sh

# preflight.sh
# dataCard
#
# Created by raoyuanjie on 8/29/07.
# Copyright 2007 __MyCompanyName__. All rights reserved.

 
  
source "$1/Contents/Resources/common"
 
echo "preflight start!"

#add by paul:delete Driver
cd "$drv_root"

for drv_item in $drv_names; do
  if [ -e $drv_item ]; then
    echo "Delete driver $drv_item"
    kextunload "$drv_item"  ###
    rm -R "$drv_item"
  fi 
done
touch -fm "$drv_root"
 
#add by paul:delete App
cd "$app_root"
 
if [ -e "$app_name" ]; then
  echo "Delete app $app_name"
  rm -R "$app_name"
fi

#add by paul:delete LaunchDaemons *.plist
cd "$dst_launchDaemons" 

if [ -e cn.com.zte.usbfilter.plist ]; then
  echo "Delete cn.com.zte.usbfilter.plist"
  sudo rm -f cn.com.zte.usbfilter.plist
fi 

if [ -e cn.com.zte.usbswapper.plist ]; then
  echo "Delete cn.com.zte.usbswapper.plist"
  sudo rm -f cn.com.zte.usbswapper.plist
fi 

#add by paul:delete Mac_Swapperdemon  ZTEUSBFilter

  cd "$dst_filter"
 
  if [ -e ZTEUSBFilter ]; then
    echo "Delete ZTEUSBFilter"
    rm -f ZTEUSBFilter
  fi 

  if [ -e Mac_SwapperDemon.app ]; then
    echo "Delete Mac_SwapperDemon.app"
    rm -f Mac_SwapperDemon.app
  fi

#add by lixiaolei: delete LaunchAgents *.plist

  cd "$dst_launchAgents" 

  if [ -e cn.com.zte.usbfilter.plist ]; then
    echo "Delete cn.com.zte.usbfilter.plist"
    sudo rm -f cn.com.zte.usbfilter.plist
  fi 

  if [ -e cn.com.zte.usbswapper.plist ]; then
    echo "Delete cn.com.zte.usbswapper.plist"
    sudo rm -f cn.com.zte.usbswapper.plist
  fi 

 killall "Mac_SwapperDemon"
 

 
 echo "preflight end!"