1#!/bin/bash
2#  pls add rules to udev, this can execute our background program automatically.
3#  wangxiaoming 201012
4#  SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v1C9Ep9905*", KERNEL=="ttyACM*", ATTRS{bInterfaceNumber}=="00", ATTRS{bInterfaceProtocol}=="01", NAME="ttyUSB_lct_modem", RUN+="/bin/sh /sbin/startUSBModem"
5
6export DISPLAY=":0"
7export XAUTHLOCALNAME=`hostname`
8LOGFILE="/tmp/lcActiveUSBModem.log"
9
10echo " start to active USBModem!!! ====" > $LOGFILE
11
12if [ "$(ps aux | grep -v grep | grep USBModem.jar  | awk '{print $2}')" != "" ]
13then
14	echo " USBModem has been started up!!! ====" > $LOGFILE
15	exit 0
16fi
17
18echo " start to check $1!!! ====" >> $LOGFILE
19if [ "$1" != "" ]
20then 
21	exec $1
22	exit 0
23fi
24
25echo " start to check /etc/default/locale!!! ====" >> $LOGFILE
26if [ -r /etc/default/locale ]; then
27  . /etc/default/locale
28  export LANG LANGUAGE
29elif [ -r /etc/environment ]; then
30  . /etc/environment
31  export LANG LANGUAGE
32fi
33
34echo " start to check /etc/lcUSBCard!!! ====" >> $LOGFILE
35if [ -f /etc/lcUSBCard ]
36then
37    . /etc/lcUSBCard
38    echo ""$path/$name""
39    if [ -x "$path/$name" ]
40    then
41       echo " start to execute $path/$name!!! ====" >> $LOGFILE
42       exec "$path/$name"
43       exit 0
44    fi
45fi
46echo " check /etc/lcUSBCard failure!!! ====" >> $LOGFILE
47