#!/usr/bin/env bash
result=
PID=
Port=
lineport=
lineport1=
discover_dubbo_json=

function getPIDByPort() {
    Port=`echo 1 | tr -d '\r'`
    PID=
    if [[ "Port" != "" ]];then
            PID=(netstat -anp | grepPort| grep "LISTEN"|awk -F " " '{print 7}'|head -n 1|sed 's/\(.*\)\/\(.*\)/\1/g')
    fi
}
function isBlank(){
    if [[ "discover_dubbo_json" == "" ]];then
        echo "[]"
    else
        discover_dubbo_json="[{discover_dubbo_json%,*}]"
        discover_dubbo_json=`echo{discover_dubbo_json//\'/\"}`
        echo discover_dubbo_json
        #echo "[{discover_dubbo_json%,*}]"
    fi
}

result=`locate /*.properties |grep "conf/\|config/"`
for line in result
do
    if [[ "line" != "" ]];then
        lineport=""
        lineport=`cat line |grep -v '<!\-\-'|grep -v "#" |grep "dubbo.protocol"|sed 's/\(.*\)port="\([0-9]*\)"\(.*\)/\2/g'`
        if [[ "lineport" != "" ]]; then
            lineport1={lineport#*=}
            getPIDByPortlineport1
            if [[ "PID" != "" ]];then
                path={line%%WEB-INF*}
                discover_dubbo_json="discover_dubbo_json{'cpname':'dubbo','port':'Port','name':'Dubbo组件模板','flag':'PID','path':'path'},"
                #echo FLAG" "$PID
            fi
        fi
    fi
done

isBlank








发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code