Created
March 27, 2015 16:45
-
-
Save duggan/ca5144d07d49c85602f4 to your computer and use it in GitHub Desktop.
Helper script for managing suspension/resumption of kitchen VMs. Workaround for Omnibus using Kitchen instead of Vagrant.
This file contains 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
#!/bin/sh | |
show_help(){ | |
cat <<-EOF | |
Manage running Kitchen instances. | |
suspend <NAME> Suspend a running kitchen instance. | |
resume <NAME> Resume a kitchen instance. | |
EOF | |
} | |
matcher(){ | |
find .kitchen/kitchen-vagrant/ -name "*$1*" | |
} | |
vm_action(){ | |
action=$1 | |
name=$2 | |
vm=$(matcher ${name}) | |
if [ "xx" != "x${vm}x" ] ; then | |
cwd=$(pwd) | |
cd ${vm} | |
vagrant ${action} | |
cd ${cwd} | |
else | |
echo "No running VM called '${name}'" | |
fi | |
} | |
suspend_vm(){ | |
vm_action suspend $1 | |
} | |
resume_vm(){ | |
vm_action up $1 | |
} | |
if [ "$#" = "0" ] ; then | |
show_help | |
fi | |
case $1 in | |
suspend) | |
suspend_vm $2 | |
;; | |
resume) | |
resume_vm $2 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment