When the Rancher container is upgraded, the execution of the shell script reports an error: sed: -e expression #1, char 37: unknown option to `sanalysis and solution

在 Rancher 容器升级时,执行 SHELL 脚本报错:sed: -e expression #1, char 37: unknown option to `s'
1. When the RAncher container is upgraded, execute the shell script error: sed: -e expression #1, char 37: unknown option to `s, as shown in Figure 1
在 Rancher 容器升级时,执行 SHELL 脚本报错:sed: -e expression #1, char 37: unknown option to `s'
Figure 1
2. The value of the environment variable CMCP_API_CFG_REdis_password is q5dhp@xcbuujy^L, which leads to the failure of the upgrade, and the value is changed to q5dhp@xcbuujyl, remove the ^ symbol, upgrade again, the upgrade failed 3. Modify the value to Q5Dhpxcbuujy^L, remove the @ symbol, upgrade again, and the upgrade is successful


sed -i "s@CMCP_API_CFG_REDIS_HOSTNAME@$CMCP_API_CFG_REDIS_HOSTNAME@g" /sobey/www/cmcp-api/.env;


4. The value of the environment variable CMCP_API_CFG_REdis_password is q5dhp@xcbuujy^L, which leads to the failure of the upgrade, and finally decided not to modify the original value and modify the shell file, replace @ with #, the upgrade is successful


sed -i "s@CMCP_API_CFG_REDIS_HOSTNAME@$CMCP_API_CFG_REDIS_HOSTNAME@g" /sobey/www/cmcp-api/.env;




sed -i "s#CMCP_API_CFG_REDIS_HOSTNAME#$CMCP_API_CFG_REDIS_HOSTNAME#g" /sobey/www/cmcp-api/.env;


5. To sum up, in the shell, the search and replacement of the data, the default is: seds/strings to be replaced/new strings/gbut where / can be replaced with other strings to avoid conflicts

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.