2 # On docker run, Env Variables "STACK_PASS & SERVICE_HOST" should be set using -e
3 # example 'docker run -e "STACK_PASS=stack" -e "SERVICE_HOST=192.168.0.5" compute'
4 set -o nounset # throw an error if a variable is unset to prevent unexpected behaviors
5 # the following variables should be overridden at runtime with docker run -e "..."
6 # ODL_NETWORK, SERVICE_HOST
7 ODL_NETWORK=${ODL_NETWORK:-True}
8 SERVICE_HOST=${SERVICE_HOST:-"192.168.1.2"}
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 [ -z "$(grep "8.8.8.8" /etc/resolv.conf )" ] && 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
21 # get container IP for mgmt network interface
22 ip=`/sbin/ip -o -4 addr list ethphys01 | awk '{print $4}' | cut -d/ -f1`
23 # update no_proxy with service-node info
25 [ -z "$( echo $no_proxy | grep "$(hostname)" )" ] && no_proxy="${no_proxy},$(hostname)"
26 [ -z "$( echo $no_proxy | grep "${ip}" )" ] && no_proxy="${no_proxy},${ip}"
27 [ -z "$( echo $no_proxy | grep "${SERVICE_HOST}" )" ] && no_proxy="${no_proxy},${SERVICE_HOST}"
29 # fix address binding issue in mysql
30 sudo sed -i 's:^bind-address.*:#&:' /etc/mysql/my.cnf
32 # allow services to start
33 sudo sed -i 's:^exit .*:exit 0:' /usr/sbin/policy-rc.d
35 # remove any dead screen sessions from previous stacking
38 # set the correct branch in devstack
39 cd $DEVSTACK_HOME || exit
40 # shellcheck disable=SC2063
41 [ -z "$(git branch -a | grep "* ${BRANCH_NAME}")" ] && \
43 git checkout -b ${BRANCH_NAME} -t ${TAG_NAME}
45 # copy local.conf into devstack and customize, based on environment including:
46 # ODL_NETWORK, ip, DEVSTACK_HOME, SERVICE_HOST
47 cp /home/stack/local.conf $CONF_PATH
49 # Configure local.conf
50 # update the ip of this host
51 sed -i "s:\(HOST_IP=\).*:\1${ip}:" $CONF_PATH
52 sed -i "s:\(SERVICE_HOST=\).*:\1${ip}:" $CONF_PATH
55 cd $DEVSTACK_HOME || exit
56 $DEVSTACK_HOME/stack.sh
58 # write a marker file to indicate successful stacking
60 echo "$(hostname) stacking successful at $(date)" >> stacking.status
61 /home/stack/devstack/tools/info.sh >> stacking.status
62 # set devstack to OFFLINE mode after a successful stack
63 sed -i "s/^#.*\(OFFLINE=True\)/\1/g" /home/stack/$SRC_CONF
64 sed -i "s/^#.*\(RECLONE=False\)/\1/g" /home/stack/$SRC_CONF
67 # vim: set et ts=4 sw=4 :