blob: 9cd8f624627ec4234aa68bb920150d2871accd33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/bin/bash
##############################################################################
# Copyright (c) 2016-2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
SCRIPT_DIR=${WORK_DIR}/scripts
function generate_conf()
{
rm -rf ${SCRIPT_DIR}
mkdir -p ${SCRIPT_DIR}
python ${OPERA_DIR}/process_conf.py ${CONF_DIR}/open-o.yml \
${CONF_DIR}/vnf.yml
}
function package_prepare()
{
if [[ $(grep Ubuntu /etc/issue) ]]; then
sudo apt-get update -y
sudo apt-get install -y wget python-pip sshpass figlet curl net-tools
else
# not test with redhat server yet
sudo yum update -y
sudo yum install -y wget python-pip sshpass figlet curl net-tools
fi
sudo pip install pyyaml
docker version &>/dev/null
if [[ $? != 0 ]];then
curl -sSL https://experimental.docker.com/ | sh
service docker start
fi
}
function network_prepare()
{
local assigned_ip=`sed -n 's/OPENO_IP=//p' ${SCRIPT_DIR}/open-o.conf`
echo $assigned_ip
if [[ $assigned_ip != 'None' ]]; then
if [[ ! $(ifconfig -a | grep openo) ]]; then
sudo ip tuntap add dev openo mode tap
fi
sudo ifconfig openo $assigned_ip up
else
external_nic=`ip route |grep '^default'|awk '{print $5F}'`
host_ip=`ifconfig $external_nic | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
sed -i "s/^\(.*OPENO_IP=\).*/\1$host_ip/g" ${SCRIPT_DIR}/open-o.conf
fi
}
function prepare_env()
{
package_prepare
generate_conf
network_prepare
}
|