#!/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 # Get charger hash name MODELNAME=`/root/WebService query|busybox awk -F '[:,]' '/"ModelName"/ {gsub("[[:blank:]\"]+", "", $2); print $2}'` SERIALNUMBER=`/root/WebService query|busybox awk -F '[:,]' '/"SerialNumber"/ {gsub("[[:blank:]\"]+", "", $6); print $6}'` HOSTNAME_HASH=`echo -n $MODELNAME$SERIALNUMBER | md5sum | cut -f1 -d" "` # 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 fi # Check reset password request if [ -f "/UsbFlash/$HOSTNAME_HASH" ]; then echo [ $DATE ] USB reset webpage login password >> /Storage/SystemLog/check_upgrade_byUSB `cp -f /UsbFlash/$HOSTNAME_HASH /Storage/valid_info` 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 fi umount /dev/$MDEV ;; esac