Commit 4b5c929c authored by wangyongshou's avatar wangyongshou

modify build, install, run

parent 15bb44b7
...@@ -18,10 +18,18 @@ N4PATH="$base/install/n4" ...@@ -18,10 +18,18 @@ N4PATH="$base/install/n4"
UPFINSTALL="$base/install/upf" UPFINSTALL="$base/install/upf"
UPF_PKG="upf.tar.gz" UPF_PKG="upf.tar.gz"
OS_ID=""
OS_VERSION_ID=""
OS_KERNEL_VERSION=""
OS_ARCH=""
OS_SYS_TYPE=""
function pre_create(){ function pre_create(){
if [ ! -d $VPPINSTALL ] ; then if [ ! -d $VPPINSTALL ] ; then
sudo mkdir -p $VPPINSTALL mkdir -p $VPPINSTALL
fi fi
#if [ ! -d $UPFINSTALL ] ; then #if [ ! -d $UPFINSTALL ] ; then
...@@ -32,36 +40,37 @@ function pre_create(){ ...@@ -32,36 +40,37 @@ function pre_create(){
mkdir -p $UPFINSTALL mkdir -p $UPFINSTALL
if [ ! -d $UPFINSTALL/pkg ] ; then if [ ! -d $UPFINSTALL/pkg ] ; then
sudo mkdir -p $UPFINSTALL/pkg mkdir -p $UPFINSTALL/pkg
fi fi
if [ ! -d $UPFINSTALL/etc ] ; then if [ ! -d $UPFINSTALL/etc ] ; then
sudo mkdir -p $UPFINSTALL/etc mkdir -p $UPFINSTALL/etc
fi fi
if [ ! -d $UPFINSTALL/scripts ] ; then if [ ! -d $UPFINSTALL/scripts ] ; then
sudo mkdir -p $UPFINSTALL/scripts mkdir -p $UPFINSTALL/scripts
fi fi
if [ ! -d $UPFINSTALL/tools ] ; then if [ ! -d $UPFINSTALL/tools ] ; then
sudo mkdir -p $UPFINSTALL/tools mkdir -p $UPFINSTALL/tools
fi fi
} }
function config_file(){ function config_file(){
#scripts #scripts
cp -f $current/dpdk-devbind.py $UPFINSTALL/scripts cp -f $current/dpdk-devbind.py $UPFINSTALL/scripts
cp -f $current/install_upf.sh $UPFINSTALL/scripts cp -f $current/install_upf.sh $UPFINSTALL/scripts
cp -f $current/new_run_upf.sh $UPFINSTALL/scripts cp -f $current/new_run_upf.sh $UPFINSTALL/scripts
#etc #etc
cp -f $configure/template/n4.template $UPFINSTALL/etc cp -f $configure/template/n4.template $UPFINSTALL/etc
#cp -f $configure/template/n4_config.yaml $UPFINSTALL/etc #cp -f $configure/template/n4_config.yaml $UPFINSTALL/etc
cp -f $configure/template/startup_debug.template $UPFINSTALL/etc cp -f $configure/template/startup_debug.template $UPFINSTALL/etc
#cp -f $configure/template/vppe.conf $UPFINSTALL/etc #cp -f $configure/template/vppe.conf $UPFINSTALL/etc
cp -f $configure/upf.conf $UPFINSTALL/etc cp -f $configure/upf.conf $UPFINSTALL/etc
#tools #tools
cp -f /sbin/ethtool $UPFINSTALL/tools cp -f /sbin/ethtool $UPFINSTALL/tools
cp -f $base/plugin/interreput $UPFINSTALL/tools cp -f $base/plugin/interreput $UPFINSTALL/tools
...@@ -74,15 +83,26 @@ function make_pkg(){ ...@@ -74,15 +83,26 @@ function make_pkg(){
cd .. cd ..
} }
function pre_install(){ function pre_install(){
sudo apt-get install sqlite
sudo apt-get install net-tools if [ $OS_SYS_TYPE == "ubuntu" ]; then
sudo apt-get install ethtool
sudo apt-get install make sudo apt-get install sqlite
sudo apt-get install cmake sudo apt-get install net-tools
sudo apt-get install ccache sudo apt-get install ethtool
sudo apt-get install dpkg-buildpackage sudo apt-get install make
cd $base/src/vppe sudo apt-get install cmake
$base/src/vppe/pre_install.sh sudo apt-get install ccache
sudo apt-get install dpkg-buildpackage
cd $base/src/vppe
$base/src/vppe/pre_install.sh
else
echo "pre install don't know system $OS_SYS_TYPE"
exit 0
fi
return 0
} }
function vpp(){ function vpp(){
...@@ -106,8 +126,8 @@ function make_vpp_package() ...@@ -106,8 +126,8 @@ function make_vpp_package()
if [ $1 = "debug" ] if [ $1 = "debug" ]
then then
cd $VPPPATH; cd $VPPPATH;
./pre_install.sh > /dev/null 2>&1; #./pre_install.sh > /dev/null 2>&1;
echo "pre install vppe" #echo "pre install vppe"
make rebuild > /dev/null 2>&1; make rebuild > /dev/null 2>&1;
echo "build vppe" echo "build vppe"
make pkg-deb-debug > /dev/null 2>&1; make pkg-deb-debug > /dev/null 2>&1;
...@@ -116,7 +136,7 @@ function make_vpp_package() ...@@ -116,7 +136,7 @@ function make_vpp_package()
elif [ $1 = "release" ] elif [ $1 = "release" ]
then then
cd $VPPPATH; cd $VPPPATH;
./pre_install.sh > /dev/null 2>&1; #./pre_install.sh > /dev/null 2>&1;
make rebuild-release > /dev/null 2>&1; make rebuild-release > /dev/null 2>&1;
make pkg-deb > /dev/null 2>&1; make pkg-deb > /dev/null 2>&1;
cd .. cd ..
...@@ -213,6 +233,45 @@ function clear_all() ...@@ -213,6 +233,45 @@ function clear_all()
rm -rf $VPPPATH/build/external/downloads/* rm -rf $VPPPATH/build/external/downloads/*
} }
function check_system()
{
echo "check_system..."
if [ ! -f /etc/os-release ] ; then
echo "ERROR /etc/os-release is not exist....."
exit 0
fi
OS_ID=$(echo `grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g'`)
OS_VERSION_ID=$(echo `grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g'`)
OS_KERNEL_VERSION=$(echo `uname -r`)
OS_ARCH=$(echo `uname --m`)
#ubuntu
if [ $OS_ID == "ubuntu" -a $OS_VERSION_ID == "18.04" -a $OS_KERNEL_VERSION == "5.4.0-80-generic" -a $OS_ARCH == "x86_64" ]; then
echo $OS_ID
echo $OS_VERSION_ID
echo $OS_KERNEL_VERSION
echo $OS_ARCH
OS_SYS_TYPE="ubuntu"
else
echo "don't know system"
echo $OS_ID
echo $OS_VERSION_ID
echo $OS_KERNEL_VERSION
echo $OS_ARCH
echo "build exit..."
exit 0
fi
return 0
}
function help() function help()
{ {
echo " " echo " "
...@@ -233,6 +292,8 @@ function main() { ...@@ -233,6 +292,8 @@ function main() {
help help
exit exit
fi fi
check_system
until [ -z "$1" ]; do until [ -z "$1" ]; do
case "$1" in case "$1" in
...@@ -252,6 +313,7 @@ function main() { ...@@ -252,6 +313,7 @@ function main() {
shift shift
;; ;;
--upf-dp) --upf-dp)
pre_install
pre_create pre_create
config_file config_file
make_n4_package make_n4_package
......
...@@ -10,25 +10,36 @@ ...@@ -10,25 +10,36 @@
current="$PWD" current="$PWD"
base=$(dirname "$PWD") base=$(dirname "$PWD")
ROOT_PATH=/opt/5gc/test ROOT_PATH=/opt/5gc/upf
VPP_PRO="vpp" VPP_PRO="vpp"
N4_PRO="main" N4_PRO="main"
OS_ID=""
OS_VERSION_ID=""
OS_KERNEL_VERSION=""
OS_ARCH=""
OS_SYS_TYPE=""
OS_CPU_NUM=0
OS_FREE=0
function pre_install() function pre_install()
{ {
if [ ! -d $ROOT_PATH ] ; then if [ ! -d $ROOT_PATH ] ; then
sudo mkdir -p $ROOT_PATH mkdir -p $ROOT_PATH
fi fi
if [ ! -d $ROOT_PATH/bin ] ; then if [ ! -d $ROOT_PATH/bin ] ; then
sudo mkdir -p $ROOT_PATH/bin mkdir -p $ROOT_PATH/bin
fi fi
cp -rf $base/scripts $ROOT_PATH cp -rf $base/scripts $ROOT_PATH
cp -rf $base/etc $ROOT_PATH cp -rf $base/etc $ROOT_PATH
cp -rf $base/tools $ROOT_PATH cp -rf $base/tools $ROOT_PATH
#cp -rf $base/tools/ethtool /sbin/
#cp -rf $base/tools/ethtool /sbin/
} }
function install_bupt_n4() function install_bupt_n4()
...@@ -50,18 +61,18 @@ function install_bupt_vppe () ...@@ -50,18 +61,18 @@ function install_bupt_vppe ()
#delete vppe process #delete vppe process
#unpack #unpack
sudo tar -zxvf $base/pkg/bupt_vppe.tar.gz -C $base/pkg > /dev/null 2>&1; tar -zxvf $base/pkg/bupt_vppe.tar.gz -C $base/pkg > /dev/null 2>&1;
sleep 1; sleep 1;
#install #install
echo "install bupt_vppe start..." echo "install bupt_vppe start..."
sudo dpkg -i $base/pkg/vppe_install/*.deb > /dev/null 2>&1; dpkg -i $base/pkg/vppe_install/*.deb > /dev/null 2>&1;
sudo systemctl stop vpp > /dev/null 2>&1 ; systemctl stop vpp > /dev/null 2>&1 ;
sudo systemctl disable vpp > /dev/null 2>&1 ; systemctl disable vpp > /dev/null 2>&1 ;
#rm install package #rm install package
sudo rm -rf $base/pkg/vppe_install; rm -rf $base/pkg/vppe_install;
sudo rm -rf $base/pkg/bupt_vppe.tar.gz; rm -rf $base/pkg/bupt_vppe.tar.gz;
cp -f /usr/bin/vpp /$ROOT_PATH/bin; cp -f /usr/bin/vpp /$ROOT_PATH/bin;
...@@ -90,6 +101,80 @@ function close_upf() ...@@ -90,6 +101,80 @@ function close_upf()
fi fi
} }
function system_requirement()
{
echo "Minimum system requirements"
echo ""
echo "ubuntu"
echo "18.04"
echo "5.4.0-80-generic"
echo "x86_64"
echo "cpu num: 16"
echo "free total mem: 14G"
echo ""
echo ""
return 0
}
function check_system()
{
echo "check system config "
echo ""
if [ ! -f /etc/os-release ] ; then
echo "ERROR /etc/os-release is not exist....."
exit 0
fi
OS_ID=$(echo `grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g'`)
OS_VERSION_ID=$(echo `grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g'`)
OS_KERNEL_VERSION=$(echo `uname -r`)
OS_ARCH=$(echo `uname --m`)
OS_CPU_NUM_T=$(echo `cat /proc/cpuinfo| grep "processor"| wc -l`)
OS_FREE_T=$(echo `awk '($1 == "MemTotal:"){print $2/1048576}' /proc/meminfo`)
OS_CPU_NUM=$(echo `echo $OS_CPU_NUM_T| awk '{print int($0)}'`)
OS_FREE=$(echo `echo $OS_FREE_T| awk '{print int($0)}'`)
#ubuntu
if [ $OS_ID == "ubuntu" -a $OS_VERSION_ID == "18.04" -a $OS_KERNEL_VERSION == "5.4.0-80-generic" -a $OS_ARCH == "x86_64" -a $OS_CPU_NUM -ge 16 -a $OS_FREE -ge 14 ]; then
echo $OS_ID
echo $OS_VERSION_ID
echo $OS_KERNEL_VERSION
echo $OS_ARCH
echo "cpu num: $OS_CPU_NUM"
echo "free mem: $OS_FREE"
OS_SYS_TYPE="ubuntu"
else
echo $OS_ID
echo $OS_VERSION_ID
echo $OS_KERNEL_VERSION
echo $OS_ARCH
echo $OS_CPU_NUM
echo $OS_FREE
echo "don't support system config"
echo ""
system_requirement
echo " exit..."
exit 0
fi
return 0
}
function help() function help()
{ {
...@@ -107,6 +192,10 @@ function main() { ...@@ -107,6 +192,10 @@ function main() {
exit exit
fi fi
#check system
check_system
until [ -z "$1" ]; do until [ -z "$1" ]; do
case "$1" in case "$1" in
--upf) --upf)
......
...@@ -129,12 +129,12 @@ function check_system() ...@@ -129,12 +129,12 @@ function check_system()
} }
function install_driver() function install_driver()
{ {
sudo modprobe vfio-pci; modprobe vfio-pci;
insmod_result=$? insmod_result=$?
exec_result $insmod_result exec_result $insmod_result
echo Y | sudo tee /sys/module/vfio/parameters/enable_unsafe_noiommu_mode echo Y | tee /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
#$base/tools/interreput -i $CPUNUMBER #$base/tools/interreput -i $CPUNUMBER
set_cpu_interrupt set_cpu_interrupt
...@@ -433,6 +433,40 @@ function read_config() { ...@@ -433,6 +433,40 @@ function read_config() {
echo "UPF_N4_LOGSIZE:$UPF_N4_LOGSIZE" echo "UPF_N4_LOGSIZE:$UPF_N4_LOGSIZE"
} }
function chk_net()
{
echo "check net ..."
echo ""
ping_gnb_n3=$(echo `/usr/bin/vppctl -s /run/vpp/cli.sock ping $UPF_N3_GW source if_n3 repeat 5`)
loss="*100% packet loss*"
if [[ ${ping_gnb_n3} == ${loss} ]] ; then
echo "n3 ping: $UPF_N6_IP ping $UPF_N3_GW"
echo ${ping_gnb_n3}
exit 0
fi
echo "n3 ping succ: $UPF_N6_IP ping $UPF_N3_GW"
echo ${ping_gnb_n3}
ping_dn_n6=$(echo `/usr/bin/vppctl -s /run/vpp/cli.sock ping $UPF_N6_GW source if_n6 repeat 5`)
if [[ ${ping_dn_n6} == ${loss} ]]; then
echo "warning: n6 ping: $UPF_N6_IP ping $UPF_N6_GW"
fi
echo "n6 ping: $UPF_N6_IP ping $UPF_N6_GW"
echo ${ping_dn_n6}
echo ""
return 0
}
function config_upf() function config_upf()
{ {
install_driver install_driver
...@@ -483,6 +517,7 @@ function main() ...@@ -483,6 +517,7 @@ function main()
config_upf config_upf
start_vppe start_vppe
sleep 20s sleep 20s
chk_net
start_n4 start_n4
shift shift
;; ;;
......
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