| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #!/bin/sh
- tmpdir=tmp
- function is_ipv6()
- {
- var="$1"
- regex='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$'
- if [[ $var =~ $regex ]]; then
- return 1
- else
- return 0
- fi
- }
- function kill_all()
- {
- killall RestartApp.sh smartMornitor.sh smartMonitor.sh main snmpd Qt_Test smartPDU smartUPG
- }
- 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*
- rm -rf /root/run
- }
- function set_net()
- {
- netfile=/etc/network/interfaces
- content=$(cat $netfile)
-
- if [[ $content == *"address"* ]]; then
- return
- fi
- ip4=192.168.1.132
- mask4=255.255.255.0
- gw4=192.168.1.1
- str_lo="auto lo\niface lo inet loopback\n\n"
- str_e0="auto eth0\niface eth0 inet static\naddress $ip4\nnetmask $mask4\ngateway $gw4\n\n"
- str_e1="auto eth1\niface eth1 inet dhcp\npre-up /etc/network/nfs_check\nwait-delay 5\nhostname $(hostname)\n"
-
- echo -e $str_lo > $netfile
- echo -e $str_e0 >> $netfile
- echo -e $str_e1 >> $netfile
- ifconfig eth0 $ip4
- }
- kill_all
- rm_old
- echo release $obj ...
- tar -xpf $tmpdir/pdutar -C / >/dev/null 2>&1
- if [ -e $tmpdir/logo.png ]; then
- cp -f $tmpdir/logo.png /root/run/app/image/
- fi
- if [ -e $tmpdir/smartPDU.ini ]; then
- cp -f $tmpdir/smartPDU.ini /root/run/app/
- cp -f $tmpdir/smartPDU.ini /root/run/app/smartPDU_bak.ini
- rm -rf /root/bak/*
- fi
- rm -rf $tmpdir
- set_net
- echo +++++++ upgrade ok! +++++++
- echo reboot device
- reboot -d 1
- exit 0
|