#!/bin/bash

_install() {
    if [[ $VMFLAG = 1 ]];then
        return 0
    fi
}

_check() {
    _check="PASS"

    ipinfos=`ip add|egrep "eth0|net0|eth1|net1|eth2|net2|bond0"|grep inet|awk '{print $2}'`
    for ipinfo in `echo "$ipinfos"`;
    do
        local_ip=`echo $ipinfo|awk -F '/' '{print $1}'`
        local_netmask=`echo $ipinfo|awk -F '/' '{print $2}'`

        ipdb_info=$(curl -s -X GET -H 'Accept: application/json' -H 'api-key: 9134617e88ce4bf69974805b5089715e' "http://api-gw.ucloudadmin.com/ipdb/intranet/ip?address=%5B%22$local_ip%22%5D")
        ipdb_ipseg=$(echo $ipdb_info|jq -r '.data[]|.ipseg')

        if [[ ! $ipdb_ipseg =~ "/$local_metmask" ]];then
            _check="FAIL"
            PRINT_ERR "[ERROR] Local NetMask $local_netmask Not Match IPDB Recorded ipseg $ipdb_ipseg"
        fi
    done
}
