1#!/usr/bin/env bash 2 3if [ ! "$USER" = "root" ]; then 4 echo 5 echo Error: must be run as root! 6 echo 7 exit 1 8fi 9 10set -e 11 12DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13SPDK_DIR="$( cd "${DIR}/../../" && pwd )" 14echo "SPDK_DIR = $SPDK_DIR" 15 16# Bug fix for vagrant rsync problem 17if [ -d /home/vagrant/spdk_repo ]; then 18 echo "Fixing permissions on /home/vagrant/spdk_repo" 19 chown vagrant /home/vagrant/spdk_repo 20 chgrp vagrant /home/vagrant/spdk_repo 21fi 22 23# Setup for run-autorun.sh 24if [ ! -f /home/vagrant/autorun-spdk.conf ]; then 25 echo "Copying scripts/vagrant/autorun-spdk.conf to /home/vagrant" 26 cp ${SPDK_DIR}/scripts/vagrant/autorun-spdk.conf /home/vagrant 27 chown vagrant /home/vagrant/autorun-spdk.conf 28 chgrp vagrant /home/vagrant/autorun-spdk.conf 29fi 30 31SYSTEM=$(uname -s) 32 33if [ "$SYSTEM" = "FreeBSD" ]; then 34 # Do initial setup for the system 35 pkg upgrade -f 36 ${SPDK_DIR}/scripts/pkgdep.sh 37 if [ -d /usr/src/.git ]; then 38 echo 39 echo "/usr/src/ is a git repository" 40 echo "consider \"cd /usr/src/; git pull\" to update" 41 echo 42 else 43 git clone --depth 10 -b release/11.1.0 https://github.com/freebsd/freebsd.git /usr/src 44 fi 45else 46 47 # Make sure that we get the hugepages we need on provision boot 48 # Note: The package install should take care of this at the end 49 # But sometimes after all the work of provisioning, we can't 50 # get the requested number of hugepages without rebooting. 51 # So do it here just in case 52 sysctl -w vm.nr_hugepages=1024 53 HUGEPAGES=$(sysctl -n vm.nr_hugepages) 54 if [ $HUGEPAGES != 1024 ]; then 55 echo "Warning: Unable to get 1024 hugepages, only got $HUGEPAGES" 56 echo "Warning: Adjusting HUGEMEM in /home/vagrant/autorun-spdk.conf" 57 sed "s/HUGEMEM=.*$/HUGEMEM=${HUGEPAGES}/g" /home/vagrant/autorun-spdk.conf > /home/vagrant/foo.conf 58 mv -f /home/vagrant/foo.conf /home/vagrant/autorun-spdk.conf 59 fi 60 61 # Figure out what system we are running on 62 if [ -f /etc/lsb-release ];then 63 . /etc/lsb-release 64 elif [ -f /etc/redhat-release ];then 65 yum update -y 66 yum install -y redhat-lsb 67 DISTRIB_ID=$(lsb_release -si) 68 DISTRIB_RELEASE=$(lsb_release -sr) 69 DISTRIB_CODENAME=$(lsb_release -sc) 70 DISTRIB_DESCRIPTION=$(lsb_release -sd) 71 fi 72 73 # Do initial setup for the system 74 if [ "$DISTRIB_ID" == "Ubuntu" ]; then 75 set -xv 76 export DEBIAN_PRIORITY=critical 77 export DEBIAN_FRONTEND=noninteractive 78 export DEBCONF_NONINTERACTIVE_SEEN=true 79 # Standard update + upgrade dance 80 apt-get update --assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" 81 apt-get upgrade --assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" 82 ${SPDK_DIR}/scripts/pkgdep.sh 83 elif [ "$DISTRIB_ID" == "CentOS" ]; then 84 # Standard update + upgrade dance 85 yum check-update 86 yum update -y 87 ${SPDK_DIR}/scripts/pkgdep.sh 88 elif [ "$DISTRIB_ID" == "Fedora" ]; then 89 if [ "$DISTRIB_RELEASE" = "26" ]; then 90 echo 91 echo " Run \"${SPDK_DIR}/test/common/config/vm_setup.sh\" to complete setup of Fedora 26" 92 echo 93 else 94 yum check-update 95 yum update -y 96 ${SPDK_DIR}/scripts/pkgdep.sh 97 fi 98 fi 99fi 100