| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #!/bin/sh
- obj=pdutar
- 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*
- }
- function set_net()
- {
- ip4=`ip addr show dev eth0 | sed -e's/^.*inet \([^ ]*\)\/.*$/\1/;t;d'`
- ip6=`ip addr show dev eth0 | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d'`
- str_lo="auto lo\niface lo inet loopback\n\n"
- str_e0="auto eth0\niface eth0 inet static\naddress $ip4\nnetmask 255.255.255.0\ngateway 192.168.1.1\n\n"
-
- if [ "$ip6" = "" ]; then
- echo ___$ip6
- fi
-
- str_e1="auto eth1\niface eth1 inet dhcp\npre-up /etc/network/nfs_check\nwait-delay 5\nhostname $(hostname)\n"
- netfile=/etc/network/interfaces
- echo -e $str_lo > $netfile
- echo -e $str_e0 >> $netfile
- echo -e $str_e1 >> $netfile
- }
- 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
- #set_net
- echo +++++++ upgrade ok! +++++++
- echo reboot device now ...
- reboot
|