2018年6月10日 星期日

TOMCAT 固化文件


H1(){
if [ "$#" -ne 2 ]
then
echo "\$1 關鍵字"
echo "\$2 色碼"
echo "色碼 4  底線  色碼 7  反白  "
echo "色碼 31 紅字  色碼 41 紅底  "
return
fi
perl -pe 's/('$1')/\e[1;'$2'm$1\e[0m/g';
}



# TOMCAT Alias
TC=/home/apuser/apache-tomcat-7.0.78
alias cdTC='cd  $TC'
alias cdTCBIN='cd ${TC}/bin'
alias STOP_TOMCAT='cd $TC ; sh $TC/bin/shutdown.sh'
alias START_TOMCAT='cd $TC ; sh $TC/bin/startup.sh'
alias TAILCAT='tail -f $TC/logs/catalina.out'
alias TAILASS='tail -f $TC/logs/localhost_access_log.`date +%Y-%m-%d`.txt'
alias PS='ps -ef | grep java | grep tomcat | grep -v grep'





##
## tomcat 固化文件


. ~/consts
. ~/functions



function test0()
{
MSG=" + Test Http Page "
if [ $# -ne 2 ] 
then
echo "$MSG"
echo " \$1 = \$IP    $IP"
echo " \$2 = \$Port  $PORT"
echo ''
echo ''
return 1
fi

echo -e `DisplayToolTip "$MSG"`

type2 $1 $2
type3 $1 $2
type4 $1 $2
type5 $1 $2
}





##    Display --indent 4 --text "- Checking klogd" --result "${STATUS_FOUND}" --color GREEN

function type2(){
MSG=" - Http Test Type2 default page "
if [ $# -ne 2 ] 
then
echo "$MSG"
echo " \$1 = \$IP    $IP"
echo " \$2 = \$Port  $PORT"
echo ''
echo ''
return 1
fi
TEXT=
IP="$1"
PORT="$2"
nc -z -v $IP $PORT > /dev/null || return 3 

if [[ $PORT -eq 8080 || $PORT -eq 80 ]]
then
curl http://${IP}:${PORT} -s |  grep -i -q -e 'tomcat' -e 'apache' -e 'nginx'
fi
if [[ $PORT -eq 8443 || $PORT -eq 443 ]]
then
curl https://${IP}:${PORT} -s |  grep -i -q -e 'tomcat' -e 'apache' -e 'nginx'
fi

TEXT="$MSG"

## echo $?

if [ $? -eq 0 ]
then
STATUS_FOUND=FOUND
COLOR=RED
else
STATUS_FOUND=NotFOUND
COLOR=GREEN
fi
echo -e `Display --indent 4 --text "${TEXT}" --result "${STATUS_FOUND}" --color $COLOR`
}


function type3(){
MSG=" - Http Test Type3 default App "
if [ $# -ne 2 ] 
then
echo "$MSG"
echo " \$1 = \$IP    $IP"
echo " \$2 = \$Port  $PORT"
echo ''
echo ''
return 1
fi
TEXT=
IP="$1"
PORT="$2"
nc -z -v $IP $PORT > /dev/null || return 3 



if [[ $PORT -eq 8080 || $PORT -eq 80 ]]
then


curl http://${IP}:${PORT} -s |  grep -i -q -e 'tomcat' -e 'apache' -e 'nginx'
fi
if [[ $PORT -eq 8443 || $PORT -eq 443 ]]
then
curl https://${IP}:${PORT} -s |  grep -i -q -e 'tomcat' -e 'apache' -e 'nginx'
fi

TEXT="$MSG"

## echo $?
if [ $? -eq 0 ]
then
STATUS_FOUND=FOUND
COLOR=RED
else
STATUS_FOUND=NotFOUND
COLOR=GREEN
fi
echo -e `Display --indent 4 --text "${TEXT}" --result "${STATUS_FOUND}" --color $COLOR`
}


function type4(){
MSG=" - Http Test Type4 404 page"
if [ $# -ne 2 ] 
then
echo "$MSG"
echo " \$1 = \$IP    $IP"
echo " \$2 = \$Port  $PORT"
echo ''
echo ''
return 1
fi
TEXT=
IP="$1"
PORT="$2"
VER=
nc -z -v $IP $PORT > /dev/null || return 3 



if [[ $PORT -eq 8080 || $PORT -eq 80 ]]
then
VER=`curl -s -m 3 http://${IP}:${PORT}/aaa.bbb | \
grep -E "Apache Tomcat/[[:digit:]].*Error report" | \
perl -lne 'm/(?<=title>)(.+)(?= - Error report)/ && print $1'`


fi

if [[ $PORT -eq 8443 || $PORT -eq 443 ]]
then
VER=`curl -s -m 3 https://${IP}:${PORT}/aaa.bbb | \
grep -E "Apache Tomcat/[[:digit:]].*Error report" | \
perl -lne 'm/(?<=title>)(.+)(?= - Error report)/ && print $1'`
fi

TEXT="$MSG"

## echo $?
if [ ! -z "$VER"  ]
then
STATUS_FOUND="$VER"
COLOR=RED
else
STATUS_FOUND=NotFOUND
COLOR=GREEN
fi
echo -e `Display --indent 4 --text "${TEXT}" --result "${STATUS_FOUND}" --color $COLOR`
}



function type5(){
MSG=" - Http Test Type5 Header Server Info"
if [ $# -ne 2 ] 
then
echo "$MSG"
echo " \$1 = \$IP    $IP"
echo " \$2 = \$Port  $PORT"
echo ''
echo ''
return 1
fi
TEXT=
IP="$1"
PORT="$2"
P=
nc -z -v $IP $PORT > /dev/null || return 3 

if [[ $PORT -eq 8080 || $PORT -eq 80 ]]
then

P=`curl -s -I http://${IP}:${PORT}/aaa.bbb | grep -E "^Server|^X-Powered-By" | sed -e 's/Server: //g'`


fi

if [[ $PORT -eq 8443 || $PORT -eq 443 ]]
then

P=`curl -s -I http://${IP}:${PORT}/aaa.bbb | grep -E "^Server|^X-Powered-By" | sed -e 's/Server: //g'`
fi

TEXT="$MSG"

## echo $?
if [[ "$P" =~ "Apache-Coyote" || "$P" =~ "IISa" ]] 
then

STATUS_FOUND="$P"
COLOR=RED
else
STATUS_FOUND=NotFOUND
COLOR=GREEN
fi
echo -e `Display --indent 4 --text "${TEXT}" --result "${STATUS_FOUND}" --color $COLOR`
}

沒有留言:

RHEL install EPEL

  https://www.linuxtechi.com/install-epel-repo-on-rhel-system/ EPEL dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest...