update.sh revision bee3dc86
1#!/bin/bash
2# Copyright (c) 2016 Cisco and/or its affiliates.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at:
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Make sure that we get the hugepages we need on provision boot
16# Note: The package install should take care of this at the end
17#       But sometimes after all the work of provisioning, we can't
18#       get the requested number of hugepages without rebooting.
19#       So do it here just in case
20sysctl -w vm.nr_hugepages=1024
21HUGEPAGES=`sysctl -n  vm.nr_hugepages`
22if [ $HUGEPAGES != 1024 ]; then
23    echo "ERROR: Unable to get 1024 hugepages, only got $HUGEPAGES.  Cannot finish."
24    exit
25fi
26
27exit 0
28
29# Figure out what system we are running on
30if [ -f /etc/lsb-release ];then
31    . /etc/lsb-release
32elif [ -f /etc/redhat-release ];then
33    yum install -y redhat-lsb
34    DISTRIB_ID=`lsb_release -si`
35    DISTRIB_RELEASE=`lsb_release -sr`
36    DISTRIB_CODENAME=`lsb_release -sc`
37    DISTRIB_DESCRIPTION=`lsb_release -sd`
38fi
39
40# Do initial setup for the system
41if [ $DISTRIB_ID == "Ubuntu" ]; then
42    # Fix grub-pc on Virtualbox with Ubuntu
43    export DEBIAN_FRONTEND=noninteractive
44
45    # Standard update + upgrade dance
46    apt-get update
47    apt-get upgrade -y
48
49    # Fix the silly notion that /bin/sh should point to dash by pointing it to bash
50
51    update-alternatives --install /bin/sh sh /bin/bash 100
52
53    # Install useful but non-mandatory tools
54    apt-get install -y emacs  git-review gdb gdbserver brctl
55elif [ $DISTRIB_ID == "CentOS" ]; then
56    # Standard update + upgrade dance
57    yum check-update
58    yum update -y
59fi
60