2 # On docker run, Env Variables "STACK_PASS & SERV_HOST" should be set using -e
3 # example 'docker run -e "STACK_PASS=stack" -e "SERV_HOST=192.168.0.5" compute'
4 # or overided below by uncommenting:
6 # SERV_HOST="192.168.0.5"
7 # ODL_NETWORK should be set in the 'docker run' script
8 set -o nounset # throw an error if a variable is unset to prevent unexpected behaviors
9 ODL_NETWORK=${ODL_NETWORK}
10 DEVSTACK_HOME="/home/stack/devstack"
11 CONF_PATH=$DEVSTACK_HOME/local.conf
12 BRANCH_NAME=stable/newton
13 TAG_NAME="origin/${BRANCH_NAME}"
15 #Set Nameserver to google
16 echo nameserver 8.8.8.8 | sudo tee -a /etc/resolv.conf
18 # change the stack user password
19 echo "stack:$STACK_PASS" | sudo chpasswd
22 ip=`/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1`
25 # Centos7: sudo: service: command not found
26 #sudo service ssh start
29 # Centos7: sudo: service: command not found
30 #sudo service openvswitch-switch start
32 # set the correct branch in devstack
35 git checkout -b ${BRANCH_NAME} -t ${TAG_NAME}
37 # copy local.conf into devstack and customize, based on environment including:
38 # ODL_NETWORK, ip, DEVSTACK_HOME, SERV_HOST
39 cp /home/stack/local.conf $CONF_PATH
41 # Configure local.conf
42 # update the ip of this host & SERVICE_HOST
43 sed -i "s/HOST_IP=.*/HOST_IP=${ip}/" $CONF_PATH
44 sed -i "s/SERVICE_HOST=.*/SERVICE_HOST=$SERV_HOST/" $CONF_PATH
45 # modify the local.conf according to ODL_NETWORK value
46 echo "Preparing $CONF_PATH for ODL=$ODL_NETWORK"
48 if [ "$ODL_NETWORK" = "false" ] ; then
49 # prepare local.conf to NOT use ODL networking (default to Neutron)
50 sed -i "s:^\(enable_plugin networking-odl\):#\1:g" $CONF_PATH
51 sed -i "s:^\(ODL_MODE=compute\):#\1:g" $CONF_PATH
52 sed -i "s:^\(ENABLED_SERVICES=\).*:\1n-cpu,q-agt:g" $CONF_PATH
54 # prepare local.conf to use ODL networking
55 sed -i "s:^#\(enable_plugin networking-odl\):\1:g" $CONF_PATH
56 sed -i "s:^#\(ODL_MODE=compute\):\1:g" $CONF_PATH
57 sed -i "s:^\(ENABLED_SERVICES=\).*:\1n-cpu:g" $CONF_PATH
60 $DEVSTACK_HOME/stack.sh