`
sunxboy
  • 浏览: 2828728 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

bash shell notes:

 
阅读更多


#!/bin/bash
config_file='xxxxx'
tmp_file=/tmp/tempfile.$$



function usage()
{
cat <<!
usage: $(basename $0) options

options
aaa       switch to aaa
bbb       switch to bbb
ccc       switch to ccc
!
    exit 9
}

cmd=$1

if [ $# -eq 0 ]; then 
echo Required parameter '"'Environment'"' not set 
exit 1
usage 
fi 


if [ "$cmd" = "aaa" ]; then 
  cd ~/test/aaa/
  cp $config_file $tmp_file

  url="xxxxxxxxxxxxxx"
  sed -i -e s/xxxxxxxxxx=.*/$url/ $tmp_file
  cp $tmp_file $config_file
fi


  
if [ "$cmd" = "bbb" ]; then
  cd ~/test/bbb/
  cp $config_file $tmp_file

  sed -i -e "s/shouldLogSql = System.properties.containsKey(\"logSql\")/shouldLogSql = true/" $tmp_file

  cp $tmp_file $config_file
fi

if [ "$cmd" = "ccc" ]; then
  cd ~/test/ccc/
  cp $config_file $tmp_file

  if grep "getEnvironment()\.toLowerCase()" $tmp_file; then
    sed -i -e "s/getEnvironment()\.toLowerCase()/\"apac\"/" $tmp_file
  fi

  cp $tmp_file $config_file
fi

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics