28d4ecb69daf7d57ef2475a85ab8fa3c7c0c273b
[csit.git] / resources / tools / t-rex-installer.sh
1 #!/bin/sh
2
3 TREX_DOWNLOAD_REPO="https://github.com/cisco-system-traffic-generator/trex-core/archive/"
4 TREX_DOWNLOAD_PACKAGE="v1.88.zip"
5 TREX_PACKAGE_URL="${TREX_DOWNLOAD_REPO}${TREX_DOWNLOAD_PACKAGE}"
6 TARGET_DIR="/opt/"
7 TREX_DIR="trex-core-1.88/"
8 TREX_INSTALL_DIR="${TARGET_DIR}${TREX_DIR}"
9
10 if test "$(id -u)" -ne 0
11 then
12     echo "Please use root or sudo to be able to access target installation directory: ${TARGET_DIR}"
13     exit 1
14 fi
15
16 WORKING_DIR=$(mktemp -d)
17 test $? -eq 0 || exit 1
18
19 cleanup () {
20     rm -r ${WORKING_DIR}
21 }
22
23 trap cleanup EXIT
24
25 test -d ${TREX_INSTALL_DIR} && echo "T-REX aleready installed: ${TREX_INSTALL_DIR}" && exit 1
26
27 wget -P ${WORKING_DIR} ${TREX_PACKAGE_URL}
28 test $? -eq 0 || exit 1
29
30 unzip ${WORKING_DIR}/${TREX_DOWNLOAD_PACKAGE} -d ${TARGET_DIR}
31 test $? -eq 0 || exit 1
32
33 cd ${TREX_INSTALL_DIR}/linux_dpdk/ && ./b configure && ./b build || exit 1
34 cd ${TREX_INSTALL_DIR}/scripts/ko/src && make || exit 1
35