#!/bin/sh case "$ACTION" in add|"") DATE=`date +%Y-%m-%d_%H:%M:%S` result=1 # cat /dev/null > /Storage/SystemLog/check_upgrade_byUSB echo [ $DATE ] /dev/$MDEV detected. >> /Storage/SystemLog/check_upgrade_byUSB mount /dev/$MDEV /UsbFlash # Check upgrade image list file exist and process upgrade logic if [ -f "/UsbFlash/upgrade_image_list" ]; then # Copy image file to target while read -r filename; do `cp -f /UsbFlash/$filename /mnt` if [ $? -ne 0 ]; then result=0 echo [ $DATE ] copy /UsbFlash/$filename to /mnt fail. >> /Storage/SystemLog/check_upgrade_byUSB else echo [ $DATE ] copy /UsbFlash/$filename to /mnt success. >> /Storage/SystemLog/check_upgrade_byUSB fi done < /UsbFlash/upgrade_image_list # Trigger upgrade event if [ $result -eq 1 ]; then echo [ $DATE ] copy all image list on upgrade_image_list to /mnt success and trigger upgrade event. >> /Storage/SystemLog/check_upgrade_byUSB `/root/WebService upgrade /mnt/` else echo [ $DATE ] copy all image list on upgrade_image_list to /mnt occur error. >> /Storage/SystemLog/check_upgrade_byUSB fi else echo [ $DATE ] USB disk can not find upgrade_image_list file >> /Storage/SystemLog/check_upgrade_byUSB fi # Check copy log to usb file exist if [ -f "/UsbFlash/cp_log" ]; then `cp -f -r /Storage/ /UsbFlash/` if [ $? -ne 0 ]; then echo [ $DATE ] copy /Storage/ to /UsbFlash/ fail. >> /Storage/SystemLog/check_upgrade_byUSB else echo [ $DATE ] copy /Storage/ to /UsbFlash/ success. >> /Storage/SystemLog/check_upgrade_byUSB fi else echo [ $DATE ] USB disk can not find cp_log file >> /Storage/SystemLog/check_upgrade_byUSB fi umount /dev/$MDEV ;; esac