====== Useful bash functions ======
**DEPRECATED, USE** [[https://git.ciberterminal.net/dodger/script_template|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:
* [[#bash_colors]]
===== 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:
* [[#ssh_it]]
* [[#debug_me]]
* ''${CVMIP}'' must be defined
====== bash_colors ======
LIGHTGREEN="\033[1;32m"
LIGHTRED="\033[1;31m"
LIGHTBLUE="\033[1;34m"
WHITE="\033[0;37m"
RESET="\033[0;00m"