How to adjust the `start.sh` script after changing the executable file name of AnQiCMS in order to continue working?
As an experienced security CMS website operator, I am well aware of the importance of maintaining the stable operation of the website, especially when adjusting the core system files.AnQiCMS with its efficiency and lightweight nature in the Go language is widely popular in actual operation.However, any modification to the core components requires meticulous adjustments to ensure the normal operation of the system.Among other things, after changing the executable file name of AnQiCMS, the corresponding startup scriptstart.shIt must also be adapted for compatibility.
Understand the AnQiCMS startup scriptstart.shthe core role
The deployment of AnQiCMS, especially under Linux, usually depends on a name calledstart.shA script to manage the startup and monitoring of the application. The main responsibility of this script is to check if AnQiCMS is running, and if it is not, it will automatically start the application.This mechanism ensures that AnQiCMS can automatically restore services even after unexpected crashes or server restarts, greatly enhancing the availability and stability of the website.
start.shThe script contains several key variables and commands that work together to identify and execute the AnQiCMS main program. Among them,BINNAMEVariables are used to specify the name of the executable file, andps -ef | grepThe command is used to find the process corresponding to the name in the system process list.If these names do not match the actual executable files running, the script will not be able to detect and start AnQiCMS correctly.
Adjust the script after changing the executable file name of AnQiCMS
When you decide to change the executable file name of AnQiCMS for some reasons (such as improving security, avoiding conflicts with other programs in the system, or distinguishing between multiple different instances running on the same server),start.shThe related references in the script must also be updated synchronously. Otherwise, even if the executable file itself exists and can be manually run, the auto-start script will not be able to find it, causing AnQiCMS to fail to start automatically or restart when needed.
Adjuststart.shThe script needs to be modified to accommodate the new executable filename, you need to modify two key positions in the script.
First, you need to find the script.BINNAMEVariable definition line. It is usually set to in the original scriptBINNAME=anqicms. You need toanqicmsReplace it with your new executable filename. For example, if your new executable filename ismyanqicms_webThis line should be modified toBINNAME=myanqicms_web.
Next, the script is used to pass throughgrepThe command line to find the running process also needs to be modified. This line of code usually containsgrep '\<anqicms\>'. Here,anqicmsThe same needs to be replaced with your new executable filename. Please make sure to keep it\<and\>These special characters are ingrepThe command represents a 'word boundary', ensuring that only complete filenames are matched, rather than strings containing the name, to avoid affecting unrelated processes. For example, if your new filename ismyanqicms_webIt should be modified asexists=\ps -ef | grep '<myanqicms_web>' |grep -v grep |wc -l
It is worth noting that the commands actually executed by AnQiCMS in the script usually refer to$BINNAMEFor example,nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &. Since you have updatedBINNAMEVariable definition, this line of code will automatically use the new executable filename without any additional modification.
Detailed operation steps
To complete these modifications, please follow the following steps:
First, connect to your AnQiCMS server using SSH.
Next, navigate to the AnQiCMS installation directory, usually/www/wwwroot/anqicmsOr specify a custom path. Find it in the directory.start.shthe script file.
Then, open the file with your preferred text editor (such as)viornano).start.shRun the file. For example,nano start.sh.
In the opened file, locate toBINNAMEthe line of the variable definition, change its value fromanqicmsto your new executable filename.
Next, find the line containinggrep '\<anqicms\>'and change it toanqicmsReplace with your new executable filename and make sure to keep it\<and\>.
Save the file and exit the editor after making the changes
To ensurestop.shThe script also works correctly, performing the same modification steps. Instop.shIn, you also need to changeBINNAMEvariables as well asgrepThe name of the executable file referenced in the command. Keep the two scriptsBINNAMEConsistency is the key to ensuring that AnQiCMS can be started and stopped correctly.
Finally, execute./start.shManually test the new script using the command and check if AnQiCMS can start normally. You can useps -ef | grep your_new_executable_nameCommand to verify that the new executable file is running. Also, checkrunning.logandcheck.logthe file, confirm that there are no error messages.
By making the above adjustments, changing the executable file name of AnQiCMS will not affect its automatic startup and management functions, ensuring the smooth operation of the website.
Frequently Asked Questions
If I change the executable file name but forget to modifystart.shWhat will happen to the script?
If the executable file name of AnQiCMS is changed without updating accordinglystart.shScript, the system will not be able to start AnQiCMS automatically through this script.This means that after the server restarts, or the AnQiCMS process is unexpectedly terminated, your website will not be able to automatically restore services.You need to manually locate the new executable file and run it, or manually edit and updatestart.shTry to start the script again. In the long run, this will affect the stability and availability of the website, increasing the burden of operation and maintenance.
Why do we need to change the name of the AnQiCMS executable file?
There are various practical application scenarios for changing the name of an executable file.When deploying multiple AnQiCMS instances on the same server, assigning different executable filenames to each instance helps distinguish and manage them, preventing process conflicts.Secondly, from a security perspective, changing the default filename to an uncommon or customized name can slightly increase the In addition, custom executable filenames may also be convenient for certain specific operational processes or tool integrations.
modifystart.shWill the script affect the database connection or configuration of AnQiCMS?
No. Modify.start.shThe script is simply to allow the system to correctly identify and start the binary file of AnQiCMS application.This operation is purely for the application startup logic and will not affect the internal configuration of AnQiCMS (such as database connection, port settings, website address, etc.).These configuration information is usually stored inconfig.jsonIn other configuration files, it is irrelevant to the name of the executable file. You just need to make sure that the executable file can read these configuration files correctly.