给setenv.sh增加-XX:+UseCompressedOops

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/bin/bash
#Program:
#    在每个tomcat下的bin里创建setenv.sh

#1.输入目录
read -p "请输入shequ的目录:" dir
if [ ${dir} == "" -o ! -d ${dir} ]; then 
    echo "$dir 不存在"
    exit 1
fi

#为每个目录下创建sentenv.sh
dirList=$(ls -d ${dir}/*/bin )
for binDir in $dirList
do
    #没有就创建setenv.sh
    fileName=${binDir}/setenv.sh
    if [ ! -f fileName ]; then
      touch ${fileName}
    fi
    temp=$(cat ${fileName})
    
    count1=$(echo ${temp}|grep -c 'JAVA_OPTS')
    count2=$(echo ${temp}|grep -c 'UseCompressedOops')
   # echo ${fileName}${count1}${count2}
    if [ ${count1} == '1' ] &&  [ ${count2} == '0' ]; then 
       temp=$(echo ${temp}|sed 's/"$/ -XX:+UseCompressedOops"/g')
    elif [ ${count1} == '0' ]; then
       temp='JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedOops"'
    fi
    
    echo ${temp}>${fileName}
done