| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #!/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
- echo V /dev/watchdog
- }
- 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 /mnt/UDISK/run/bak
- find /mnt/UDISK/run/run -type f \( -not -name "*.db" -and -not -name "*.ini" \) -exec rm -f {} +
- }
- 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 -xpkf $tmpdir/pdutar -C / >/dev/null 2>&1
- if [ -e $tmpdir/logo.png ]; then
- cp -f $tmpdir/logo.png /mnt/UDISK/run/app/image/
- fi
- if [ -e $tmpdir/smartPDU.ini ]; then
- cp -f $tmpdir/smartPDU.ini /mnt/UDISK/run/app/
- cp -f $tmpdir/smartPDU.ini /mnt/UDISK/run/app/smartPDU_bak.ini
- chmod 777 /mnt/UDISK/run/app/*
- rm -rf /mnt/UDISK/run/bak/*
- fi
- rm -rf $tmpdir
- set_net
- echo +++++++ upgrade ok! +++++++
- echo reboot device
- reboot -d 1
- exit 0
|