User Tools

Site Tools


zz_deprecated:bash:common_functions

Useful bash functions

DEPRECATED, USE Script template

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"
zz_deprecated/bash/common_functions.txt · Last modified: 2022/11/16 08:18 by dodger