User Tools

Site Tools


linux:bash:common_functions

Useful bash functions

ssh_it

# CONFIG SECTION
SSHIT="${SSH} ${USERNAME}@${DSTHOST}"
 
# FUNCTION SECTION
ssh_it()
{
  ${SSHIT} $* 2>/dev/null
}

debug_me

debug_me()
{
  if [[ ${DEBUG} -eq 0 ]] ; then
    echo -e "${LIGHTBLUE}DEBUG: ${RESET}$*"
  fi
}

Dependencies:

check_vm

For nutanix:

check_vm()
{
    local THEVM="${1}"
    if [[ $(ssh_it "${ACLI} vm.list" | egrep -i "${THEVM^^}") ]] ; then
        debug_me "${LIGHTGREEN}${THEVM}${RESET} exists on ${CVMIP}"
        #echo -e "${LIGHTGREEN}${THEVM}${RESET} exists on ${CVMIP}"
        return 0
    else
        debug_me "${LIGHTRED}${THEVM}${RESET} NOT exists on ${CVMIP}"
        #echo -e "${LIGHTRED}${THEVM}${RESET} NOT exists on ${CVMIP}"
        return 1
    fi
}
 
# calling it
check_vm "${VMNAME}"
RES=$?

Dependency:

bash_colors

LIGHTGREEN="\033[1;32m"
LIGHTRED="\033[1;31m"
LIGHTBLUE="\033[1;34m"
WHITE="\033[0;37m"
RESET="\033[0;00m"
linux/bash/common_functions.txt · Last modified: 2022/02/11 11:36 by 127.0.0.1