Commit 35985c44 authored by Lionel Gauthier's avatar Lionel Gauthier

Added test_command_install for installing a package if a command is missing.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4330 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 9e149aa8
...@@ -98,35 +98,25 @@ set_openair() { ...@@ -98,35 +98,25 @@ set_openair() {
declare -i index declare -i index
length_path=${#path} length_path=${#path}
index=`echo $path | grep -b -o 'targets' | cut -d: -f1` for i in 'openair1' 'openair2' 'openair3' 'openair-cn' 'targets'
#echo ${path%$token*} do
if [[ $index -lt $length_path && index -gt 0 ]] index=`echo $path | grep -b -o $i | cut -d: -f1`
then #echo ${path%$token*}
declare -x OPENAIR_DIR if [[ $index -lt $length_path && index -gt 0 ]]
index=`expr $index - 1` then
openair_path=`echo $path | cut -c1-$index` declare -x OPENAIR_DIR
#openair_path=`echo ${path:0:$index}` index=`expr $index - 1`
export OPENAIR_DIR=$openair_path openair_path=`echo $path | cut -c1-$index`
export OPENAIR1_DIR=$openair_path/openair1 #openair_path=`echo ${path:0:$index}`
export OPENAIR2_DIR=$openair_path/openair2 export OPENAIR_DIR=$openair_path
export OPENAIR3_DIR=$openair_path/openair3 export OPENAIR_HOME=$openair_path
export OPENAIR_TARGETS=$openair_path/targets export OPENAIR1_DIR=$openair_path/openair1
return 0 export OPENAIR2_DIR=$openair_path/openair2
fi export OPENAIR3_DIR=$openair_path/openair3
index=`echo $path | grep -b -o 'openair3' | cut -d: -f1` export OPENAIR_TARGETS=$openair_path/targets
if [[ $index -lt $length_path && index -gt 0 ]] return 0
then fi
declare -x OPENAIR_DIR done
index=`expr $index - 1`
openair_path=`echo $path | cut -c1-$index`
#openair_path=`echo ${path:0:$index}`
export OPENAIR_DIR=$openair_path
export OPENAIR1_DIR=$openair_path/openair1
export OPENAIR2_DIR=$openair_path/openair2
export OPENAIR3_DIR=$openair_path/openair3
export OPENAIR_TARGETS=$openair_path/targets
return 0
fi
return -1 return -1
} }
...@@ -182,6 +172,12 @@ assert() { ...@@ -182,6 +172,12 @@ assert() {
fi fi
} }
test_command_install() {
# usage: test_command_install searched_binary package_to_be_installed_if_binary_not_found
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; };}
echo_success "$1 available"
}
start_openswitch_daemon() { start_openswitch_daemon() {
rmmod -s bridge rmmod -s bridge
if [[ -e "/lib/modules/`uname -r`/extra/openvswitch.ko" ]] ; then if [[ -e "/lib/modules/`uname -r`/extra/openvswitch.ko" ]] ; then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment