systems directory scripts for Centos7
[vswitchperf.git] / systems / build_base_machine.sh
1 #!/bin/bash
2 #
3 # Top level scripts to build basic setup for the host
4 #
5
6 # Copyright 2015 OPNFV
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #     http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19
20 #
21 # Contributors:
22 #   Aihua Li, Huawei Technologies.
23 #   Abdul Halim, Intel Corporation.
24 #   Martin Klozik, Intel Corporation.
25
26 ROOT_UID=0
27 SUDO=""
28
29 export VSPERFENV_DIR="$HOME/vsperfenv"
30
31 # function to emit error message before quitting
32 function die() {
33     echo $1
34     exit 1
35 }
36
37 # determine this machine's distro-version
38 # replacing 'lsb_release' tool to detect OS distro name with using systemd distribution release file /etc/os-release
39 # 'lsb_release' is not available by default on Fedora.
40
41 . /etc/os-release
42
43 # check if root
44 if [ "$UID" -ne "$ROOT_UID" ]
45 then
46     # installation must be run via sudo
47     SUDO="sudo -E"
48 fi
49
50 # Get distro name from variables imported; Special case for 'Fedora 22' - we need to get versions as well
51 if [ "$NAME" == 'Fedora' -a $VERSION_ID -gt 21 ]
52 then
53     distro_dir="$NAME$VERSION_ID"
54 else
55     distro_dir=`echo "$NAME" | cut -d ' ' -f1`
56 fi
57
58 # build base system
59 if [ -d "$distro_dir" ] && [ -e $distro_dir/build_base_machine.sh ]; then
60     $SUDO $distro_dir/build_base_machine.sh
61 else
62     die "$distro_dir is not yet supported"
63 fi
64
65 if [ -d "$distro_dir" ] && [ -e $distro_dir/prepare_python_env.sh ] ; then
66     $distro_dir/prepare_python_env.sh
67 else
68     die "$distro_dir is not yet supported"
69 fi
70
71 if [ ! -d /lib/modules/`uname -r`/build ] ; then
72     die "Kernel devel is not available for active kernel. It can be caused by recent kernel update. Please reboot and run $0 again."
73 fi
74
75 # download and compile DPDK, OVS and QEMU
76 if [ -f ../src/Makefile ] ; then
77     cd ../src
78     make
79     cd -
80 fi