1. yang xiaoyong
  2. woocode

Source

woocode / sa-auto / sh / msj / on_ip_changed.sh

#!/bin/sh
# on_ip_changed.sh
# deal with configure files once msj env is changed .


MSJ_CONF_DIR=/apps/conf/msj
SH_DIR=/apps/sh
MYSQL=/apps/svr/mysql5/bin/mysql
MYSQL_PID_FILE=/apps/dbdat/mysql5_data/APPS.pid


read -p "please offer me the new ip:" ip_new


# configure files : db.csv email_config.lua fcgi_config.lua mall_config.lua server.csv sn_config.lua 

cd ${MSJ_CONF_DIR}
echo -n "Dealing with server.csv......" 
sed -i "2,\$s/[^,]*,/${ip_new},/4" server.csv
echo "Done!"

echo -n "Dealing with fcgi_config.lua..."
sed -i "/DOMAIN_NAME/s/\".*\"/\"$ip_new\"/" fcgi_config.lua
sed -i "/HOME_URL/s/\/\/.*:/\/\/$ip_new:/" fcgi_config.lua
sed -i "/GAME_URL/s/\/\/.*:/\/\/$ip_new:/" fcgi_config.lua
echo "Done!"

echo -n "Dealing with mall_config.lua email_config.lua sn_config.lua..."
for f in mall_config.lua email_config.lua sn_config.lua ; do
	sed -i "/_IP/s/\".*\"/\"$ip_new\"/" $f 
done
echo -n "Done!"

cd -

eval `sed -n '/DB_HOST/s/ //gp' ${MSJ_CONF_DIR}/mall_config.lua`
eval `sed -n '/DB_USER/s/ //gp' ${MSJ_CONF_DIR}/mall_config.lua`
eval `sed -n '/DB_PASS/s/ //gp' ${MSJ_CONF_DIR}/mall_config.lua`
eval `sed -n '/DB_NAME/s/ //gp' ${MSJ_CONF_DIR}/mall_config.lua`

test -p ${DB_PASS} || DB_PASS="-p${DB_PASS}"
${MYSQL} -u${DB_USER} ${DB_PASS} -h ${DB_HOST} -D ${DB_NAME} -e "update serverlist set ip=\"${ip_new}\";"
exit 0