blob: bcfb955e47885618e2fcb1f6448767ac99ed3308 [file] [log] [blame]
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -04001#!/bin/bash
2
Sergio Slobodrian7c483622017-06-13 15:51:34 -04003uId=`id -u`
4vmName="voltha_voltha${uId}"
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -04005
6# Voltha directory
7cd ..
8
Sergio Slobodrian36e16552017-06-19 11:00:45 -04009# Blow away the settings file, we're going to set all the settings below
10rm -f settings.vagrant.yaml
11
Sergio Slobodrian7c483622017-06-13 15:51:34 -040012# Rename voltha for multi-user support
Sergio Slobodrian36e16552017-06-19 11:00:45 -040013echo "---" > settings.vagrant.yaml
14echo "# The name to use for the server" >> settings.vagrant.yaml
15echo 'server_name: "voltha'${uId}'"' >> settings.vagrant.yaml
16# Make sure that we're using KVM and not virtualbox
17echo '# Use KVM as the VM provider' >> settings.vagrant.yaml
18echo 'vProvider: "KVM"' >> settings.vagrant.yaml
19echo '# Use virtualbox as the VM provider' >> settings.vagrant.yaml
20echo '#vProvider: "virtualbox"' >> settings.vagrant.yaml
21# Build voltha in the specified mode if any
Sergio Slobodrian7c483622017-06-13 15:51:34 -040022if [ $# -eq 1 -a "$1" == "test" ]; then
Sergio Slobodrian36e16552017-06-19 11:00:45 -040023 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
27elif [ $# -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
32else
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 Slobodrian7c483622017-06-13 15:51:34 -040037fi
38
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040039# Destroy the VM if it's running
Sergio Slobodrian7c483622017-06-13 15:51:34 -040040vagrant destroy voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040041
42# Bring up the VM.
Sergio Slobodrian7c483622017-06-13 15:51:34 -040043vagrant up voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040044
45# Get the VM's ip address
46ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'`
47
Sergio Slobodrian7c483622017-06-13 15:51:34 -040048
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040049# Run all the build commands
Sergio Slobodrian61287792017-06-27 12:14:05 -040050if [ $# -eq 1 -a "$1" == "test" ]; then
51 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \
52 .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \
53 "cd /cord/incubator/voltha && . env.sh && make fetch && make build"
54 rtrn=$?
55else
56 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \
57 .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \
58 "cd /cord/incubator/voltha && . env.sh && make fetch && make production"
59 rtrn=$?
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040060fi
61
Sergio Slobodrian61287792017-06-27 12:14:05 -040062echo "Build return code: $rtrn"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040063
Sergio Slobodrian61287792017-06-27 12:14:05 -040064exit $rtrn
65