#!/bin/sh obj=pdutar function kill_proc() { proc=$1 kill -9 $(ps | grep $proc | grep -v grep | awk '{print $1}') } function kill_all() { kill_proc smartMonitor.sh killall RestartApp.sh smartMornitor.sh smartMonitor.sh snmpd Qt_Test smartPDU sleep 1 echo V > /dev/watchdog sleep 1 echo V > /dev/watchdog } function rm_old() { rm -f /etc/init.d/S90PDUStart rm -rf /usr/local/snmpd rm -f /usr/lib/libnetsnmp* rm -f /usr/sbin/smartMornitor.sh rm -f /usr/libmpr.so /usr/libhttp.so /usr/lib/libesp.o /usr/lib/libmodbus* } function chg_net() { curIP=`ifconfig eth0 |sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'` text="# interface file auto-generated by buildroot\n\ \n\ auto lo\n\ iface lo inet loopback\n\ \n\ auto eth0\n\ iface eth0 inet static\n\ address $curIP\n\ netmask 255.255.255.0\n\ gateway 192.168.1.1\n\ \n" echo -e $text > /etc/network/interfaces ifconfig eth0 $curIP } kill_all #rm_old cd /mnt/UDISK #rm -rf web fw mkdir -p /tmp/upgrade echo release $obj tar -zxvf $obj -C /tmp/upgrade > /dev/null 2>&1 cd /tmp/upgrade find /tmp/upgrade -type f > /tmp/upgrade.log PORT_FILE="/tmp/upgrade/mnt/UDISK/app/smartPDU_PhList.ini /tmp/upgrade/mnt/UDISK/app/smartPDU.ini /tmp/upgrade/mnt/UDISK/app/pdu_dat.db /tmp/upgrade/mnt/UDISK/app/pdu_dat_bak.db" no_cp_flag=0 while IFS= read -r line; do flag=0 for n in $PORT_FILE do if [[ $n == $line ]];then no_cp_flag=1 break; fi done if [[ $no_cp_flag -ne 1 ]]; then #echo $line detection="${line:12}" dir=`/usr/bin/dirname $detection` if [[ ! -d $dir ]];then mkdir -p $dir fi #cp file to dir cp $line $detection echo "cp $line $detection" fi done < /tmp/upgrade.log #delete file upgrade rm -rf /tmp/upgrade/* rm /tmp/upgrade.log cd /mnt/UDISK #delete obj rm -f $obj sync sync #chg_net echo ++++ upgrade ok! ++++ echo ++++ reboot now! ++++ reboot -d 1 exit 0