Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 3 | uId=`id -u` |
| 4 | vmName="voltha_voltha${uId}" |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 5 | |
| 6 | # Voltha directory |
| 7 | cd .. |
| 8 | |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 9 | # Blow away the settings file, we're going to set all the settings below |
| 10 | rm -f settings.vagrant.yaml |
| 11 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 12 | # Rename voltha for multi-user support |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 13 | echo "---" > settings.vagrant.yaml |
| 14 | echo "# The name to use for the server" >> settings.vagrant.yaml |
| 15 | echo 'server_name: "voltha'${uId}'"' >> settings.vagrant.yaml |
| 16 | # Make sure that we're using KVM and not virtualbox |
| 17 | echo '# Use KVM as the VM provider' >> settings.vagrant.yaml |
| 18 | echo 'vProvider: "KVM"' >> settings.vagrant.yaml |
| 19 | echo '# Use virtualbox as the VM provider' >> settings.vagrant.yaml |
| 20 | echo '#vProvider: "virtualbox"' >> settings.vagrant.yaml |
| 21 | # Build voltha in the specified mode if any |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 22 | if [ $# -eq 1 -a "$1" == "test" ]; then |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 23 | echo '# This determines if test mode is active' >> settings.vagrant.yaml |
| 24 | echo 'testMode: "true"' >> settings.vagrant.yaml |
| 25 | echo '# This determines if installer mode is active' >> settings.vagrant.yaml |
| 26 | echo 'installMode: "false"' >> settings.vagrant.yaml |
| 27 | elif [ $# -eq 1 -a "$1" == "install" ]; then |
| 28 | echo '# This determines if installer mode is active' >> settings.vagrant.yaml |
| 29 | echo 'installMode: "true"' >> settings.vagrant.yaml |
| 30 | echo '# This determines if test mode is active' >> settings.vagrant.yaml |
| 31 | echo 'testMode: "false"' >> settings.vagrant.yaml |
| 32 | else |
| 33 | echo '# This determines if installer mode is active' >> settings.vagrant.yaml |
| 34 | echo 'installMode: "false"' >> settings.vagrant.yaml |
| 35 | echo '# This determines if test mode is active' >> settings.vagrant.yaml |
| 36 | echo 'testMode: "false"' >> settings.vagrant.yaml |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 37 | fi |
| 38 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 39 | # Destroy the VM if it's running |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 40 | vagrant destroy voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 41 | |
| 42 | # Bring up the VM. |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 43 | vagrant up voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 44 | |
| 45 | # Get the VM's ip address |
| 46 | ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'` |
| 47 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 48 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 49 | # Run all the build commands |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 50 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr "cd /cord/incubator/voltha && . env.sh && make fetch && make build" |