diff --git a/targets/build_helper.bash b/targets/build_helper.bash index c7a336b8aa9a13a86c321673063edf6bbf5c9509..f3959861b5614b8004b682d574f329af794c504f 100755 --- a/targets/build_helper.bash +++ b/targets/build_helper.bash @@ -306,7 +306,6 @@ check_install_freediamter(){ } check_epc_s6a_certificate() { - cnt=0 if [ -d /usr/local/etc/freeDiameter ] then if [ -f /usr/local/etc/freeDiameter/user.cert.pem ] @@ -323,35 +322,34 @@ check_epc_s6a_certificate() { echo_warning "EPC S6A: generatting new certificate in /usr/local/etc/freeDiameter..." cd $OPENAIRCN_DIR/S6A/freediameter ./make_certs.sh ${1:-'eur'} - if [ $cnt = 0 ] ; then - cnt=1 - check_epc_s6a_certificate ${1:-'eur'} + if [ $# -lt 2 ] ; then + check_epc_s6a_certificate ${1:-'eur'} 2 fi - return 1 + exit 1 } -check_s6a_certificate() { - cnt=0 +check_hss_s6a_certificate() { if [ -d /usr/local/etc/freeDiameter ]; then if [ -f /usr/local/etc/freeDiameter/hss.cert.pem ]; then full_hostname=`cat /usr/local/etc/freeDiameter/hss.cert.pem | grep "Subject" | grep "CN" | cut -d '=' -f6` -# if [ $full_hostname = `hostname`.eur ]; then - if [ $full_hostname = hss.eur ]; then - echo_success "S6A: Found valid certificate in /usr/local/etc/freeDiameter" + if [ a$full_hostname == a`hostname`.${1:-'eur'} ] + then + echo_success "HSS S6A: Found valid certificate in /usr/local/etc/freeDiameter" return 0 + else + echo_error "Bad hss hostname found in cert file: "$full_hostname " hostname is "`hostname` fi fi fi echo_error "S6A: Did not find valid certificate in /usr/local/etc/freeDiameter" echo_warning "S6A: generatting new certificate in /usr/local/etc/freeDiameter..." - cd $OPENAIRCN_DIR/S6A/freediameter - make_certs - if [ $cnt = 0 ] ; then - cnt=1 - check_s6a_certificate + cd $OPENAIRCN_DIR/OPENAIRHSS/conf + ./make_certs.sh ${1:-'eur'} + if [ $# -lt 2 ] ; then + check_hss_s6a_certificate ${1:-'eur'} 2 fi - return 1 + exit 1 } check_install_usrp_uhd_driver(){ @@ -632,10 +630,12 @@ check_install_asn1c(){ ################################################ compile_hss() { cd $OPENAIRCN_DIR/OPENAIRHSS + pwd OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*` - if [ $1 = 1 ]; then + if [ $1 -eq 1 ]; then echo_info "build a clean EPC" - bash_exec "rm -rf obj" + bash_exec "rm -rf obj*" + bash_exec "rm configure" fi if [ ! -n "$OBJ_DIR" ]; then OBJ_DIR="objs" @@ -644,32 +644,36 @@ compile_hss() { else OBJ_DIR=`basename $OBJ_DIR` fi + if [ ! -f $OBJ_DIR/Makefile ]; then - if [ ! -n "m4" ]; then + if [ ! -d "m4" ]; then mkdir -m 777 m4 fi echo_success "Invoking autogen" - bash_exec "./autogen.sh" - cd ./$OBJ_DIR - echo_success "Invoking configure" + ./autogen.sh + if [ $? -ne 0 ]; then + return 1 + fi + cd $OBJ_DIR + echo_success "Invoking configure from "`pwd` ../configure else - cd ./$OBJ_DIR + cd $OBJ_DIR fi if [ -f Makefile ]; then - echo_success "Compiling..." - make -j $NUM_CPU + echo_success "Compiling..."pwd + make ; #-j $NUM_CPU if [ $? -ne 0 ]; then echo_error "Build failed, exiting" return 1 - else - cp -pf ./openair-hss $OPENAIR_TARGETS/bin - return 0 + else + cp -pfv ./openair-hss $OPENAIR_TARGETS/bin + return 0 fi else - echo_error "Configure failed, exiting" - return 1 + echo_error "Configure failed, aborting" fi + return 1 } @@ -850,6 +854,7 @@ check_for_hss_executable() { if [ ! -f $OPENAIRCN_DIR/OPENAIRHSS/objs/openair-hss ]; then echo_error "Cannot find openair-hss executable object in directory $OPENAIRCN_DIR/OPENAIRHSS/objs/" echo_error "Please make sure you have compiled OAI HSS" + exit 1 fi } diff --git a/targets/build_oai.bash b/targets/build_oai.bash index df4620719b9a77fe3cdfd496a4f4eb3db7008a6d..4952ace0d8b5f4c985035cfc62a0cd4448607cf1 100755 --- a/targets/build_oai.bash +++ b/targets/build_oai.bash @@ -172,6 +172,7 @@ fi BUILD_LTE=$2 echo "setting top-level build target to: $2" shift 2; + echo > bin/install_log.txt ;; -h | --help) print_help @@ -555,14 +556,15 @@ build_epc(){ exit 1 fi - rm -f /tmp/source.txt + TEMP_FILE=`tempfile` VARIABLES=" S6A_CONF\|\ REALM" VARIABLES=$(echo $VARIABLES | sed -e 's/\\r//g') VARIABLES=$(echo $VARIABLES | tr -d ' ') - cat $CONFIG_FILE | grep -w "$VARIABLES"| tr -d " " | tr -d ";" > /tmp/source.txt - source /tmp/source.txt + cat $CONFIG_FILE | grep -w "$VARIABLES"| tr -d " " | tr -d ";" > $TEMP_FILE + source $TEMP_FILE + rm -f $TEMP_FILE if [ x"$REALM" == "x" ]; then echo_error "Your config file do not contain a REALM for S6A configuration" @@ -594,7 +596,7 @@ build_hss(){ hss_compiled=1 - echo_info "Note: this scripts works only for Ubuntu 12.04" + echo_info "Note: this script tested only for Ubuntu 12.04 x64 -> 14.04 x64" ###################################### # CHECK MISC SOFTWARES AND LIBS # @@ -607,13 +609,10 @@ build_hss(){ if [ $OAI_CLEAN -eq 1 ]; then check_install_freediamter else - if [ ! -d /usr/local/etc/freeDiameter ]; then - check_install_freediamter - fi + if [ ! -d /usr/local/etc/freeDiameter ]; then + check_install_freediamter + fi fi - $(make_certs >> bin/install_log.txt 2>&1) - output=$(check_s6a_certificate >> bin/install_log.txt 2>&1) - hss_certificate_generated=$? ###################################### # compile HSS # @@ -622,9 +621,29 @@ build_hss(){ output=$(compile_hss $OAI_CLEAN >> bin/install_log.txt 2>&1 ) hss_compiled=$? + if [ $hss_compiled -eq 1 ]; then + echo_error "Failed in compiling hss target: check the installation log file bin/install_log.txt" + exit 1 + fi check_for_hss_executable echo_info "finished hss target: check the installation log file bin/install_log.txt" +###################################### +# Check certificates # +###################################### + + TEMP_FILE=`tempfile` + cat $OPENAIRCN_DIR/OPENAIRHSS/conf/hss_fd.conf | grep -w "Identity" | tr -d " " | tr -d ";" > $TEMP_FILE + source $TEMP_FILE + rm -f $TEMP_FILE + + if [ x"$Identity" == "x" ]; then + echo_error "Your config file do not contain a host identity for S6A configuration" + exit 1 + fi + HSS_REALM=$(echo $Identity | sed 's/.*\.//') + check_hss_s6a_certificate $HSS_REALM + ###################################### # fill the HSS DB ###################################### @@ -635,7 +654,7 @@ build_hss(){ output=$(create_hss_database $USER $PW ) hss_db_created=$? if [ $hss_db_created = 0 ]; then - echo_warning "hss DB not created" + echo_warning "hss DB not created" fi ###################################### # install hss @@ -646,14 +665,16 @@ build_hss(){ echo_success "target hss built, DB created and installed in the bin directory" echo "target hss built, DB created, and installed in the bin directory" >> bin/${oai_build_date} cp -rf $OPENAIRCN_DIR/OPENAIRHSS/conf $OPENAIR_TARGETS/bin - $SUDO cp $OPENAIR_TARGETS/bin/conf/hss_fd.local.conf /etc/openair-hss + $SUDO cp $OPENAIR_TARGETS/bin/conf/hss_fd.local.conf /etc/openair-hss + rm -f $OPENAIR_TARGETS/bin/openair-hss + cp -pv $OPENAIRCN_DIR/OPENAIRHSS/objs/openair-hss $OPENAIR_TARGETS/bin/ fi ###################################### # LAUNCH HSS # ###################################### - echo_info "8. run hss in bin/: ./openair-hss -c conf/hss.local.conf" - cd bin + echo_info "8. run hss in $OPENAIR_TARGETS/bin/: ./openair-hss -c conf/hss.local.conf" + cd $OPENAIR_TARGETS/bin ./openair-hss -c conf/hss.local.conf } @@ -731,6 +752,7 @@ case "$BUILD_LTE" in build_epc ;; 'HSS') + echo_warning "BUILD_LTE: $BUILD_LTE" echo_warning "build HSS: Experimental" build_hss ;;