#! /bin/bash

. ./function.sh

ClearEeprom;
ShowStartInstall;

Return=$(SetStaticIP);
if [ $Return -eq -1 ]; then
    ShowNetworkConnectionError;
    Beep 4 0.001 0.5;
    exit 0;
fi

#Beep 1 1 0.001;
ClearApp;
RemoveApp;
CopyFactoryFileToEnvironment;

Return=$(ComparisonFactoryTarFile);
if [ $Return -eq -1 ]; then
    ShowComparisonTarFileError;
    Beep 4 0.001 0.5;
    exit 0;
fi

DecompressedFile;
CopyEnvironment;
SetEnvironment;
ChmodFile;
Install_openvpn_if_needed;
DeleteFactoryResidualFile;
clear_openvpn_conf;
ResetFirewall;
ClearRestartUnit;
Sync;
SetEeprom "Restore Factory Settings Successfully";
UpdateComPortSetting;
sync;
ShowInstallSuccess;
Beep 1 1 0.5;
Beep 1 1 0.001;
