#!/bin/sh obj=pdutar function kill_all() { killall RestartApp.sh smartMornitor.sh smartMonitor.sh main snmpd Qt_Test smartPDU } function rm_old() { echo rm old files ... 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\ auto eth1\n\ iface eth1 inet dhcp\n\ pre-up /etc/network/nfs_check\n\ wait-delay 5\n\ hostname $(hostname)\n" echo -e $text > /etc/network/interfaces ifconfig eth0 $curIP up } kill_all rm_old shopt -s extglob echo rm home files except for $obj rm -rf !("$obj") shopt -u extglob echo release $obj ... tar -xpf $obj -C / >/dev/null 2>&1 rm $obj chg_net echo +++++++ upgrade ok! +++++++ echo reboot device now ... reboot -f