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