1. yang xiaoyong
  2. woocode

Source

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

#!/bin/sh
# on_db_pass_changed.sh
# use me when db_pass needs to be changed.

MSJ_CONF_DIR=/apps/conf/msj

cd ${MSJ_CONF_DIR}
read -p "Please offer me new DB HOST IP (default 127.0.0.1) :" db_host_new
db_host_new=${db_host_new:="127.0.0.1"}

# Config files: db.csv fcgi_config.lua mall_config.lua email_config.lua sn_config.lua

echo -n "Dealing with db.csv ..."
sed -i "2s/[^,]*,/${db_host_new},/1" db.csv
echo "Done!"

echo -n "Dealing with fcgi_config.lua ..."
sed -i "2s/\".*\"/\"${db_host_new}\"/" fcgi_config.lua
echo "Done!"


CONF_FILES="mall_config.lua email_config.lua sn_config.lua"
echo -n "Dealing with ${CONF_FILES} ..."
for f in  ${CONF_FILES};do
	sed -i "/DB_HOST/s/\".*\"/\"${db_host_new}\"/" $f
done
echo "Done!"

cd -
exit 0