#!/bin/bash #description: this script is to modify the arguments of database in all PHP config files #author:huangyong #date:2018-10-23 #该脚本在之前的脚本上在2个地方进行了优化: #1.不再仅限于在具体某个目录下去寻找配置文件.而是在current.shared目录中去寻找 #2.find忽略了releases目录,这样不会去修改老版本的配置文件
p_dir=/data/apps/ #Parent dir
#找出父目录下的所有PHP业务目录 files=$(ls $p_dir)
for file in $files;do cd $p_dir$file app_conf=$(find current/ shared/ -name "application.ini" ) #在current shared目录查找配置文件.指定目录是避免查找release目录. #find的命令可以忽略某个目录: find . ! -path "./xxx/*" ! -path "./xxxxx/*"
if [ ! -z "$app_conf" ];then #如果存在application配置文件,就替换redis配置项.前面2个是好食期的redis配置..后面两个是觅食蜂项目的 for conf in $app_conf;do sed -ri '/redis.config.isauth/s#(=\s*).+$#\1true#' $conf sed -ri '/redis.config.auth/s#(=\s*).+$#\1"Iamyourdaddy"#' $conf sed -ri '/redis.default.config.isauth/s#(=\s*).+$#\1true#' $conf sed -ri '/redis.default.config.auth/s#(=\s*).+$#\1"Iamyourdaddy"#' $conf