From 18c0288730e528ab59603bda3c7162e2aa6dc090 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Sun, 10 May 2020 13:04:32 +0200 Subject: [PATCH] setup.sh: exit from the script if not supported platform is detected Also, store kernel name in the separate var and use it throughout the entire script. Change-Id: Iaa1c4c4aa52fb4aa708fb476478a81e9c6067b58 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2340 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- scripts/setup.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index e1fdcf8bf..c9331ebf9 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -2,11 +2,18 @@ set -e +os=$(uname -s) + +if [[ $os != Linux && $os != FreeBSD ]]; then + echo "Not supported platform ($os), aborting" + exit 1 +fi + rootdir=$(readlink -f $(dirname $0))/.. source "$rootdir/scripts/common.sh" function usage() { - if [ $(uname) = Linux ]; then + if [[ $os == Linux ]]; then options="[config|reset|status|cleanup|help]" else options="[config|reset|help]" @@ -24,13 +31,13 @@ function usage() { echo echo "$options - as following:" echo "config Default mode. Allocate hugepages and bind PCI devices." - if [ $(uname) = Linux ]; then + if [[ $os == Linux ]]; then echo "cleanup Remove any orphaned files that can be left in the system after SPDK application exit" fi echo "reset Rebind PCI devices back to their original drivers." echo " Also cleanup any leftover spdk files/resources." echo " Hugepage memory size will remain unchanged." - if [ $(uname) = Linux ]; then + if [[ $os == Linux ]]; then echo "status Print status of all SPDK-compatible devices on the system." fi echo "help Print this help message." @@ -772,7 +779,7 @@ if [ -z "$TARGET_USER" ]; then fi fi -if [ $(uname) = Linux ]; then +if [[ $os == Linux ]]; then HUGEPGSZ=$(($(grep Hugepagesize /proc/meminfo | cut -d : -f 2 | tr -dc '0-9'))) HUGEPGSZ_MB=$((HUGEPGSZ / 1024)) : ${NRHUGE=$(((HUGEMEM + HUGEPGSZ_MB - 1) / HUGEPGSZ_MB))} @@ -796,9 +803,9 @@ else elif [ "$mode" == "reset" ]; then reset_freebsd elif [ "$mode" == "cleanup" ]; then - echo "setup.sh cleanup function not yet supported on $(uname)" + echo "setup.sh cleanup function not yet supported on $os" elif [ "$mode" == "status" ]; then - echo "setup.sh status function not yet supported on $(uname)" + echo "setup.sh status function not yet supported on $os" elif [ "$mode" == "help" ]; then usage $0 else