You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.4 KiB

1 year ago
  1. #!/bin/sh
  2. function log_info()
  3. {
  4. local date=`date`
  5. local para=$1
  6. echo "$date $1"
  7. $1
  8. echo "log info:$date $1" &>> $SYS_LOG
  9. }
  10. SYS_LOG=dockerEnv.log
  11. if [ "$isSidecarEnable" != "" ]; then
  12. if [ "$isSidecarEnable" != "false" ]; then
  13. export tsidecarPort=$sidecarPort
  14. export tserverPort=$serverPort
  15. export sidecarPort=$tserverPort
  16. export serverPort=$tsidecarPort
  17. else
  18. echo "isSidecarEnable=false"> isSidecarEnable.txt
  19. fi
  20. else
  21. echo "isSidecarEnable="> isSidecarEnable.txt
  22. fi
  23. #程式路徑
  24. Path=$1
  25. #檔案類型
  26. TypeName=$2
  27. #排除檔案
  28. removeName=$3
  29. #排除檔案2
  30. removeName2=$4
  31. #排除檔案3
  32. removeName3=$5
  33. #排除檔案4
  34. removeName4=$6
  35. #修改方法一
  36. find $Path/ -name "*.$TypeName" -a ! -name "$removeName1" -a ! -name "$removeName2" -a ! -name "$removeName3" -a ! -name "$removeName4" | xargs grep -r '@' > envSpace.txt
  37. sed 's/[[:space:]]//g' envSpace.txt > env.txt
  38. envDate=$(cat env.txt)
  39. #迴圈解析@
  40. for date in ${envDate}; do
  41. #echo $date
  42. field=2
  43. env=test
  44. filePath=$(cut -d':' -f1 <<< "$date")
  45. #echo $filePath
  46. while [[ "$env" != "" ]]; do
  47. env=$(cut -d'@' -f$field <<< "$date")
  48. let "field+=2"
  49. if [ "$env" != "" ]; then
  50. #修改方法二
  51. envReplace=${env//./_}
  52. envReplace=${envReplace//-/DH}
  53. log_info "sed -i s#@"$env"@#"$(eval echo \$$envReplace)"#g $filePath"
  54. fi
  55. done
  56. done
  57. rm -f envSpace.txt
  58. rm -f env.txt