script.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. obj=pdutar
  3. function kill_all()
  4. {
  5. killall RestartApp.sh smartMornitor.sh smartMonitor.sh main snmpd Qt_Test smartPDU
  6. }
  7. function rm_old()
  8. {
  9. echo rm old files ...
  10. rm -f /etc/init.d/S90PDUStart
  11. rm -rf /usr/local/snmpd
  12. rm -f /usr/lib/libnetsnmp*
  13. rm -f /usr/sbin/smartMornitor.sh
  14. rm -f /usr/libmpr.so /usr/libhttp.so /usr/lib/libesp.o /usr/lib/libmodbus*
  15. }
  16. function chg_net()
  17. {
  18. curIP=`ifconfig eth0 |sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'`
  19. text="# interface file auto-generated by buildroot\n\
  20. \n\
  21. auto lo\n\
  22. iface lo inet loopback\n\
  23. \n\
  24. auto eth0\n\
  25. iface eth0 inet static\n\
  26. address $curIP\n\
  27. netmask 255.255.255.0\n\
  28. gateway 192.168.1.1\n\
  29. \n\
  30. auto eth1\n\
  31. iface eth1 inet dhcp\n\
  32. pre-up /etc/network/nfs_check\n\
  33. wait-delay 5\n\
  34. hostname $(hostname)\n"
  35. echo -e $text > /etc/network/interfaces
  36. ifconfig eth0 $curIP up
  37. }
  38. kill_all
  39. rm_old
  40. shopt -s extglob
  41. echo rm home files except for $obj
  42. rm -rf !("$obj")
  43. shopt -u extglob
  44. echo release $obj ...
  45. tar -xpf $obj -C / >/dev/null 2>&1
  46. rm $obj
  47. chg_net
  48. echo +++++++ upgrade ok! +++++++
  49. echo reboot device now ...
  50. reboot -f