#! /bin/sh
. ./function.sh
KeepProjectFile;
Return=$(WebUpdateCheckTarFileName);
if [ $Return -eq -1 ]; then
    ShowCheckTarFileNameError;
    Beep 4 0.001 0.5;
    exit 0;
fi
WriteStringToWebLog "Install Start";
Beep 1 1 0.001;
ClearApp;
RenameFactoryFolder;
CreatFactoryEnvironment;
DeleteOldFactoryFolder;
WriteStringToWebLog "Step1: Update Factory Firmware Successful.";
RenameAPPFolder;
WebUpdateDecompressedFile;
WriteStringToWebLog "Step2: Decompressed Firmware Successful.";
WebUpdateDeleteDecompressedFile;
DeleteServiceEnvironment;
UsbCopyEnvironment;
UsbSetEnvironment;
ChmodFile;
DeleteOldAPPFolder;
Sync;
ClearEeprom;
SetEeprom "WebUpdate";
/Init/Device_Driver/Multi_ComPort_driver.sh;
RestoreProjectFiles;
WriteStringToWebLog "Step3: WebUpdate OK.";
DeleteWebRedundantFile;
Beep 1 1 0.5;
Beep 1 1 0.001;
sleep 5
reboot