When the environment variable is present, the analysis solution that does not perform replacement is not performed when the Rancher is upgraded
1. When there is an environment variable, the replacement is not performed, the variable in the file /etc/nginx/conf.d/pcs.conf is not replaced, and there is a replacement record in /config/init/change.log, as shown in Figure 1
2. Check the container log, report an error: sed: couldnT open file ww/pcs/build/config.js: No such file or directory
2018/7/24 下午3:47:59PCS_CFG_NGINX_SERVER_NAME=wjdev2.chinamcloud.com
2018/7/24 下午3:47:59sed: -e expression #1, char 7: extra characters after command
2018/7/24 下午3:47:59PCS_CFG_NGINX_SERVER_NAME replace wjdev2.chinamcloud.com -> /etc/nginx/conf.d/pcs.conf
2018/7/24 下午3:47:59PCS_CFG_API_HOST_INFO=http://wjdev2.chinamcloud.com:8656
2018/7/24 下午3:47:59sed: -e expression #1, char 7: extra characters after command
2018/7/24 下午3:47:59PCS_CFG_API_HOST_INFO replace http://wjdev2.chinamcloud.com:8656 -> /etc/nginx/conf.d/pcs.conf
2018/7/24 下午3:47:59PCS_CFG_API_BASE_URL=/v1
2018/7/24 下午3:47:59sed: -e expression #1, char 7: extra characters after command
2018/7/24 下午3:47:59PCS_CFG_API_BASE_URL replace /v1 -> /etc/nginx/conf.d/pcs.conf
2018/7/24 下午3:47:59PCS_CFG_CALLBACK_LOGIN=https://cmclogin.chinamcloud.com/login/index?call_back=http://wjdev2.chinamcloud.com:8657/#/topic/add
2018/7/24 下午3:47:59sed: couldn't open file ww/pcs/build/config.js: No such file or directory
2018/7/24 下午3:47:59PCS_CFG_CALLBACK_LOGIN replace https://cmclogin.chinamcloud.com/login/index?call_back=http://wjdev2.chinamcloud.com:8657/#/topic/add -> /sobey/www/pcs/build/config.js
2018/7/24 下午3:47:59PCS_CFG_API_VERSION=0.0
2018/7/24 下午3:47:59sed: couldn't open file ww/pcs/build/config.js: No such file or directory
2018/7/24 下午3:47:59PCS_CFG_API_VERSION replace 0.0 -> /sobey/www/pcs/build/config.js
2018/7/24 下午3:47:59PCS_CFG_CMC_CONSOLE_URL=https://cmcconsole.chinamcloud.com
2018/7/24 下午3:47:59sed: couldn't open file ww/pcs/build/config.js: No such file or directory
2018/7/24 下午3:47:59PCS_CFG_CMC_CONSOLE_URL replace https://cmcconsole.chinamcloud.com -> /sobey/www/pcs/build/config.js
2018/7/24 下午3:47:59PCS_CFG_CMC_CONSOLE_HEADER_LEFT_CSS=/cmc/cmc_header_left.css
2018/7/24 下午3:47:59sed: couldn't open file ww/pcs/build/config.js: No such file or directory
2018/7/24 下午3:47:59PCS_CFG_CMC_CONSOLE_HEADER_LEFT_CSS replace /cmc/cmc_header_left.css -> /sobey/www/pcs/build/config.js
2018/7/24 下午3:47:59PCS_CFG_CMC_CONSOLE_HEADER_LEFT_JS=/cmc/cmc_header_left.js
2018/7/24 下午3:47:59sed: couldn't open file ww/pcs/build/config.js: No such file or directory
2018/7/24 下午3:47:59PCS_CFG_CMC_CONSOLE_HEADER_LEFT_JS replace /cmc/cmc_header_left.js -> /sobey/www/pcs/build/config.js
2018/7/24 下午3:47:59PCS_CFG_API_VERSION=0.0
2018/7/24 下午3:47:59sed: couldn't open file ww/pcs/build/gis/config.js: No such file or directory
2018/7/24 下午3:47:59PCS_CFG_API_VERSION replace 0.0 -> /sobey/www/pcs/build/gis/config.js
2018/7/24 下午3:47:59/config/init/cronlog.sh: line 4: LOG_NAME: unbound variable
3. pcs_cfg_callback_login=https://cmclogin.chinamcloud.com/login/index?call_back=http://wjdev2.chinamcloud.com:8657/#/topic/add, there is # in its value, so in order to prevent conflicts, you need to replace # with @. And sed -i” is replaced with sed -i “, space is missing.
env | grep "PCS_CFG_CALLBACK_LOGIN" || export PCS_CFG_CALLBACK_LOGIN="PCS_CFG_CALLBACK_LOGIN"
sed -i "s@PCS_CFG_CALLBACK_LOGIN@$PCS_CFG_CALLBACK_LOGIN@g" $BUILD_CONFIG_PATH
echo "PCS_CFG_CALLBACK_LOGIN replace $PCS_CFG_CALLBACK_LOGIN -> $BUILD_CONFIG_PATH"
echo "PCS_CFG_CALLBACK_LOGIN replace $PCS_CFG_CALLBACK_LOGIN -> $BUILD_CONFIG_PATH" >> $DIR/change.log
4. The variables in the file /etc/nginx/conf.d/pcs.conf have been successfully replaced, as shown in Figure 2

