1#!/bin/bash 2CONFNAME=runlcactivator 3START_CONFNAME=S99$CONFNAME 4STOP_CONFNAME=K10$CONFNAME 5 6 7if [ "$(ps aux | grep -v grep | grep LCACTIVOR.jar | awk '{print $2}')" != "" ] 8then 9 kill -9 $(ps aux | grep -v grep | grep LCACTIVOR.jar | awk '{print $2}') 10fi 11 12 13INSTALL_PATH=$1 14 15#create active programe shell script wangxiaoming 201012 16 17echo -e "#!/bin/bash" > $INSTALL_PATH/LCACTIVOR.sh 18 19echo -e "if [ \"\$(ps aux | grep -v grep | grep LCACTIVOR.jar | awk '{print \$2}')\" != \"\" ]" >> $INSTALL_PATH/LCACTIVOR.sh 20echo -e "then" >> $INSTALL_PATH/LCACTIVOR.sh 21echo -e "exit" >> $INSTALL_PATH/LCACTIVOR.sh 22echo -e "fi" >> $INSTALL_PATH/LCACTIVOR.sh 23 24echo -e "export JAVA_HOME=${INSTALL_PATH}/java/jre1.5.0_15" >> $INSTALL_PATH/LCACTIVOR.sh 25echo -e "export CLASSPATH=${INSTALL_PATH}/java/jre1.5.0_15/lib:." >> $INSTALL_PATH/LCACTIVOR.sh 26echo -e "APPDIR=${INSTALL_PATH}" >> $INSTALL_PATH/LCACTIVOR.sh 27echo -e "cd \${APPDIR}" >> $INSTALL_PATH/LCACTIVOR.sh 28echo -e "\${APPDIR}/java/jre1.5.0_15/bin/java -Djava.library.path=\${APPDIR}/lib -jar LCACTIVOR.jar &" >> $INSTALL_PATH/LCACTIVOR.sh 29chmod +x $INSTALL_PATH/LCACTIVOR.sh 30 31cp $INSTALL_PATH/active/lcAutoStart.desktop /etc/xdg/autostart/ 32chmod a+x /etc/xdg/autostart/lcAutoStart.desktop 33echo "rm -f /etc/xdg/autostart/lcAutoStart.desktop" >> $INSTALL_PATH/active/active_uninstall 34 35for AUTORUNPATH in `find /home/ -mount -name "[Aa]utostart" -type d`; 36do 37 38 39 echo "AUTORUNPATH=$AUTORUNPATH" 40 if [ -d $ADDRUNLEVEL ] ; then 41 cp $INSTALL_PATH/active/lcAutoStart.desktop $AUTORUNPATH 42 chmod a+x $AUTORUNPATH/lcAutoStart.desktop 43 echo "rm -f $AUTORUNPATH/lcAutoStart.desktop" >> $INSTALL_PATH/active/active_uninstall 44 fi 45done 46for AUTORUNPATH in `find /root/ -mount -name "[Aa]utostart" -type d`; 47do 48 echo "AUTORUNPATH=$AUTORUNPATH" 49 if [ -d $ADDRUNLEVEL ] ; then 50 cp $INSTALL_PATH/active/lcAutoStart.desktop $AUTORUNPATH 51 chmod a+x $AUTORUNPATH/lcAutoStart.desktop 52 echo "rm -f $AUTORUNPATH/lcAutoStart.desktop" >> $INSTALL_PATH/active/active_uninstall 53 fi 54done 55 56 57#install the configuration file for auto run in boot 58sed "s#CURPATH#${INSTALL_PATH}#g" $INSTALL_PATH/active/skeleton > $INSTALL_PATH/active/skeleton.bak 59 60sed "s#parameter#$2#g" $INSTALL_PATH/active/skeleton.bak > $INSTALL_PATH/active/$CONFNAME 61 62rm -f $INSTALL_PATH/active/skeleton.bak 63 64 65 66if [ -d /etc/init.d ] 67then 68 cp -f $INSTALL_PATH/active/$CONFNAME /etc/init.d/ 69 chmod a+x /etc/init.d/$CONFNAME 70 CONFPATH=/etc/init.d 71elif [ -d /etc/rc.d ] 72then 73 cp -f $INSTALL_PATH/active/$CONFNAME /etc/rc.d/ 74 chmod a+x /etc/rc.d/$CONFNAME 75 CONFPATH=/etc/rc.d 76fi 77 78echo "rm -f $CONFPATH/$CONFNAME" >> $INSTALL_PATH/active/active_uninstall 79 80#use command 81for ADDRUNLEVEL in `find /etc/ -name "rc[2345].d" -type d`; 82do 83 echo "ADDRUNLEVEL=$ADDRUNLEVEL" 84 if [ -d $ADDRUNLEVEL ] ; then 85 if [ -L "$ADDRUNLEVEL/$START_CONFNAME" ] ; then 86 rm -f $ADDRUNLEVEL/$START_CONFNAME 87 rm -f $ADDRUNLEVEL/$STOP_CONFNAME 88 fi 89 ln -sv $CONFPATH/$CONFNAME $ADDRUNLEVEL/$START_CONFNAME 90 chmod a+x $ADDRUNLEVEL/$START_CONFNAME 91 ln -sv $CONFPATH/$CONFNAME $ADDRUNLEVEL/$STOP_CONFNAME 92 chmod a+x $ADDRUNLEVEL/$STOP_CONFNAME 93 94 echo "rm -f $ADDRUNLEVEL/$START_CONFNAME" >> $INSTALL_PATH/active/active_uninstall 95 echo "rm -f $ADDRUNLEVEL/$STOP_CONFNAME" >> $INSTALL_PATH/active/active_uninstall 96 fi 97done 98 99if [ -f /etc/init.d/.depend.start ] 100then 101 rm -f /etc/init.d/.depend.start 102 rm -f /etc/init.d/.depend.stop 103 chkconfig -a runlcactivator 104fi 105 106 107 108cp "$INSTALL_PATH"/active/startUSBModem /sbin/ 109chmod a+x /sbin/startUSBModem 110echo "rm -f /sbin/startUSBModem" >> "$INSTALL_PATH"/active/active_uninstall 111 112#"$INSTALL_PATH"/LCACTIVOR.sh 113#"$INSTALL_PATH"/USBModem>>/dev/null 2>&1 114