Work in progress for SPECTRA setup.
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4353 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
Executable
+89
@@ -0,0 +1,89 @@
|
||||
#! /bin/bash
|
||||
|
||||
###########################################################
|
||||
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
|
||||
source $THIS_SCRIPT_PATH/env_802dot21.bash
|
||||
###########################################################
|
||||
|
||||
cd $OPENAIR_TARGETS/SIMU/USER
|
||||
|
||||
|
||||
###############################
|
||||
# COMPILE oaisim
|
||||
###############################
|
||||
|
||||
test_command_install_package "gccxml" "gccxml" "--force-yes"
|
||||
test_command_install_package "iptables" "iptables"
|
||||
test_command_install_package "ip" "iproute"
|
||||
test_install_package "openssl"
|
||||
test_install_package "libblas-dev"
|
||||
test_install_package "libxml2"
|
||||
test_install_package "libxml2-dev"
|
||||
test_install_package "libforms-bin" "--force-yes"
|
||||
test_install_package "libforms-dev"
|
||||
test_install_package "libatlas-dev"
|
||||
test_install_package "libatlas-base-dev"
|
||||
test_install_package "libpgm-5.1-0" "--force-yes"
|
||||
test_install_package "libpgm-dev" "--force-yes"
|
||||
test_install_package linux-headers-`uname -r`
|
||||
|
||||
|
||||
#make clean > /dev/null
|
||||
#make cleancell >/dev/null
|
||||
|
||||
echo_success "Executing: make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 -j`grep -c ^processor /proc/cpuinfo `"
|
||||
make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 -j`grep -c ^processor /proc/cpuinfo `
|
||||
if [[ $? -eq 2 ]] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
###############################
|
||||
# COMPILE LTE_RAL_UE
|
||||
###############################
|
||||
cd $OPENAIR3_DIR/RAL-LTE/LTE_RAL_UE
|
||||
make all
|
||||
|
||||
|
||||
###############################
|
||||
# COMPILE LTE_RAL_ENB
|
||||
###############################
|
||||
cd $OPENAIR3_DIR/RAL-LTE/LTE_RAL_ENB
|
||||
make all
|
||||
|
||||
|
||||
###############################
|
||||
# COMPILE rrm_std_cellular
|
||||
###############################
|
||||
cd $OPENAIR_TARGETS/SIMU/USER
|
||||
make rrm_std_cellular
|
||||
if [[ $? -eq 2 ]] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
###############################
|
||||
# COMPILE IP kernel drivers
|
||||
###############################
|
||||
cd $OPENAIR2_DIR
|
||||
make naslite_netlink_ether.ko
|
||||
cd $OPENAIR2_DIR/NAS/DRIVER/LITE/RB_TOOL/
|
||||
make
|
||||
|
||||
###############################
|
||||
# COMPILE MIH-F
|
||||
###############################
|
||||
cd $ODTONE_ROOT
|
||||
b2 --boost-root=$BOOST_ROOT
|
||||
|
||||
|
||||
###############################
|
||||
# COMPILE MIH-USER
|
||||
###############################
|
||||
cd $ODTONE_ROOT/app/lte_test_user/
|
||||
b2 --boost-root=$BOOST_ROOT linkflags=-lrt
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
#####################################################
|
||||
# VARIABLES TO BE FILLED WITH RIGHT VALUES:
|
||||
#####################################################
|
||||
export BOOST_ROOT=/usr/local/src/boost_1_48_0
|
||||
export ODTONE_ROOT=/usr/local/src/odtone_spectra_v1
|
||||
#####################################################
|
||||
|
||||
|
||||
ENV_SCRIPT_SOURCED="?"
|
||||
ENV_SCRIPT_ERRORS="no"
|
||||
|
||||
if [[ $BASH_SOURCE != $0 ]]; then
|
||||
THIS_SCRIPT_PATH=${BASH_SOURCE%env_802dot21.bash}
|
||||
[[ x"$THIS_SCRIPT_PATH" == x ]] && THIS_SCRIPT_PATH="./"
|
||||
ENV_SCRIPT_SOURCED="yes"
|
||||
else
|
||||
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
|
||||
fi
|
||||
|
||||
ENV_SCRIPT_STARTED="yes"
|
||||
source $THIS_SCRIPT_PATH/utils.bash
|
||||
|
||||
if [ ! -d $BOOST_ROOT ]; then
|
||||
echo_error "BOOST_ROOT variable was not set correctly, please update (may be you also need to install boost), exiting."
|
||||
ENV_SCRIPT_ERRORS="yes"
|
||||
else
|
||||
command -v b2 >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_warning "Program b2 is not installed or not in the PATH variable. Trying to resolve..." >&2
|
||||
if [[ -x "$BOOST_ROOT/b2" ]]; then
|
||||
echo_success "Program b2 found in dir $BOOST_ROOT." >&2
|
||||
export PATH=$PATH:$BOOST_ROOT
|
||||
else
|
||||
echo_warning "Program b2 not found in dir $BOOST_ROOT. Trying to install..." >&2
|
||||
cd $BOOST_ROOT; ./bootstrap.sh;
|
||||
cd -
|
||||
export PATH=$PATH:$BOOST_ROOT
|
||||
fi
|
||||
command -v $BOOST_ROOT/b2 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo_success "Program b2 is now reachable by the PATH variable." >&2
|
||||
else
|
||||
echo_error "Built of b2 failed. Please help yourself" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d $ODTONE_ROOT ]; then
|
||||
echo_error "ODTONE_ROOT variable was not set correctly, please update (may be you also need to install odtone), exiting."
|
||||
ENV_SCRIPT_ERRORS="yes"
|
||||
fi
|
||||
|
||||
|
||||
[[ x"$ENV_SCRIPT_ERRORS" == "xyes" ]] && [[ x"$ENV_SCRIPT_SOURCED" == "xyes" ]] && return 1
|
||||
[[ x"$ENV_SCRIPT_ERRORS" == "xyes" ]] && [[ x"$ENV_SCRIPT_SOURCED" == "xno" ]] && exit 1
|
||||
|
||||
Executable
+342
@@ -0,0 +1,342 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
cidr2mask() {
|
||||
local i mask=""
|
||||
local full_octets=$(($1/8))
|
||||
local partial_octet=$(($1%8))
|
||||
|
||||
for ((i=0;i<4;i+=1)); do
|
||||
if [ $i -lt $full_octets ]; then
|
||||
mask+=255
|
||||
elif [ $i -eq $full_octets ]; then
|
||||
mask+=$((256 - 2**(8-$partial_octet)))
|
||||
else
|
||||
mask+=0
|
||||
fi
|
||||
test $i -lt 3 && mask+=.
|
||||
done
|
||||
|
||||
echo $mask
|
||||
}
|
||||
|
||||
|
||||
black='\E[30m'
|
||||
red='\E[31m'
|
||||
green='\E[32m'
|
||||
yellow='\E[33m'
|
||||
blue='\E[34m'
|
||||
magenta='\E[35m'
|
||||
cyan='\E[36m'
|
||||
white='\E[37m'
|
||||
reset_color='\E[00m'
|
||||
|
||||
ROOT_UID=0
|
||||
E_NOTROOT=67
|
||||
|
||||
HOSTNAME=$(hostname -f)
|
||||
|
||||
trim ()
|
||||
{
|
||||
echo "$1" | sed -n '1h;1!H;${;g;s/^[ \t]*//g;s/[ \t]*$//g;p;}'
|
||||
}
|
||||
|
||||
trim2()
|
||||
{
|
||||
local var=$@
|
||||
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
|
||||
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
|
||||
echo -n "$var"
|
||||
}
|
||||
|
||||
cecho() # Color-echo
|
||||
# arg1 = message
|
||||
# arg2 = color
|
||||
{
|
||||
local default_msg="No Message."
|
||||
message=${1:-$default_msg}
|
||||
color=${2:-$green}
|
||||
echo -e -n "$color$message$reset_color"
|
||||
echo
|
||||
return
|
||||
}
|
||||
|
||||
echo_error() {
|
||||
local my_string=""
|
||||
until [ -z "$1" ]
|
||||
do
|
||||
my_string="$my_string$1"
|
||||
shift
|
||||
done
|
||||
cecho "$my_string" $red
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
local my_string=""
|
||||
until [ -z "$1" ]
|
||||
do
|
||||
my_string="$my_string$1"
|
||||
shift
|
||||
done
|
||||
cecho "$my_string" $yellow
|
||||
}
|
||||
|
||||
echo_success() {
|
||||
local my_string=""
|
||||
until [ -z "$1" ]
|
||||
do
|
||||
my_string="$my_string$1"
|
||||
shift
|
||||
done
|
||||
cecho "$my_string" $green
|
||||
}
|
||||
|
||||
bash_exec() {
|
||||
output=$($1 2>&1)
|
||||
result=$?
|
||||
if [ $result -eq 0 ]
|
||||
then
|
||||
echo_success "$1"
|
||||
else
|
||||
echo_error "$1: $output"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
extract() {
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xvjf $1 ;;
|
||||
*.tar.gz) tar xvzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xvf $1 ;;
|
||||
*.tbz2) tar xvjf $1 ;;
|
||||
*.tgz) tar xvzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1 ;;
|
||||
*.7z) 7z x $1 ;;
|
||||
*) echo_error "'$1' cannot be extracted via >extract<" ; return 1;;
|
||||
esac
|
||||
else
|
||||
echo_error "'$1' is not a valid file"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
set_openair() {
|
||||
path=`pwd`
|
||||
declare -i length_path
|
||||
declare -i index
|
||||
length_path=${#path}
|
||||
|
||||
for i in 'openair1' 'openair2' 'openair3' 'openair-cn' 'targets'
|
||||
do
|
||||
index=`echo $path | grep -b -o $i | cut -d: -f1`
|
||||
#echo ${path%$token*}
|
||||
if [[ $index -lt $length_path && index -gt 0 ]]
|
||||
then
|
||||
declare -x OPENAIR_DIR
|
||||
index=`expr $index - 1`
|
||||
openair_path=`echo $path | cut -c1-$index`
|
||||
#openair_path=`echo ${path:0:$index}`
|
||||
export OPENAIR_DIR=$openair_path
|
||||
export OPENAIR_HOME=$openair_path
|
||||
export OPENAIR1_DIR=$openair_path/openair1
|
||||
export OPENAIR2_DIR=$openair_path/openair2
|
||||
export OPENAIR3_DIR=$openair_path/openair3
|
||||
export OPENAIRCN_DIR=$openair_path/openair-cn
|
||||
export OPENAIR_TARGETS=$openair_path/targets
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return -1
|
||||
}
|
||||
|
||||
wait_process_started () {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo_error "WAITING FOR PROCESS START: NO PROCESS"
|
||||
return 1
|
||||
fi
|
||||
ps -C $1 > /dev/null 2>&1
|
||||
while [ $? -ne 0 ]; do
|
||||
echo_warning "WAITING FOR $1 START"
|
||||
sleep 2
|
||||
ps -C $1 > /dev/null 2>&1
|
||||
done
|
||||
echo_success "PROCESS $1 STARTED"
|
||||
return 0
|
||||
}
|
||||
|
||||
is_process_started () {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo_error "WAITING FOR PROCESS START: NO PROCESS"
|
||||
return 1
|
||||
fi
|
||||
ps -C $1 > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo_success "PROCESS $1 NOT STARTED"
|
||||
return 1
|
||||
fi
|
||||
echo_success "PROCESS $1 STARTED"
|
||||
return 0
|
||||
}
|
||||
|
||||
assert() {
|
||||
# If condition false
|
||||
# exit from script with error message
|
||||
E_PARAM_ERR=98
|
||||
E_PARAM_FAILED=99
|
||||
|
||||
if [ -z "$2" ] # Not enought parameters passed.
|
||||
then
|
||||
return $E_PARAM_ERR
|
||||
fi
|
||||
|
||||
lineno=$2
|
||||
if [ ! $1 ]
|
||||
then
|
||||
echo "Assertion failed: \"$1\""
|
||||
echo "File \"$0\", line $lineno"
|
||||
exit $E_ASSERT_FAILED
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
test_install_package() {
|
||||
# usage: test_install_package package_name_to_be_installed optional_option_to_apt_get_install
|
||||
dpkg --get-selections $1 | grep -i install > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_warning "Package $1 is not installed. Installing it." >&2
|
||||
apt-get install $2 $1 -y
|
||||
dpkg --get-selections $1 | grep -i install > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo_success "$1 is installed"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
test_command_install_package() {
|
||||
# usage: test_command_install_package searched_binary package_to_be_installed_if_binary_not_found optional_option_to_apt_get_install
|
||||
if [ $# -eq 2 ]; then
|
||||
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; apt-get install $2 -y; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };}
|
||||
else
|
||||
if [ $# -eq 3 ]; then
|
||||
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it (apt-get install $3 $2)." >&2; apt-get install $3 $2 -y; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };}
|
||||
else
|
||||
echo_success "test_command_install_package: BAD PARAMETER"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo_success "$1 available"
|
||||
}
|
||||
|
||||
test_command_install_script() {
|
||||
# usage: test_command_install_script searched_binary script_to_be_invoked_if_binary_not_found
|
||||
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; bash $2; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };}
|
||||
echo_success "$1 available"
|
||||
}
|
||||
|
||||
start_openswitch_daemon() {
|
||||
rmmod -s bridge
|
||||
if [[ -e "/lib/modules/`uname -r`/extra/openvswitch.ko" ]] ; then
|
||||
bash_exec "insmod /lib/modules/`uname -r`/extra/openvswitch.ko"
|
||||
else
|
||||
echo_error "/lib/modules/`uname -r`/extra/openvswitch.ko not found, exiting"
|
||||
exit -1
|
||||
fi
|
||||
is_process_started "ovsdb-server"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,manager_options --pidfile --detach
|
||||
wait_process_started "ovsdb-server"
|
||||
fi
|
||||
# To be done after installation
|
||||
# ovs-vsctl --no-wait init
|
||||
is_process_started "ovs-vswitchd"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
ovs-vswitchd --pidfile --detach
|
||||
wait_process_started "ovs-vswitchd"
|
||||
fi
|
||||
}
|
||||
|
||||
check_epc_config() {
|
||||
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/epc_$HOSTNAME.conf ]
|
||||
then
|
||||
echo "Cannot find file $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/epc_$HOSTNAME.conf"
|
||||
echo "Please make sure to create one that fits your use (you can use mme_default.conf file as template)"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
check_enb_config() {
|
||||
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/enb_$HOSTNAME.conf ]
|
||||
then
|
||||
echo "Cannot find file $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/enb_$HOSTNAME.conf"
|
||||
echo "Please make sure to create one that fits your use (you can use mme_default.conf file as template)"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
check_for_epc_executable() {
|
||||
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAI_EPC/oai_epc ]
|
||||
then
|
||||
echo "Cannot find oai_epc executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAI_EPC/"
|
||||
echo "Please make sure you have compiled OAI EPC with --enable-standalone-epc option"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
check_for_sgw_executable() {
|
||||
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAI_SGW/oai_sgw ]
|
||||
then
|
||||
echo "Cannot find oai_sgw executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAI_SGW/"
|
||||
echo "Please make sure you have compiled OAI EPC without --enable-standalone-epc option"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
check_for_mme_executable() {
|
||||
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAISIM_MME/oaisim_mme ]
|
||||
then
|
||||
echo "Cannot find oai_sgw executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAISIM_MME/"
|
||||
echo "Please make sure you have compiled OAI EPC without --enable-standalone-epc option"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
check_for_root_rights() {
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
###########################################################
|
||||
declare -x OPENAIR_DIR=""
|
||||
declare -x OPENAIR1_DIR=""
|
||||
declare -x OPENAIR2_DIR=""
|
||||
declare -x OPENAIR3_DIR=""
|
||||
declare -x OPENAIRCN_DIR=""
|
||||
declare -x OPENAIR_TARGETS=""
|
||||
###########################################################
|
||||
|
||||
set_openair
|
||||
cecho "OPENAIR_DIR = $OPENAIR_DIR" $green
|
||||
cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green
|
||||
cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green
|
||||
cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green
|
||||
cecho "OPENAIRCN_DIR = $OPENAIRCN_DIR" $green
|
||||
cecho "OPENAIR_TARGETS = $OPENAIR_TARGETS" $green
|
||||
Reference in New Issue
Block a user