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 | ba9cbd8 | 2017-06-22 11:45:49 -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 production" | tee voltha_build.tmp |
| 51 | |
| 52 | rtrn=$# |
| 53 | |
| 54 | if [ $rtrn -ne 0 ]; then |
| 55 | rm -f voltha_build.tmp |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | egrep 'Makefile:[0-9]+: recipe for target .* failed' voltha_build.tmp |
| 60 | |
| 61 | rtrn=$# |
| 62 | rm -f voltha_build.tmp |
| 63 | if [ $rtrn -eq 0 ]; then |
| 64 | # An error occured, notify the caller |
| 65 | exit 1 |
| 66 | fi |