Universal gateway upgrade method, storage medium, and electronic device
By storing upgrade files in the USB flash drive and using the automatic upgrade method of MD5 code value verification, the problem of difficulty in upgrading a general gateway device is solved, a safe and efficient upgrade process is achieved, the possibility of human error is reduced, and the integrity and security of the file is ensured.
Patent Information
- Application Number
- CN202111600452.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2041-12-24
AI Technical Summary
The universal gateway device of the rail-side security platform is difficult to upgrade, especially in distributed equipment rooms, and the external network status affects communication reliability.
By storing upgrade files on the USB flash drive, including program files and configuration file lists, and MD5 code value files, it can be automatically upgraded using MD5 code value verification, and perform secondary verification at self-start to ensure file security and integrity.
It reduces the difficulty of upgrading the general gateway, improves the upgrade efficiency, reduces human errors, ensures the security of programs and configuration files, and avoids the impact of USB drive corruption on files.
Smart Images

Figure CN114265604B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of trackside safety platforms, and in particular to an upgrading method, storage medium and electronic equipment of a universal gateway. Background Art
[0002] At present, when the two-by-two subsystem of the trackside safety platform is directly connected to the data communication network, its reliability is easily affected by the external network status. To avoid this situation, a universal gateway device is usually added between the external network and the two-by-two subsystem to reduce the impact of the external network on it and improve the stability of communication.
[0003] Figure 1 This is a diagram showing the program files and configuration files of a general gateway device. Program files 1, 2, ..., N are the program files required by the gateway device; configuration files 1, 2, ..., M are common configuration files required by the gateway device; and the file list is a list of the file names of program files such as program file 1 and configuration file 1, the MD5 code values calculated for the files, and the file types. The specific format is as follows: Figure 2 As shown in the figure; the MD5 code value of the file list is contained in the file list.
[0004] As can be seen from the program and configuration files of the universal gateway device described above, any change to any program or general configuration file requires an upgrade of the gateway device. However, since trackside equipment is dispersed across various equipment rooms, the introduction of universal gateway devices significantly increases the difficulty of on-site equipment maintenance and upgrades. Therefore, a simple and easy-to-use configuration or program upgrade method is urgently needed. Summary of the Invention
[0005] The present invention aims to solve one of the technical problems in the related art to at least a certain extent. To this end, a first object of the present invention is to provide a method for upgrading a universal gateway to reduce the difficulty of upgrading the universal gateway.
[0006] A second object of the present invention is to provide a computer-readable storage medium.
[0007] A third object of the present invention is to provide an electronic device.
[0008] To achieve the above object, the present invention is implemented through the following technical solutions:
[0009] A method for upgrading a universal gateway comprises: obtaining an upgrade file for upgrading the universal gateway and storing the upgrade file in the root directory of a USB flash drive, wherein the upgrade file includes a file list consisting of a plurality of program files and a plurality of configuration files of the universal gateway, an MD5 code value file of the file list, and the program files or configuration files used for upgrading and updating; and inserting the USB flash drive storing the upgrade file into the universal gateway to automatically upgrade the universal gateway using the upgrade file.
[0010] Optionally, the list information of the file list includes: the file name, file type, MD5 code and upgrade flag of each program file or each configuration file, wherein the upgrade flag is used to mark the program file or configuration file to be upgraded.
[0011] Optionally, the step of automatically upgrading the universal gateway using the upgrade file includes: performing two MD5 code value checks on the upgrade file; after the two MD5 code value checks are passed, deleting the original file to be upgraded corresponding to the upgrade file in the target directory of the universal gateway, and copying the upgrade file to the target directory.
[0012] Optionally, the step of performing a first MD5 code value check on the upgrade file includes: calculating the MD5 code value of the file list, and comparing the calculated MD5 code value with the MD5 code value in the MD5 code value file in the upgrade file; if the two are equal, the first MD5 code value check passes, and the step of performing a second MD5 code value check on the upgrade file is entered; if the two are not equal, the universal gateway terminates the upgrade and sends an upgrade failure message containing a first alarm code unique identifier, where the first alarm code unique identifier is used to identify the failure of the MD5 code value check of the file list.
[0013] Optionally, the step of performing a second MD5 code value check on the upgrade file includes: opening the file list, obtaining the file name, file type, MD5 code value and upgrade flag of all files in the file list; filtering out the file name and file type of the file to be upgraded through the upgrade flag; finding the corresponding program file or configuration file for upgrading in the root directory of the U disk according to the file name and the file type; calculating the MD5 code value of the program file or the configuration file for upgrading, and comparing the calculated MD5 code value with the MD5 code value of the corresponding file to be upgraded obtained by screening; if the MD5 code values of all files to be upgraded are equal to the calculated corresponding MD5 code value, the second MD5 code value check passes; otherwise, the universal gateway terminates the upgrade and sends an upgrade failure message containing a second alarm code unique identifier, where the second alarm code unique identifier is used to identify files that need to be upgraded but fail the MD5 code value check.
[0014] Optionally, after two MD5 code value checks are passed, before deleting the original files to be upgraded in the target directory of the universal gateway, the method further includes: checking whether there is a program file among all the files to be upgraded in the target directory; if so, turning off the watchdog and terminating the operation of the program file; wherein, when an error occurs in turning off the watchdog or terminating the operation of the program file, the universal gateway terminates the upgrade and sends an upgrade failure message containing a third alarm code unique identifier, and the third alarm code unique identifier is used to identify an error in turning off the watchdog or an error in terminating the operation of the program file.
[0015] Optionally, when deleting the original file to be upgraded in the target directory of the universal gateway, if the deletion fails, the universal gateway terminates the upgrade and sends an upgrade failure message containing a fourth alarm code unique identifier, and the fourth alarm code unique identifier is used to identify the file deletion failure; and when copying the upgrade file to the target directory, if the copy fails, the universal gateway terminates the upgrade and sends an upgrade failure message containing a fifth alarm code unique identifier, and the fifth alarm code unique identifier is used to identify the file copy failure.
[0016] Optionally, after copying the upgrade file to the target directory, the method further includes: when it is checked that the files to be upgraded in the file list include program files, modifying the permissions of the program files to be executable; if the permission modification fails, the universal gateway terminates the upgrade and sends an upgrade failure message containing a sixth alarm code unique identifier to the outside, and the sixth alarm code unique identifier is used to identify the program file whose permission modification failed; if the permission modification is successful, the universal gateway sends an upgrade success message to the outside.
[0017] Optionally, before inserting the USB flash drive storing the upgrade file into the universal gateway, the method further includes: determining whether the universal gateway is being upgraded for the first time, and after determining that it is the first upgrade, deploying an upgrade environment for the universal gateway.
[0018] Optionally, the step of deploying the upgrade environment of the universal gateway includes: adding an automatic upgrade program and an automatic startup program to the system startup file to modify the system startup file; placing the automatic upgrade program and the automatic startup program in the target directory, and restarting the universal gateway.
[0019] Optionally, when sending an upgrade failure message or an upgrade success message, the universal gateway also sends a prompt message to unplug the U disk, and performs a self-starting operation after detecting that the U disk is unplugged.
[0020] Optionally, the step of executing the self-start operation includes: calculating the MD5 code value of the file list in the target directory, and comparing the calculated MD5 code value with the MD5 code value in the MD5 code value file in the target directory; if the two are not equal, the universal gateway terminates the self-start and sends a startup failure message containing a seventh alarm code unique identifier, and the seventh alarm code unique identifier is used to identify the failure of the MD5 code value verification of the file list in the target directory; if the two are equal, further opening the file list in the target directory to obtain the files in the target directory The file names and MD5 code values of all files in the list; calculating the MD5 code values of all files, and comparing the calculated MD5 code values of all files with the MD5 code values of the corresponding files in the file list in the target directory; if the MD5 code values of all files are equal to the MD5 code values of the corresponding files in the file list in the target directory, the self-start is successful; otherwise, the universal gateway terminates the self-start and sends a startup failure message containing the unique identification of the eighth alarm code, where the unique identification of the eighth alarm code is used to identify the files in the file list in the target directory that failed the MD5 code verification.
[0021] Optionally, after receiving the upgrade failure message, the cause of the upgrade failure is found through the unique identifier of the received alarm code.
[0022] Optionally, after receiving the upgrade success message, it is verified whether the upgrade of the universal gateway is successful through the upgraded version of the universal gateway.
[0023] To achieve the above-mentioned object, a second aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the above-mentioned method for upgrading the universal gateway is implemented.
[0024] To achieve the above-mentioned object, the third aspect of the present invention provides an electronic device, including a processor and a memory, wherein a computer program is stored on the memory, and when the computer program is executed by the processor, the above-mentioned universal gateway upgrade method is implemented.
[0025] The present invention has at least the following technical effects:
[0026] (1) The present invention performs MD5 code verification on program files and configuration files during the universal gateway upgrade and self-startup process, which can effectively detect damage to files caused by "bit reversal" of the USB flash drive and possible damage to written files, ensuring the security of running programs and configurations.
[0027] (2) The present invention adds an upgrade flag to the file list to indicate whether the file needs to be upgraded or updated, so that each upgrade only requires updating the changed program files or configuration files, without having to upgrade all files, effectively improving the upgrade efficiency.
[0028] (3) The present invention retains the MD5 information of files that do not need to be upgraded in the file list, and performs MD5 code verification on these files during self-startup, thereby ensuring the security of files that do not need to be upgraded.
[0029] (4) When upgrading the universal gateway, the present invention only needs to store the upgrade file in a USB flash drive according to the specified format, and then insert the USB flash drive into the universal gateway, which can effectively reduce the difficulty of upgrading the universal gateway and thus reduce the possibility of human errors introduced during the upgrade process.
[0030] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A schematic diagram of the file composition of a universal gateway provided by an embodiment of the present invention;
[0032] Figure 2 This is a schematic diagram of the existing file list;
[0033] Figure 3 A flowchart of a method for upgrading a universal gateway provided by one embodiment of the present invention;
[0034] Figure 4 A schematic diagram of a file list provided in one embodiment of the present invention;
[0035] Figure 5 A flowchart of the upgrade environment deployment process provided by an embodiment of the present invention;
[0036] Figure 6 This is a workflow diagram of a method for upgrading a universal gateway provided by one embodiment of the present invention. DETAILED DESCRIPTION
[0037] The present embodiment is described in detail below. Examples of the embodiment are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to explain the present invention, but are not to be construed as limiting the present invention.
[0038] The following describes the universal gateway upgrade method, storage medium, and electronic device of this embodiment with reference to the accompanying drawings.
[0039] Figure 3 Flowchart of a method for upgrading a universal gateway provided by an embodiment of the present invention. Figure 3 As shown, the method includes:
[0040] Step S1: Obtain the upgrade file for upgrading the universal gateway and store the upgrade file in the root directory of the USB flash drive. The upgrade file includes a file list consisting of several program files and several configuration files of the universal gateway, an MD5 code (message digest code) value file of the file list, and the program file or configuration file used for upgrading and updating.
[0041] The list information of the file list includes: the file name, file type, MD5 code and upgrade flag of each program file or each configuration file, wherein the upgrade flag is used to mark the program file or configuration file to be upgraded.
[0042] Specifically, the upgrade files required for the universal gateway upgrade include a file list consisting of several program files and several configuration files, wherein the program files and configuration files respectively include the following: Figure 1 The program files 1, 2, ..., N, and the configuration files 1, 2, ..., M are shown in FIG. It should be noted that the file list in this embodiment is the same as that in FIG. Figure 2 The list of files in is different. Figure 4 As shown, in the file list of this embodiment, an upgrade flag is added to the list information column, wherein the upgrade flag is used to mark the program file or configuration file to be upgraded. In this embodiment, the file type is distinguished by the numbers 1 and 2, such as 1 for program file and 2 for configuration file. The upgrade flag is divided into 0 and 1, 0 means that the file does not need to be upgraded, and 1 means that the file needs to be upgraded. As an example, Figure 4As shown, the program file 1 has a file type of program file and is a file that needs to be upgraded.
[0043] The upgrade file also includes the MD5 code value file of the file list, which contains the MD5 code value of the file list required for the universal gateway upgrade. The upgrade file also includes files with the upgrade flag 1 (need to be upgraded) in the file list, which include program files or configuration files.
[0044] Step S2: inserting the USB disk storing the upgrade file into the universal gateway to automatically upgrade the universal gateway using the upgrade file.
[0045] In one embodiment of the present invention, before inserting the USB disk storing the upgrade file into the universal gateway, the method further includes: determining whether the universal gateway is being upgraded for the first time, and after determining that it is the first upgrade, deploying the upgrade environment of the universal gateway.
[0046] In this embodiment, the general gateway operating system uses the CentOS6.5 server version. Figure 5 As shown, under this operating system, the steps for deploying the upgrade environment of the universal gateway include: adding an automatic upgrade program and an automatic startup program to the system startup file to modify the system startup file; placing the automatic upgrade program and the automatic startup program in the target directory, and restarting the universal gateway.
[0047] Specifically, you can add the automatic upgrade program and the automatic startup program to the CentOS 6.5 system startup file rc.local. Then, use SSH (Secure Shell) or other remote methods to log in to the universal gateway. Then, use the modified system startup file rc.local to overwrite the system startup file in the universal gateway. Place the automatic upgrade program and the automatic startup program in the target directory, such as the home directory, and restart the universal gateway. After restarting the universal gateway, the automatic upgrade program and the automatic startup program will run in the background. The automatic upgrade program is responsible for enabling the automatic upgrade of the universal gateway after detecting the USB flash drive, and the automatic startup program is responsible for the self-starting of the universal gateway after the upgrade.
[0048] It should be noted that if it is determined that the universal gateway is not being upgraded for the first time, the USB flash drive storing the upgrade file may be inserted into the universal gateway to automatically upgrade the universal gateway using the upgrade file.
[0049] Among them, the step of automatically upgrading the universal gateway through the upgrade file includes: performing two MD5 code value checks on the upgrade file; after the two MD5 code value checks pass, deleting the original file to be upgraded corresponding to the upgrade file in the target directory of the universal gateway, and copying the upgrade file to the target directory.
[0050] In one embodiment of the present invention, Figure 6 As shown, the step of performing the first MD5 code value verification on the upgrade file includes: calculating the MD5 code value of the file list, and comparing the calculated MD5 code value with the MD5 code value in the MD5 code value file in the upgrade file; if the two are equal, the first MD5 code value verification is passed, and the step of performing the second MD5 code value verification on the upgrade file is entered; if the two are not equal, the universal gateway terminates the upgrade and sends an upgrade failure message containing a first alarm code unique identifier, and the first alarm code unique identifier is used to identify the failure of the MD5 code value verification of the file list.
[0051] In one embodiment of the present invention, after receiving an upgrade failure message, the cause of the upgrade failure can be determined using the received unique alarm code identifier. For example, after receiving the upgrade failure message, the unique alarm code identifier in the upgrade failure message can be parsed and retrieved. If the retrieved unique alarm code identifier is the first unique alarm code identifier, it can be determined that the MD5 code value of the file list in the upgrade file is inconsistent with the MD5 code value file. Therefore, the upgrade file can be re-prepared and re-upgraded.
[0052] After the first MD5 code value verification of the upgrade file, if Figure 6 As shown, the upgrade file can be subjected to a second MD5 code value check, and the steps of conducting a second MD5 code value check on the upgrade file include: opening the file list, obtaining the file name, file type, MD5 code value and upgrade flag of all files in the file list; filtering out the file name and file type of the file to be upgraded through the upgrade flag; finding the corresponding program file or configuration file for upgrading in the root directory of the U disk according to the file name and file type; calculating the MD5 code value of the program file or configuration file for upgrading, and comparing the calculated MD5 code value with the MD5 code value of the corresponding file to be upgraded obtained by filtering; if the MD5 code values of all files to be upgraded are equal to the corresponding calculated MD5 code value, the second MD5 code value check passes; otherwise, the universal gateway terminates the upgrade and sends an upgrade failure message containing a second alarm code unique identifier to the outside, and the second alarm code unique identifier is used to identify files that need to be upgraded but have failed the MD5 code value check.
[0053] For example, you can open the file list and use the upgrade flag to filter out the files that need to be upgraded in the file list, such as configuration file 1. Find the corresponding configuration file in the root directory of the USB flash drive based on the file name and file type of configuration file 1 (such as a common configuration file). Then calculate the MD5 code value of the configuration file and compare it with the MD5 code value of configuration file 1 obtained when the file list is opened. When the two are consistent, it can be verified that the MD5 code value of configuration file 1 has passed the verification. Repeat the above steps to perform MD5 code value verification on all the files that need to be upgraded. When the verification fails, the file that failed the MD5 code value verification can be uniquely located by the second alarm code in the upgrade failure message.
[0054] In one embodiment of the present invention, after two MD5 code value checks are passed, before deleting the original files to be upgraded in the target directory of the universal gateway, the method further includes: checking whether there is a program file among all the files to be upgraded in the target directory; if so, turning off the watchdog and terminating the operation of the program file; wherein, when an error occurs in turning off the watchdog or terminating the operation of the program file, the universal gateway terminates the upgrade and sends an upgrade failure message containing a third alarm code unique identifier, and the third alarm code unique identifier is used to identify an error in turning off the watchdog or an error in terminating the operation of the program file.
[0055] Specifically, before deleting the existing files to be upgraded in the universal gateway's target directory, the system can check whether any program files exist among all files to be upgraded in the universal gateway's target directory, such as the home directory. If so, the program files must be terminated. In this embodiment, the third alarm code can be used to uniquely identify whether the cause of the universal gateway upgrade failure was a watchdog shutdown error or a program file termination error.
[0056] In one embodiment of the present invention, when deleting the original file to be upgraded in the target directory of the universal gateway, if the deletion fails, the universal gateway terminates the upgrade and sends an upgrade failure message containing a fourth alarm code unique identifier to the outside, such as to the security platform maintenance device, and the fourth alarm code unique identifier is used to identify the failure of file deletion; and when copying the upgrade file to the target directory, if the copy fails, the universal gateway terminates the upgrade and sends an upgrade failure message containing a fifth alarm code unique identifier to the outside, such as to the security platform maintenance device, and the fifth alarm code unique identifier is used to identify the failure of file copying.
[0057] Furthermore, after copying the upgrade file to the target directory, the method also includes: when it is checked that the files to be upgraded in the file list include program files, the permissions of the program files are modified to be executable; if the permission modification fails, the universal gateway terminates the upgrade and sends an upgrade failure message containing a sixth alarm code unique identifier to the outside, and the sixth alarm code unique identifier is used to identify the program file whose permission modification failed; if the permission modification is successful, the universal gateway sends an upgrade success message to the outside.
[0058] In this embodiment, the permissions of all program files that need to be upgraded need to be modified and made executable. If the permission modification fails, the file for which the permission modification failed can be found using the sixth alarm code. If the permission modification is successful, the universal gateway sends an upgrade success message to the security platform maintenance device.
[0059] In one embodiment of the present invention, when sending an upgrade failure message or an upgrade success message, the universal gateway also sends a prompt message to unplug the USB disk, and performs a self-starting operation after detecting that the USB disk is unplugged.
[0060] Among them, the steps of executing the self-start operation include: calculating the MD5 code value of the file list in the target directory, and comparing the calculated MD5 code value with the MD5 code value in the MD5 code value file in the target directory; if the two are not equal, the universal gateway terminates the self-start and sends a startup failure message containing a seventh alarm code unique identifier, and the seventh alarm code unique identifier is used to identify the failure of the MD5 code value verification of the file list in the target directory; if the two are equal, further opening the file list in the target directory to obtain the file names and MD5 code values of all files in the file list in the target directory; calculating the MD5 code values of all files, and comparing the calculated MD5 code values of all files with the MD5 code values of the corresponding files in the file list in the target directory; if the MD5 code values of all files are equal to the MD5 code values of the corresponding files in the file list in the target directory, the self-start is successful, and the relevant programs of the universal gateway are started; otherwise, the universal gateway terminates the self-start and sends a startup failure message containing an eighth alarm code unique identifier, and the eighth alarm code unique identifier is used to identify the files that failed the MD5 code value verification in the file list in the target directory.
[0061] It should be noted that the verification steps of the universal gateway during self-startup are similar to the steps of the above-mentioned secondary verification. The difference is that the second verification of the universal gateway during self-startup is to perform MD5 code value verification on all files in the file list in the target directory, thereby ensuring the security of files that do not need to be upgraded, and performing secondary verification during the self-startup process can effectively detect damage to files caused by "bit reversal" of the USB flash drive and possible damage to written files, thereby ensuring the security of running programs and configurations.
[0062] In one embodiment of the present invention, after receiving the upgrade success message, it is verified whether the upgrade of the universal gateway is successful through the upgraded version of the universal gateway.
[0063] It is understandable that when the universal gateway fails to upgrade, the running version of the universal gateway is the old version after self-startup. At this time, the reason for the upgrade failure can be found through the unique identification of the above alarm code, and the upgrade file can be re-prepared for re-upgrade.
[0064] In summary, the present invention performs MD5 code verification on program files and configuration files during the universal gateway upgrade and self-startup process, which can effectively detect damage to files caused by "bit inversion" of the USB flash drive and possible damage to written files, ensuring the security of running programs and configurations, and adds an upgrade flag to the file list to indicate whether the file needs to be upgraded and updated, so that each upgrade only requires updating the changed program files or configuration files, without the need to upgrade all files, effectively improving the upgrade efficiency, and retaining the MD5 information of files that do not need to be upgraded in the file list, and performing MD5 code verification on these files during self-startup, thereby ensuring the security of files that do not need to be upgraded, and when the universal gateway is upgraded, the present invention only needs to store the upgrade file in the USB flash drive in the specified format, and then insert the USB flash drive into the universal gateway, which can effectively reduce the difficulty of upgrading the universal gateway, thereby reducing the possibility of human-introduced errors during the upgrade process.
[0065] Furthermore, the present invention also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the above-mentioned method for upgrading the universal gateway is implemented.
[0066] Furthermore, the present invention also provides an electronic device, including a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the above-mentioned universal gateway upgrade method is implemented.
[0067] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0068] Although the present invention has been described in detail through the above preferred embodiments, it should be understood that the above description is not intended to limit the present invention. After reading the above description, various modifications and substitutions of the present invention will become apparent to those skilled in the art. Therefore, the scope of protection of the present invention should be defined by the appended claims.
Claims
1. A method for upgrading a universal gateway, characterized in that: include: Obtain an upgrade file for upgrading the universal gateway and store the upgrade file in the root directory of a USB flash drive, wherein the upgrade file includes a file list consisting of several program files and several configuration files of the universal gateway, an MD5 code value file of the file list, and program files or configuration files used for upgrading and updating. The list information of the file list includes: the file name, file type, MD5 code and upgrade flag of each program file or each configuration file, and the upgrade flag is used to mark the program file or configuration file to be upgraded; Inserting the USB flash drive storing the upgrade file into the universal gateway to automatically upgrade the universal gateway using the upgrade file includes: Perform two MD5 code value checks on the upgrade file, wherein the first MD5 code value check step includes: Calculating the MD5 code value of the file list, and comparing the calculated MD5 code value with the MD5 code value in the MD5 code value file in the upgrade file; If the two are equal, the first MD5 code value verification passes, and the process proceeds to the step of performing a second MD5 code value verification on the upgrade file; if the two are not equal, the universal gateway terminates the upgrade and sends an upgrade failure message containing a first alarm code unique identifier, where the first alarm code unique identifier is used to indicate that the MD5 code value verification of the file list has failed; The steps for the second MD5 code value verification include: Open the file list and obtain the file name, file type, MD5 code value and upgrade flag of all files in the file list; Filter the file names and file types of the files that need to be upgraded using the upgrade flag; Find the corresponding program file or configuration file for upgrading in the root directory of the USB flash drive according to the file name and the file type; Calculating the MD5 code value of the program file or the configuration file for upgrading, and comparing the calculated MD5 code value with the MD5 code value of the corresponding file that needs to be upgraded obtained by screening; If the MD5 code values of all files that need to be upgraded are equal to the corresponding calculated MD5 code values, the second MD5 code value verification passes; otherwise, the universal gateway terminates the upgrade and sends an upgrade failure message containing a second alarm code unique identifier to the outside, and the second alarm code unique identifier is used to identify files that need to be upgraded but have failed the MD5 code value verification.
2. The method for upgrading a universal gateway according to claim 1, wherein: The step of automatically upgrading the universal gateway using the upgrade file includes: After the MD5 code value is verified twice, the file to be upgraded corresponding to the upgrade file in the target directory of the universal gateway is deleted, and the upgrade file is copied to the target directory.
3. The method for upgrading a universal gateway according to claim 2, wherein: After the MD5 code value is verified twice, and before deleting the original file to be upgraded in the target directory of the universal gateway, the method further includes: Check whether the program file exists in all files that need to be upgraded in the target directory; If it exists, the watchdog is closed and the program file is terminated; wherein, when an error occurs in closing the watchdog or terminating the program file, the universal gateway terminates the upgrade and sends an upgrade failure message containing a third alarm code unique identifier to the outside, and the third alarm code unique identifier is used to identify the watchdog closing error or the program file termination error.
4. The method for upgrading a universal gateway according to claim 2, wherein: When deleting the original file to be upgraded in the target directory of the universal gateway, if the deletion fails, the universal gateway terminates the upgrade and sends an upgrade failure message containing a fourth alarm code unique identifier to the outside, and the fourth alarm code unique identifier is used to identify the failure of file deletion; and when copying the upgrade file to the target directory, if the copy fails, the universal gateway terminates the upgrade and sends an upgrade failure message containing a fifth alarm code unique identifier to the outside, and the fifth alarm code unique identifier is used to identify the failure of file copying.
5. The method for upgrading a universal gateway according to claim 4, wherein: After copying the upgrade file to the target directory, the method further includes: When it is detected that the files that need to be upgraded in the file list include program files, the permissions of the program files are modified to be executable; if the permission modification fails, the universal gateway terminates the upgrade and sends an upgrade failure message containing the sixth alarm code unique identifier to the outside, and the sixth alarm code unique identifier is used to identify the program files whose permission modification failed; if the permission modification is successful, the universal gateway sends an upgrade success message to the outside.
6. The method for upgrading a universal gateway according to claim 1, wherein: Before inserting the USB flash drive storing the upgrade file into the universal gateway, the method further includes: It is determined whether the universal gateway is upgraded for the first time, and after determining that it is upgraded for the first time, an upgrade environment of the universal gateway is deployed.
7. The method for upgrading a universal gateway according to claim 6, wherein: The step of deploying the upgrade environment of the universal gateway includes: Adding an automatic upgrade program and an automatic startup program to a system startup file to modify the system startup file; The automatic upgrade program and the automatic startup program are placed in the target directory, and the universal gateway is restarted.
8. The method for upgrading a universal gateway according to claim 5, wherein: When the universal gateway sends an upgrade failure message or an upgrade success message, it also sends a prompt message to unplug the U disk, and performs a self-starting operation after detecting that the U disk is unplugged.
9. The method for upgrading a universal gateway according to claim 8, wherein: The step of performing the self-starting operation includes: Calculating the MD5 code value of the file list in the target directory, and comparing the calculated MD5 code value with the MD5 code value in the MD5 code value file in the target directory; If the two are not equal, the universal gateway terminates self-startup and sends a startup failure message containing a seventh alarm code unique identifier, where the seventh alarm code unique identifier is used to identify the failure of the MD5 code value verification of the file list in the target directory; If the two are equal, further opening the file list in the target directory to obtain the file names and MD5 code values of all files in the file list in the target directory; Calculate the MD5 code values of all files, and compare the calculated MD5 code values of all files with the MD5 code values of corresponding files in the file list in the target directory; If the MD5 code values of all files are equal to the MD5 code values of the corresponding files in the file list in the target directory, the self-startup is successful; otherwise, the universal gateway terminates the self-startup and sends a startup failure message containing the eighth alarm code unique identifier to the outside, and the eighth alarm code unique identifier is used to identify the files in the file list in the target directory that fail the MD5 code value verification.
10. The method for upgrading a universal gateway according to claim 8, wherein: After receiving the upgrade failure message, the upgrade failure reason is searched through the unique identifier of the received alarm code.
11. The method for upgrading a universal gateway according to claim 8, wherein: After receiving the upgrade success message, it is verified whether the upgrade of the universal gateway is successful through the upgraded version of the universal gateway.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for upgrading the universal gateway according to any one of claims 1 to 11 is implemented.
13. An electronic device, characterized in that: The method comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the method for upgrading the universal gateway according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
System updating and upgrading method and system in enclosed environment
CN103902342A