mirror of
https://github.com/YunoHost/ynh-dev.git
synced 2024-09-03 20:05:59 +02:00
[fix] Be able to create multiple VM (Redmine 931) (#27)
* [fix] Unable to run several vm * [enh] Add a comment about how to refund an old vm * [fix] Bad instruction display in comment
This commit is contained in:
parent
b9346e4508
commit
5dc4bc6ce7
1 changed files with 17 additions and 4 deletions
21
ynh-dev
21
ynh-dev
|
@ -157,6 +157,17 @@ elif [ "$1" = "run" ]; then
|
|||
}
|
||||
done
|
||||
|
||||
# Update Vagrantfile
|
||||
grep "### END AUTOMATIC YNH-DEV ###" ./Vagrantfile &> /dev/null || {
|
||||
pushd ./vagrant &> /dev/null
|
||||
git pull
|
||||
popd &> /dev/null
|
||||
rm ./Vagrantfile
|
||||
ln -s vagrant/Vagrantfile Vagrantfile
|
||||
|
||||
}
|
||||
|
||||
# Adapt vagrantfile
|
||||
sed -i "/ ### END AUTOMATIC YNH-DEV ###/ i \\
|
||||
config.vm.define \"${VMNAME}\" do |${VMNAME}| \
|
||||
\n ${VMNAME}.vm.box = \"yunohost/jessie-${VERSION}\" \
|
||||
|
@ -166,18 +177,20 @@ elif [ "$1" = "run" ]; then
|
|||
}
|
||||
|
||||
# Run VM
|
||||
vagrant up $VERSION --provider virtualbox
|
||||
echo "/!\ If you don't refund an old vm, may be the vm has been \
|
||||
accidentally named with the VERSION, try to run 'ynh-dev run VERSION' with \
|
||||
VERSION as stable, testing or unstable /!\ "
|
||||
vagrant up $VMNAME --provider virtualbox
|
||||
|
||||
# Warn user about hosts file
|
||||
IP_LINE="\s\s*${VMNAME}.vm.network\s\s*:private_network,\s*ip:\s*\""
|
||||
IP=$(grep "$IP_LINE" Vagrantfile | sed "s/${IP_LINE}//")
|
||||
IP=${IP::-1}
|
||||
IP=$(grep "$IP_LINE" Vagrantfile | sed "s/${IP_LINE}//" | tr -d '"')
|
||||
echo "/!\ Please add '$IP $DOMAIN' to your /etc/hosts file /!\\"
|
||||
echo "sudo sh -s 'echo \"$IP $DOMAIN\" >> /etc/hosts'"
|
||||
echo ""
|
||||
|
||||
# Log into the VM
|
||||
vagrant ssh $VERSION
|
||||
vagrant ssh $VMNAME
|
||||
|
||||
|
||||
#####################
|
||||
|
|
Loading…
Reference in a new issue