setenv.shに「-XX:+UseCompressedOops」を追加するプログラム

shellコード:
#!/bin/bash
#Program:
# tomcatのbinにsetenv.shを作成
#ディレクトリを入力
read -p “ディレクトリを入力してください:" dir
if [ ${dir} == “" -o ! -d ${dir} ]; then
echo “$dir 存在しません"
exit 1
fi

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

Source

Posted by arkgame