#!/bin/bash

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

    local HOSTNAME="$(echo $REGION |tr "[A-Z]" "[a-z]")-$Usage-$(echo $HOSTIP|awk -F '.' '{print $3"-"$4}')"
    if [[ $OS == "CentOS6" ]];then
        hostname $HOSTNAME
        if [[ $(grep "HOSTNAME=" /etc/sysconfig/network|wc -l) -eq 1 ]];then
            sed -i "/^HOSTNAME/c\HOSTNAME=$HOSTNAME" /etc/sysconfig/network
        else
            echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network
        fi
    elif [[ $OS == "CentOS7" ]];then
	    hostnamectl set-hostname --static $HOSTNAME
    fi
}

_check() {
    _check="PASS"

    if [[ $VMFLAG = 1 ]];then
        return 0
    fi

    if [[ $(hostname) != *$Usage* ]];then
        _check="FAIL"
        PRINT_ERR "[ERROR] hostname not correct, not include Usage."
    fi
}
