mirror of
https://github.com/YunoHost/ynh-dev.git
synced 2024-09-03 20:05:59 +02:00
[enh] add halt feature:
- Retrieve running VM. - Turn the VM off if running. - Otherwise warn that there is no running VM.
This commit is contained in:
parent
06c9caf46d
commit
20fd7daa7e
1 changed files with 17 additions and 0 deletions
17
ynh-dev
17
ynh-dev
|
@ -9,6 +9,8 @@ Usage :
|
|||
Create a dev environment into PATH
|
||||
`basename $0` run DOMAIN [VERSION]
|
||||
Run a vagrant or virtualbox vm
|
||||
`basename $0` halt
|
||||
Turn off running vm
|
||||
# `basename $0` kill
|
||||
# Kill all vagrant
|
||||
|
||||
|
@ -144,6 +146,21 @@ elif [ "$1" = "run" ]; then
|
|||
vagrant ssh $VERSION
|
||||
|
||||
|
||||
#####################
|
||||
## Halt running VM ##
|
||||
#####################
|
||||
elif [ "$1" = "halt" ]; then
|
||||
vm=$(vagrant global-status | head -3 | tail -1)
|
||||
vm_status=$(echo $vm | cut -d ' ' -f 4)
|
||||
if [ $vm_status == "running" ]; then
|
||||
vm_id=$(echo $vm | cut -d ' ' -f 1)
|
||||
vagrant halt $vm_id
|
||||
echo "–> VM turned off."
|
||||
else
|
||||
echo "–> No running vm."; exit
|
||||
fi
|
||||
|
||||
|
||||
#####################
|
||||
## Kill running VM ##
|
||||
#####################
|
||||
|
|
Loading…
Add table
Reference in a new issue