check_upgrade_byUSB.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. case "$ACTION" in
  3. add|"")
  4. DATE=`date +%Y-%m-%d_%H:%M:%S`
  5. result=1
  6. # cat /dev/null > /Storage/SystemLog/check_upgrade_byUSB
  7. echo [ $DATE ] /dev/$MDEV detected. >> /Storage/SystemLog/check_upgrade_byUSB
  8. mount /dev/$MDEV /UsbFlash
  9. # Check upgrade image list file exist and process upgrade logic
  10. if [ -f "/UsbFlash/upgrade_image_list" ]; then
  11. # Copy image file to target
  12. while read -r filename;
  13. do
  14. `cp -f /UsbFlash/$filename /mnt`
  15. if [ $? -ne 0 ]; then
  16. result=0
  17. echo [ $DATE ] copy /UsbFlash/$filename to /mnt fail. >> /Storage/SystemLog/check_upgrade_byUSB
  18. else
  19. echo [ $DATE ] copy /UsbFlash/$filename to /mnt success. >> /Storage/SystemLog/check_upgrade_byUSB
  20. fi
  21. done < /UsbFlash/upgrade_image_list
  22. # Trigger upgrade event
  23. if [ $result -eq 1 ]; then
  24. echo [ $DATE ] copy all image list on upgrade_image_list to /mnt success and trigger upgrade event. >> /Storage/SystemLog/check_upgrade_byUSB
  25. `/root/WebService upgrade /mnt/`
  26. else
  27. echo [ $DATE ] copy all image list on upgrade_image_list to /mnt occur error. >> /Storage/SystemLog/check_upgrade_byUSB
  28. fi
  29. else
  30. echo [ $DATE ] USB disk can not find upgrade_image_list file >> /Storage/SystemLog/check_upgrade_byUSB
  31. fi
  32. # Check copy log to usb file exist
  33. if [ -f "/UsbFlash/cp_log" ]; then
  34. `cp -f -r /Storage/ /UsbFlash/`
  35. if [ $? -ne 0 ]; then
  36. echo [ $DATE ] copy /Storage/ to /UsbFlash/ fail. >> /Storage/SystemLog/check_upgrade_byUSB
  37. else
  38. echo [ $DATE ] copy /Storage/ to /UsbFlash/ success. >> /Storage/SystemLog/check_upgrade_byUSB
  39. fi
  40. else
  41. echo [ $DATE ] USB disk can not find cp_log file >> /Storage/SystemLog/check_upgrade_byUSB
  42. fi
  43. umount /dev/$MDEV
  44. ;;
  45. esac