Method and system for realizing software automation task based on shell
By using a shell-based automation method, shell scripts are written and executed to automate the installation, upgrade, and uninstallation of software, solving the problem of cumbersome operations in local area networks and enabling rapid deployment and efficient management of software.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN OCEANS KING LIGHTING ENG CO LTD
- Filing Date
- 2024-11-04
- Publication Date
- 2026-05-08
AI Technical Summary
Existing technologies make software installation, upgrades, and uninstallation on local area networks cumbersome, especially for those without professional knowledge, making it difficult to operate conveniently.
A shell-based automation approach is adopted, which uses shell scripts to automate the installation, upgrade, and uninstallation of software. This includes shell installation, startup, upgrade, and uninstallation scripts, which are combined with shell commands to complete the tasks and automatically start the scripts after the server boots up.
It enables quick installation, upgrades, and uninstallation of software within a local area network, reducing operational complexity, making it suitable for users without specialized knowledge, and improving work efficiency and automation.
Smart Images

Figure CN121996260A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software system technology for the Internet, and in particular to a method and system for automating software tasks based on shell. Background Technology
[0002] In recent years, with the rapid development of information technology, the functions of various system platforms have become increasingly sophisticated, while traditional installation methods have become increasingly cumbersome. Current technologies generally require some degree of internet expertise for system installation, upgrades, and uninstallation, especially when operating from a local area network (LAN) and lacking remote control capabilities. This makes software installation, upgrades, and uninstallation particularly difficult and tedious for those without the necessary knowledge. Therefore, it is necessary to propose a method to improve the convenience of software installation, upgrades, and uninstallation. Summary of the Invention
[0003] Therefore, it is necessary to propose a method and system for automating software tasks based on shell to address the above problems.
[0004] First aspect
[0005] A method for automating software tasks based on shell, the method comprising:
[0006] Define automated tasks; wherein the automated tasks include at least one of automated software installation, automated software upgrade, and automated software uninstallation;
[0007] Write shell scripts according to the automated task; wherein, the shell scripts include at least one of shell installation scripts, shell startup scripts, shell upgrade scripts, and shell uninstallation scripts;
[0008] The automated task is completed by executing the shell script.
[0009] The completion result of the automated task is verified to obtain the verification result;
[0010] The shell script is optimized and improved based on the verification results.
[0011] Preferably, when the automated task is the automated installation of software, the step of completing the automated task by executing the shell script specifically includes:
[0012] Start the shell script; wherein the shell script is automatically started after the server boots up;
[0013] Retrieve the service information recorded in the shell script;
[0014] Determine whether the service information exists in the server;
[0015] If the service information exists in the server, the software will be automatically started by executing a shell startup script;
[0016] If the service information is not present on the server, the software will be automatically installed and started by executing shell installation scripts and shell startup scripts.
[0017] Preferably, the automated installation and startup of the software by executing shell installation scripts and shell startup scripts specifically includes:
[0018] Execute the shell installation script;
[0019] Obtain the installation package information of the software on the server using shell commands;
[0020] The installation package information is processed into a service package;
[0021] The service information of the software is constructed using the service package;
[0022] Execute the shell startup script;
[0023] The software is launched based on the reserved information in the shell startup script.
[0024] Preferably, the automated software startup via executing a shell startup script specifically includes:
[0025] The staff member selects and double-clicks the startup file;
[0026] Execute the shell commands in the file sequentially;
[0027] The services in the document determine their startup method through the deployment software included in the software package; wherein, the startup method includes one of the native service startup method and other startup methods.
[0028] Preferably, when the automated task is an automated software upgrade, the step of completing the automated task by executing the shell script specifically includes:
[0029] Execute the shell upgrade script;
[0030] Retrieve service information for the software to be upgraded on the server;
[0031] Stop the service of the software to be upgraded based on the service information of the software to be upgraded.
[0032] Replace the software package to be upgraded with the upgraded software package;
[0033] The automated upgrade of the software to be upgraded is completed by executing a shell installation script.
[0034] Preferably, when the automated task is the automated uninstallation of software, the step of completing the automated task by executing the shell script specifically includes:
[0035] Execute the shell uninstallation script;
[0036] Retrieve service information of the software to be uninstalled from the server;
[0037] Stop the service of the software to be uninstalled based on the service information of the software to be uninstalled.
[0038] Preferably, the verification of the completion result of the automated task to obtain the verification result specifically includes:
[0039] When the automated task is the automated installation of software, check whether the software has been successfully installed and is running;
[0040] When the automated task is an automated software upgrade, check whether the software has been successfully upgraded and is running.
[0041] When the automated task is to automatically uninstall software, check whether the software was successfully uninstalled.
[0042] Second aspect
[0043] A system for automating software tasks based on shell, the system comprising:
[0044] A task determination module is used to determine automated tasks; wherein the automated tasks include at least one of automated software installation, automated software upgrade, and automated software uninstallation;
[0045] A script writing module is used to write shell scripts according to the automation task; wherein the shell scripts include at least one of shell installation scripts, shell startup scripts, shell upgrade scripts, and shell uninstallation scripts;
[0046] The task completion module is used to complete the automated task by executing the shell script.
[0047] The verification result acquisition module is used to verify the completion result of the automated task and obtain the verification result;
[0048] An optimization module is used to optimize and improve the shell script based on the verification results.
[0049] Preferably, when the automated task is the automated installation of software, the task completion module is specifically used for:
[0050] Start the shell script; wherein the shell script is automatically started after the server boots up;
[0051] Retrieve the service information recorded in the shell script;
[0052] Determine whether the service information exists in the server;
[0053] If the service information exists in the server, the software will be automatically started by executing a shell startup script;
[0054] If the service information is not present on the server, the software will be automatically installed and started by executing shell installation scripts and shell startup scripts.
[0055] Preferably, when the automated task is an automated software upgrade, the task completion module is specifically used for:
[0056] Execute the shell upgrade script;
[0057] Retrieve service information for the software to be upgraded on the server;
[0058] Stop the service of the software to be upgraded based on the service information of the software to be upgraded.
[0059] Replace the software package to be upgraded with the upgraded software package;
[0060] The automated upgrade of the software to be upgraded is completed by executing a shell installation script.
[0061] The embodiments of the present invention have the following beneficial effects:
[0062] This invention proposes a method and system for automating software tasks based on shell. By using the shell language, it is possible to connect with other automation technologies on the Linux platform, thereby enabling automated installation, upgrade, and uninstallation of software with a single command, meeting the requirements for rapid deployment and installation in local area networks and multiple network locations. Attached Figure Description
[0063] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0064] in:
[0065] Figure 1 This is a flowchart of a method for implementing software automation tasks based on shell in one embodiment;
[0066] Figure 2 This is a flowchart of a software package that starts automatically on boot, as shown in one embodiment.
[0067] Figure 3 This is a flowchart of an automated upgrade process in one embodiment;
[0068] Figure 4 This is a flowchart of automated uninstallation in one embodiment;
[0069] Figure 5 This is a structural block diagram of a system that implements software automation tasks based on shell in one embodiment. Detailed Implementation
[0070] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0071] This invention is used to automate the installation, upgrade, and uninstallation of software packages; to enable quick installation, upgrade, and uninstallation of software packages in a local area network environment; to execute Docker and other framework commands via shell in an offline environment; and to enable software packages to start automatically on boot in a Linux environment via shell.
[0072] Figure 1 This is a flowchart illustrating a method for automating software tasks based on a shell in one embodiment. Figure 1 As shown, the method specifically includes the following steps:
[0073] Step 202: Determine the automation task.
[0074] In some examples, the automated tasks include at least one of automated software installation, automated software upgrade, and automated software uninstallation.
[0075] Step 204: Write a shell script based on the automation task.
[0076] Shell scripts are executable files composed of shell commands. They integrate several commands into one file to process business logic. Scripts can run without compilation, which reduces workload and improves work efficiency to a certain extent. They can also process hosts in batches and on a schedule, making it convenient for administrators to set up or manage them.
[0077] In some examples, the shell script includes at least one of a shell installation script, a shell startup script, a shell upgrade script, and a shell uninstallation script.
[0078] To write a shell script to install software, the following steps are required: Identify the software to be installed and the relevant package manager (such as APT or YUM). Check and install necessary dependencies. Download the software package. Unzip the software package (if necessary). Configure, compile, and install the software. Clean up temporary files and configurations generated during the installation process.
[0079] To start a script in the shell, you need to: write the script; grant the script execute permissions; and execute the script.
[0080] To write a shell upgrade script, you need to determine what needs to be upgraded, such as software packages or the system. This script will update the package list, upgrade all available packages, and clean up any unnecessary packages and downloaded package files after completion. You can modify this script as needed, such as adding more system upgrade checks or upgrade logic for specific packages.
[0081] To create a shell script to uninstall a program, you need to know how to write scripts in a shell and the uninstallation logic for the program you want to uninstall. When writing the script, ensure you have sufficient permissions to perform these operations, especially deleting files and modifying system configurations. Perform thorough testing before running the script in a production environment.
[0082] Step 206: Complete the automated task by executing a shell script.
[0083] When the automated task is the automated installation of software, the automated task is completed by executing a shell script, specifically including steps 20611 to 20615:
[0084] Step 20611: Start the shell script; the shell script starts automatically after the server boots up.
[0085] Step 20612: Obtain the service information recorded in the shell script.
[0086] Step 20613: Determine whether service information exists in the server.
[0087] Step 20614: If service information exists on the server, the software will be automatically started by executing a shell startup script.
[0088] Step 20615: If the service information does not exist on the server, the software will be automatically installed and started by executing the shell installation script and the shell startup script.
[0089] Step 20615 automates the installation and startup of the software by executing shell installation and startup scripts, specifically including:
[0090] Execute the shell installation script;
[0091] Obtain the installation package information of the software on the server using shell commands;
[0092] Process the installation package information into a service package;
[0093] Utilize service packages to build software service information;
[0094] Execute the shell startup script;
[0095] The software starts based on the reserved information in the shell startup script.
[0096] Step 20614 automates the software startup by executing a shell startup script, specifically including:
[0097] The staff member selects and double-clicks the startup file;
[0098] Execute the shell commands in the file sequentially;
[0099] The services in the document determine their startup method through the deployment software included in the package; the startup method includes either the native service startup method or other startup methods.
[0100] For example, Figure 2 This is a flowchart of a startup software package in one embodiment. The startup software package process is as follows: Figure 2As shown: After the server boots up, a shell script will automatically start to retrieve the service information (a service refers to a software application that provides various functions and services) recorded in the script. If the service is not installed and started (i.e., the software's service information does not exist on the server), the software cannot be used. At this time, the installation script will use shell commands to retrieve the corresponding installation package information on the server and process it into a service package for building service information. Then, the shell startup script can start the services that need to be started according to the pre-reserved information in the script, thereby realizing the automated installation and startup process. It can also be manually executed by on-site personnel: simply select and double-click the startup file. After the file starts, it will execute commands sequentially through the shell commands in the file. The services in the file can be determined by the deployment software included in the package, whether to start the service using native services or other methods (such as Docker).
[0101] When the automated task is an automated software upgrade, the automated task is completed by executing a shell script, specifically including steps 20621 to 20625:
[0102] Step 20621: Execute the shell upgrade script.
[0103] Step 20622: Obtain service information of the software to be upgraded on the server.
[0104] Step 20623: Stop the service of the software to be upgraded based on the service information of the software to be upgraded.
[0105] Step 20624: Replace the software package to be upgraded with the upgraded software package.
[0106] Step 20625: Automated upgrade of the software to be upgraded is completed by executing a shell installation script.
[0107] For example, Figure 3 This is a flowchart of an automated upgrade process in one embodiment. The automated upgrade process is as follows: Figure 3 As shown: When the platform needs to be upgraded, software services can be upgraded by starting a shell script. The program will obtain information about the services running on the server, stop the services that need to be upgraded one by one according to their service information, retrieve the corresponding installation packages from the corresponding directories, replace the stopped service packages, and start the shell installation script to start the replaced packages, thereby automating the software upgrade (using Linux native commands or Docker technology commands, the corresponding script needs to be started according to the on-site packages).
[0108] When the automated task is the automated uninstallation of software, the automated task is completed by executing a shell script, specifically including steps 20631 to 20633:
[0109] Step 20631: Execute the shell uninstallation script.
[0110] Step 20632: Obtain service information of the software to be uninstalled from the server.
[0111] Step 20633: Stop the service of the software to be uninstalled based on the service information of the software to be uninstalled.
[0112] For example, Figure 4 This is a flowchart of an automated uninstallation process in one embodiment. The automated uninstallation process is as follows: Figure 4 As shown: The automated uninstallation process is consistent with the initial steps of the upgrade process. It obtains information about the services running on the server and stops the services that need to be upgraded one by one based on their service information (using Linux native commands or Docker stop commands, and the corresponding scripts need to be started according to the on-site deployment).
[0113] Step 208: Verify the completion result of the automated task and obtain the verification result.
[0114] The completion results of the automated task are verified, and the verification results are obtained, including:
[0115] When the automated task is to install software, check whether the software is successfully installed and running.
[0116] When the automated task is to upgrade the software, check whether the software has been successfully upgraded and is running.
[0117] When the automated task is to automatically uninstall the software, check whether the software was successfully uninstalled.
[0118] Step 210: Optimize and improve the shell script based on the verification results.
[0119] Based on the problems and experiences encountered during actual deployment, the script was optimized and improved to enhance its robustness and maintainability.
[0120] This embodiment enables the software package service to start automatically upon system boot; it allows for one-click installation, upgrade, and uninstallation of software packages even without internet access; it is simple and easy to use, allowing staff to quickly install software packages.
[0121] Figure 5 This is a block diagram of a system that implements software automation tasks based on shell in one embodiment. Figure 5 As shown, the system includes:
[0122] The task determination module 5501 is used to determine automated tasks. The automated tasks include at least one of the following: automated software installation, automated software upgrade, and automated software uninstallation.
[0123] Scripting module 5502 is used to write shell scripts for automated tasks. These shell scripts include at least one of the following: shell installation script, shell startup script, shell upgrade script, and shell uninstallation script.
[0124] Task completion module 5503 is used to automate tasks by executing shell scripts.
[0125] The verification result acquisition module 5504 is used to verify the completion results of automated tasks and obtain verification results.
[0126] Optimization module 5505 is used to optimize and improve shell scripts based on verification results.
[0127] When the automated task is the automated installation of software, the task completion module 5503 is specifically used for: starting the shell script; wherein the shell script is automatically started after the server boots up; obtaining the service information recorded in the shell script; determining whether the service information exists on the server; if the service information exists on the server, then the automated startup of the software is completed by executing the shell startup script; if the service information does not exist on the server, then the automated installation and startup of the software are completed by executing the shell installation script and the shell startup script.
[0128] In task completion module 5503, the automated installation and startup of the software are completed by executing shell installation scripts and shell startup scripts. Specifically, this includes: executing shell installation scripts; obtaining the installation package information corresponding to the software on the server through shell commands; processing the installation package information into a service package; using the service package to build the software's service information; executing shell startup scripts; and starting the software according to the reserved information in the shell startup scripts.
[0129] In task completion module 5503, the software is automatically started by executing a shell startup script. Specifically, this includes: the operator selects and double-clicks the startup file; the shell commands in the file are executed sequentially; the services in the file determine the startup method through the deployment software included in the software package; the startup method includes either the native service startup method or other startup methods.
[0130] When the automated task is an automated software upgrade, the task completion module 5503 is specifically used for: executing a shell upgrade script; obtaining service information of the software to be upgraded from the server; stopping the service of the software to be upgraded based on the service information; replacing the software package of the software to be upgraded with the upgraded software package; and completing the automated upgrade of the software to be upgraded by executing a shell installation script.
[0131] When the automated task is the automated uninstallation of software, the task completion module 5503 is specifically used for: executing the shell uninstallation script; obtaining the service information of the software to be uninstalled from the server; and stopping the service of the software to be uninstalled based on the service information.
[0132] The verification result acquisition module 5504 is specifically used for: checking whether the software is successfully installed and running when the automated task is the automated installation of software; checking whether the software is successfully upgraded and running when the automated task is the automated upgrade of software; and checking whether the software is successfully uninstalled when the automated task is the automated uninstallation of software.
[0133] This embodiment simplifies and automates the installation, upgrade, and uninstallation of software packages; it automates server startup; it reduces the steps and time required for upgrading software packages; and it allows even those without relevant expertise to install, upgrade, and uninstall software packages. When the server is shut down and restarted, on-site personnel can start the software program without manually restarting the software service.
[0134] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0135] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0136] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for automating software tasks based on shell, characterized in that, The method includes: Define automated tasks; wherein the automated tasks include at least one of automated software installation, automated software upgrade, and automated software uninstallation; Write shell scripts according to the automated task; wherein, the shell scripts include at least one of shell installation scripts, shell startup scripts, shell upgrade scripts, and shell uninstallation scripts; The automated task is completed by executing the shell script. The completion result of the automated task is verified to obtain the verification result; The shell script is optimized and improved based on the verification results.
2. The method for automating software tasks based on shell according to claim 1, characterized in that, When the automated task is the automated installation of software, the step of completing the automated task by executing the shell script specifically includes: Start the shell script; wherein the shell script is automatically started after the server boots up; Retrieve the service information recorded in the shell script; Determine whether the service information exists in the server; If the service information exists in the server, the software will be automatically started by executing a shell startup script; If the service information is not present on the server, the software will be automatically installed and started by executing shell installation scripts and shell startup scripts.
3. The method for automating software tasks based on shell according to claim 2, characterized in that, The automated installation and startup of the software by executing shell installation scripts and shell startup scripts specifically includes: Execute the shell installation script; Obtain the installation package information of the software on the server using shell commands; The installation package information is processed into a service package; The service information of the software is constructed using the service package; Execute the shell startup script; The software is launched based on the reserved information in the shell startup script.
4. The method for automating software tasks based on shell according to claim 2, characterized in that, The automated software startup process, achieved by executing a shell startup script, specifically includes: The staff member selects and double-clicks the startup file; Execute the shell commands in the file sequentially; The services in the document determine their startup method through the deployment software included in the software package; wherein, the startup method includes one of the native service startup method and other startup methods.
5. The method for automating software tasks based on shell according to claim 1, characterized in that, When the automated task is an automated software upgrade, the step of completing the automated task by executing the shell script specifically includes: Execute the shell upgrade script; Retrieve service information for the software to be upgraded on the server; Stop the service of the software to be upgraded based on the service information of the software to be upgraded. Replace the software package to be upgraded with the upgraded software package; The automated upgrade of the software to be upgraded is completed by executing a shell installation script.
6. The method for automating software tasks based on shell according to claim 1, characterized in that, When the automated task is the automated uninstallation of software, the step of completing the automated task by executing the shell script specifically includes: Execute the shell uninstallation script; Retrieve service information of the software to be uninstalled from the server; Stop the service of the software to be uninstalled based on the service information of the software to be uninstalled.
7. The method for automating software tasks based on shell according to claim 1, characterized in that, The verification of the completion result of the automated task, and the resulting verification, specifically include: When the automated task is the automated installation of software, check whether the software has been successfully installed and is running; When the automated task is an automated software upgrade, check whether the software has been successfully upgraded and is running. When the automated task is to automatically uninstall software, check whether the software was successfully uninstalled.
8. A system for automating software tasks based on shell, characterized in that, The system includes: A task determination module is used to determine automated tasks; wherein the automated tasks include at least one of automated software installation, automated software upgrade, and automated software uninstallation; A script writing module is used to write shell scripts according to the automation task; wherein the shell scripts include at least one of shell installation scripts, shell startup scripts, shell upgrade scripts, and shell uninstallation scripts; The task completion module is used to complete the automated task by executing the shell script. The verification result acquisition module is used to verify the completion result of the automated task and obtain the verification result; An optimization module is used to optimize and improve the shell script based on the verification results.
9. The system for automating software tasks based on shell according to claim 8, characterized in that, When the automated task is the automated installation of software, the task completion module is specifically used for: Start the shell script; wherein the shell script is automatically started after the server boots up; Retrieve the service information recorded in the shell script; Determine whether the service information exists in the server; If the service information exists in the server, the software will be automatically started by executing a shell startup script; If the service information is not present on the server, the software will be automatically installed and started by executing shell installation scripts and shell startup scripts.
10. The system for automating software tasks based on shell according to claim 8, characterized in that, When the automated task is an automated software upgrade, the task completion module is specifically used for: Execute the shell upgrade script; Retrieve service information for the software to be upgraded on the server; Stop the service of the software to be upgraded based on the service information of the software to be upgraded. Replace the software package to be upgraded with the upgraded software package; The automated upgrade of the software to be upgraded is completed by executing a shell installation script.