Commit 021ca70b authored by Navid Nikaein's avatar Navid Nikaein

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5980 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 35bd7f34
...@@ -45,6 +45,7 @@ USER=`whoami` ...@@ -45,6 +45,7 @@ USER=`whoami`
BUILD_FROM_MAKEFILE=0 BUILD_FROM_MAKEFILE=0
SUDO='' SUDO=''
PW='' PW=''
UBUNTU_REL=`lsb_release -r | cut -f2`
set_build_from_makefile(){ set_build_from_makefile(){
BUILD_FROM_MAKEFILE=$1 BUILD_FROM_MAKEFILE=$1
...@@ -127,25 +128,27 @@ make_certs(){ ...@@ -127,25 +128,27 @@ make_certs(){
echo "creating the certificate" echo "creating the certificate"
user=$(whoami) user=$(whoami)
HOSTNAME=$(hostname) HOSTNAME=$(hostname -f)
echo "Creating certificate for user '$HOSTNAME'" echo "Creating certificate for user '$HOSTNAME'"
# CA self certificate # CA self certificate
openssl req -new -batch -x509 -days 3650 -nodes -newkey rsa:1024 -out cacert.pem -keyout cakey.pem -subj /CN=eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM openssl req -new -batch -x509 -days 3650 -nodes -newkey rsa:1024 -out cacert.pem -keyout cakey.pem -subj /CN=eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM
openssl genrsa -out user.key.pem 1024 # openssl genrsa -out user.key.pem 1024
openssl req -new -batch -out user.csr.pem -key user.key.pem -subj /CN=$HOSTNAME.eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM openssl genrsa -out hss.key.pem 1024
openssl ca -cert cacert.pem -keyfile cakey.pem -in user.csr.pem -out user.cert.pem -outdir . -batch #openssl req -new -batch -out user.csr.pem -key user.key.pem -subj /CN=$HOSTNAME.eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM
openssl req -new -batch -out hss.csr.pem -key hss.key.pem -subj /CN=hss.eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM
openssl ca -cert cacert.pem -keyfile cakey.pem -in hss.csr.pem -out hss.cert.pem -outdir . -batch
if [ ! -d /usr/local/etc/freeDiameter ]; then if [ ! -d /usr/local/etc/freeDiameter ]; then
echo "Creating non existing directory: /usr/local/etc/freeDiameter/" echo "Creating non existing directory: /usr/local/etc/freeDiameter/"
$SUDO mkdir /usr/local/etc/freeDiameter/ $SUDO mkdir /usr/local/etc/freeDiameter/
fi fi
echo "Copying cakey.pem user.key.pem cacert.pem to /usr/local/etc/freeDiameter/" echo "Copying *.pem to /usr/local/etc/freeDiameter/"
$SUDO cp user.key.pem user.cert.pem cacert.pem /usr/local/etc/freeDiameter/ $SUDO cp *.pem /usr/local/etc/freeDiameter/
mv user.key.pem user.cert.pem cacert.pem bin/ mv *.pem bin/
# openssl genrsa -out ubuntu.key.pem 1024 # openssl genrsa -out ubuntu.key.pem 1024
# openssl req -new -batch -x509 -out ubuntu.csr.pem -key ubuntu.key.pem -subj /CN=ubuntu.localdomain/C=FR/ST=BdR/L=Aix/O=fD/OU=Tests # openssl req -new -batch -x509 -out ubuntu.csr.pem -key ubuntu.key.pem -subj /CN=ubuntu.localdomain/C=FR/ST=BdR/L=Aix/O=fD/OU=Tests
...@@ -154,46 +157,49 @@ make_certs(){ ...@@ -154,46 +157,49 @@ make_certs(){
} }
check_install_freediamter(){ check_install_freediamter(){
if [ ! -d /usr/local/src/ ]; then
echo "/usr/local/src/ doesn't exist please create one"
exit -1
fi
if [ ! -w /usr/local/src/ ]; then
echo "You don't have permissions to write to /usr/local/src/, installing as a sudoer"
# exit -1
fi
cd /usr/local/src/
echo "Downloading nettle archive"
if [ -f nettle-2.5.tar.gz ]; then if [ $UBUNTU_REL = "12.04" ]; then
$SUDO rm -f nettle-2.5.tar.gz
fi
if [ -f nettle-2.5.tar ]; then
$SUDO rm -f nettle-2.5.tar
fi
if [ -d nettle-2.5 ]; then
$SUDO rm -rf nettle-2.5/
fi
$SUDO wget ftp://ftp.lysator.liu.se/pub/security/lsh/nettle-2.5.tar.gz if [ ! -d /usr/local/src/ ]; then
$SUDO gunzip nettle-2.5.tar.gz echo "/usr/local/src/ doesn't exist please create one"
$SUDO echo "Uncompressing nettle archive" exit -1
$SUDO tar -xf nettle-2.5.tar fi
cd nettle-2.5/
$SUDO ./configure --disable-openssl --enable-shared --prefix=/usr if [ ! -w /usr/local/src/ ]; then
if [ $? -ne 0 ]; then echo "You don't have permissions to write to /usr/local/src/, installing as a sudoer"
exit -1 # exit -1
fi
cd /usr/local/src/
echo "Downloading nettle archive"
if [ -f nettle-2.5.tar.gz ]; then
$SUDO rm -f nettle-2.5.tar.gz
fi
if [ -f nettle-2.5.tar ]; then
$SUDO rm -f nettle-2.5.tar
fi
if [ -d nettle-2.5 ]; then
$SUDO rm -rf nettle-2.5/
fi
$SUDO wget ftp://ftp.lysator.liu.se/pub/security/lsh/nettle-2.5.tar.gz
$SUDO gunzip nettle-2.5.tar.gz
$SUDO echo "Uncompressing nettle archive"
$SUDO tar -xf nettle-2.5.tar
cd nettle-2.5/
$SUDO ./configure --disable-openssl --enable-shared --prefix=/usr
if [ $? -ne 0 ]; then
exit -1
fi
echo "Compiling nettle"
$SUDO make -j $NUM_CPU
$SUDO make check
$SUDO make install
cd ../
fi fi
echo "Compiling nettle"
$SUDO make -j $NUM_CPU
$SUDO make check
$SUDO make install
cd ../
echo "Downloading gnutls archive" echo "Downloading gnutls archive"
...@@ -203,9 +209,9 @@ check_install_freediamter(){ ...@@ -203,9 +209,9 @@ check_install_freediamter(){
if [ -d gnutls-3.1.0/ ]; then if [ -d gnutls-3.1.0/ ]; then
$SUDO rm -rf gnutls-3.1.0/ $SUDO rm -rf gnutls-3.1.0/
fi fi
test_uninstall_package libgnutls-dev test_uninstall_package libgnutls-dev
$SUDO wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-3.1.0.tar.xz $SUDO wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-3.1.0.tar.xz
$SUDO tar -xf gnutls-3.1.0.tar.xz $SUDO tar -xf gnutls-3.1.0.tar.xz
echo "Uncompressing gnutls archive ($PWD)" echo "Uncompressing gnutls archive ($PWD)"
...@@ -218,7 +224,7 @@ check_install_freediamter(){ ...@@ -218,7 +224,7 @@ check_install_freediamter(){
$SUDO make -j $NUM_CPU $SUDO make -j $NUM_CPU
$SUDO make install $SUDO make install
cd ../ cd ../
echo "Downloading freeDiameter archive" echo "Downloading freeDiameter archive"
if [ -f 1.1.5.tar.gz ]; then if [ -f 1.1.5.tar.gz ]; then
...@@ -245,17 +251,19 @@ check_install_freediamter(){ ...@@ -245,17 +251,19 @@ check_install_freediamter(){
$SUDO make test $SUDO make test
$SUDO sudo make install $SUDO sudo make install
make_certs # make_certs
} }
check_s6a_certificate() { check_s6a_certificate() {
cnt=0
if [ -d /usr/local/etc/freeDiameter ]; then if [ -d /usr/local/etc/freeDiameter ]; then
if [ -f /usr/local/etc/freeDiameter/user.cert.pem ]; then if [ -f /usr/local/etc/freeDiameter/hss.cert.pem ]; then
full_hostname=`cat /usr/local/etc/freeDiameter/user.cert.pem | grep "Subject" | grep "CN" | cut -d '=' -f6` 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 = `hostname`.eur ]; then
if [ $full_hostname = hss.eur ]; then
echo_success "S6A: Found valid certificate in /usr/local/etc/freeDiameter" echo_success "S6A: Found valid certificate in /usr/local/etc/freeDiameter"
return 1 return 0
fi fi
fi fi
fi fi
...@@ -263,7 +271,10 @@ check_s6a_certificate() { ...@@ -263,7 +271,10 @@ check_s6a_certificate() {
echo_warning "S6A: generatting new certificate in /usr/local/etc/freeDiameter..." echo_warning "S6A: generatting new certificate in /usr/local/etc/freeDiameter..."
cd $OPENAIRCN_DIR/S6A/freediameter cd $OPENAIRCN_DIR/S6A/freediameter
make_certs make_certs
check_s6a_certificate if [ $cnt = 0 ] ; then
cnt=1
check_s6a_certificate
fi
return 1 return 1
} }
...@@ -350,6 +361,10 @@ check_install_oai_software() { ...@@ -350,6 +361,10 @@ check_install_oai_software() {
check_install_hss_software() { check_install_hss_software() {
if [ ! -f ./.lock_oaibuild ]; then if [ ! -f ./.lock_oaibuild ]; then
$SUDO apt-get update $SUDO apt-get update
if [ $UBUNTU_REL = "12.04" ]; then
test_uninstall_package nettle-dev
test_uninstall_package nettle-bin
fi
test_install_package autoconf test_install_package autoconf
test_install_package automake test_install_package automake
test_install_package bison test_install_package bison
...@@ -372,7 +387,7 @@ check_install_hss_software() { ...@@ -372,7 +387,7 @@ check_install_hss_software() {
test_install_package libsctp1 test_install_package libsctp1
test_install_package libsctp-dev test_install_package libsctp-dev
test_install_package libxml2-dev test_install_package libxml2-dev
test_install_package linux-headers-`uname -r` # test_install_package linux-headers-`uname -r`
test_install_package make test_install_package make
test_install_package mysql-client-core-5.5 test_install_package mysql-client-core-5.5
test_install_package mysql-server-core-5.5 test_install_package mysql-server-core-5.5
...@@ -384,8 +399,8 @@ check_install_hss_software() { ...@@ -384,8 +399,8 @@ check_install_hss_software() {
test_install_package sshfs test_install_package sshfs
test_install_package swig test_install_package swig
test_install_package unzip test_install_package unzip
test_install_package nettle-bin # test_install_package nettle-bin
test_install_package nettle-dev # test_install_package nettle-dev
test_install_package valgrind test_install_package valgrind
if [ $OAI_INSTALLED = 1 ]; then if [ $OAI_INSTALLED = 1 ]; then
...@@ -393,7 +408,7 @@ check_install_hss_software() { ...@@ -393,7 +408,7 @@ check_install_hss_software() {
fi fi
else else
echo_info "skip the package installations" echo_info "All the required packages installed: skip"
fi fi
} }
...@@ -402,6 +417,10 @@ check_install_epc_software() { ...@@ -402,6 +417,10 @@ check_install_epc_software() {
if [ ! -f ./.lock_oaibuild ]; then if [ ! -f ./.lock_oaibuild ]; then
$SUDO apt-get update $SUDO apt-get update
if [ $UBUNTU_REL = "12.04" ]; then
test_uninstall_package nettle-dev
test_uninstall_package nettle-bin
fi
test_install_package autoconf test_install_package autoconf
test_install_package automake test_install_package automake
test_install_package bison test_install_package bison
...@@ -467,7 +486,7 @@ check_install_epc_software() { ...@@ -467,7 +486,7 @@ check_install_epc_software() {
fi fi
else else
echo_info "skip the package installations" echo_info "All the required packages installed: skip"
fi fi
} }
...@@ -501,6 +520,10 @@ check_install_asn1c(){ ...@@ -501,6 +520,10 @@ check_install_asn1c(){
compile_hss() { compile_hss() {
cd $OPENAIRCN_DIR/OPENAIRHSS cd $OPENAIRCN_DIR/OPENAIRHSS
OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*` OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*`
if [ $1 = 1 ]; then
echo_info "build a clean EPC"
bash_exec "rm -rf obj"
fi
if [ ! -n "$OBJ_DIR" ]; then if [ ! -n "$OBJ_DIR" ]; then
OBJ_DIR="objs" OBJ_DIR="objs"
bash_exec "mkdir -m 777 ./$OBJ_DIR" bash_exec "mkdir -m 777 ./$OBJ_DIR"
......
...@@ -415,7 +415,7 @@ build_epc(){ ...@@ -415,7 +415,7 @@ build_epc(){
###################################### ######################################
# CHECK MISC SOFTWARES AND LIBS # # CHECK MISC SOFTWARES AND LIBS #
###################################### ######################################
echo_info "4.check the required packages for HSS" echo_info "4. check the required packages for HSS"
check_install_epc_software check_install_epc_software
...@@ -472,8 +472,9 @@ build_hss(){ ...@@ -472,8 +472,9 @@ build_hss(){
###################################### ######################################
# CHECK MISC SOFTWARES AND LIBS # # CHECK MISC SOFTWARES AND LIBS #
###################################### ######################################
echo_info "4.check the required packages for HSS" echo_info "4. check the required packages for HSS"
hss_certificate_generated=1;
check_install_hss_software check_install_hss_software
if [ $OAI_CLEAN = 1 ]; then if [ $OAI_CLEAN = 1 ]; then
...@@ -483,13 +484,16 @@ build_hss(){ ...@@ -483,13 +484,16 @@ build_hss(){
check_install_freediamter check_install_freediamter
fi fi
fi fi
check_s6a_certificate $(make_certs >> bin/install_log.txt 2>&1)
output=$(check_s6a_certificate >> bin/install_log.txt 2>&1)
hss_certificate_generated=$?
###################################### ######################################
# compile HSS # # compile HSS #
###################################### ######################################
echo_info "5.compile HSS" echo_info "5. compile HSS"
output=$(compile_hss >> bin/install_log.txt 2>&1 ) output=$(compile_hss $OAI_CLEAN >> bin/install_log.txt 2>&1 )
hss_compiled=$? hss_compiled=$?
check_for_hss_executable check_for_hss_executable
echo_info "finished hss target: check the installation log file bin/install_log.txt" echo_info "finished hss target: check the installation log file bin/install_log.txt"
...@@ -497,31 +501,33 @@ build_hss(){ ...@@ -497,31 +501,33 @@ build_hss(){
###################################### ######################################
# fill the HSS DB # fill the HSS DB
###################################### ######################################
echo_info "6.create HSS database (for EURECOM SIM CARDS)" echo_info "6. create HSS database (for EURECOM SIM CARDS)"
hss_db_created=1 hss_db_created=1
output=$(create_hss_database) USER="hssadmin"
PW=""
output=$(create_hss_database $USER $PW )
hss_db_created=$? hss_db_created=$?
if [ $hss_db_created = 0 ]; then
echo_warning "hss DB not created"
fi
###################################### ######################################
# install hss # install hss
###################################### ######################################
echo_info "6. install the binary file" echo_info "7. install the binary file"
if [ $hss_compiled = 0 ]; then if [ $hss_compiled = 0 ]; then
if [ $hss_db_created = 0 ]; then echo_success "target hss built, DB created and installed in the bin directory"
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}
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
else $SUDO cp $OPENAIR_TARGETS/bin/conf/hss_fd.local.conf /etc/openair-hss
echo_warning "hss DB not created"
fi
cp -f $OPENAIRCN_DIR/OPENAIRHSS/conf/hss.conf $OPENAIR_TARGETS/bin
fi fi
###################################### ######################################
# LAUNCH HSS # # LAUNCH HSS #
###################################### ######################################
echo_info "7. run hss" echo_info "8. run hss in bin/: ./openair-hss -c conf/hss.local.conf"
bin/openair-hss -c bin/hss.conf cd bin
./openair-hss -c conf/hss.local.conf
} }
...@@ -530,7 +536,7 @@ build_hss(){ ...@@ -530,7 +536,7 @@ build_hss(){
# set the build # set the build
############################################ ############################################
echo_info "set the top-level build target" echo_info "3. set the top-level build target"
case "$BUILD_LTE" in case "$BUILD_LTE" in
'ENB') 'ENB')
echo_success "build LTE eNB" echo_success "build LTE eNB"
......
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