Skip to content

Instantly share code, notes, and snippets.

@duggan
Created March 27, 2015 16:45
Show Gist options
  • Save duggan/ca5144d07d49c85602f4 to your computer and use it in GitHub Desktop.
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.
#!/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