Last active
February 23, 2017 19:42
-
-
Save davydany/cdbfc3cb6691488d057c7bb940a2116a to your computer and use it in GitHub Desktop.
Soup Kitchen - Runs vagrant commands for kitchen vms. Get it? Soup Kitchens serve Vagrants?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # soupkitchen | |
| # ----------- | |
| # Runs vagrant commands for kitchen vms | |
| function soupkitchen { | |
| BROWN_ORANGE="\033[0;33m" | |
| RED="\033[0;31m" | |
| NC="\033[0m" # No Color | |
| command=$1; | |
| COOKBOOK_HOME="${PWD}"; | |
| KITCHEN_VAGRANT_HOME="${COOKBOOK_HOME}/.kitchen/kitchen-vagrant"; | |
| if [ -d "${KITCHEN_VAGRANT_HOME}" ]; | |
| then | |
| for dir in `find ${KITCHEN_VAGRANT_HOME} -type d -maxdepth 1 -name 'kitchen-*' 2> /dev/null | tail -n +1`; | |
| do | |
| VAGRANT_DIR="${dir}"; | |
| VAGRANTFILE_PATH=${dir}/Vagrantfile; | |
| if [ -f ${VAGRANTFILE_PATH} ]; | |
| then | |
| cd "${VAGRANT_DIR}"; | |
| echo -e "${BROWN_ORANGE}Running '${command}' for $(basename ${VAGRANT_DIR})...${NC}"; | |
| vagrant ${command}; | |
| cd .. | |
| fi | |
| done | |
| else | |
| echo -e "${RED}You're not in a directory that has a '.kitchen/kitchen-vagrant' directory, or has any Vagrant VMs.${NC}"; | |
| fi | |
| cd ${COOKBOOK_HOME} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment