Skip to content

Instantly share code, notes, and snippets.

@flyotlin
Last active November 21, 2022 11:20
Show Gist options
  • Save flyotlin/04e92e87ad06d6f5731c7d7905135ad5 to your computer and use it in GitHub Desktop.
Save flyotlin/04e92e87ad06d6f5731c7d7905135ad5 to your computer and use it in GitHub Desktop.

Revisions

  1. flyotlin revised this gist Nov 21, 2022. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions env_setup.sh
    Original file line number Diff line number Diff line change
    @@ -59,12 +59,13 @@ if [ -z "$(which mn)" ]; then
    fi

    # Install OvS 2.11.4
    ovs_version=2.15.4
    if [ -z "$(which ovs-vsctl)" ]; then
    cd ~
    sudo apt install gcc make
    wget https://www.openvswitch.org/releases/openvswitch-2.11.4.tar.gz
    tar zxf openvswitch-2.11.4.tar.gz
    cd openvswitch-2.11.4
    wget https://www.openvswitch.org/releases/openvswitch-${ovs_version}.tar.gz
    tar zxf openvswitch-${ovs_version}.tar.gz
    cd openvswitch-${ovs_version}
    ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
    make
    sudo make install
  2. flyotlin revised this gist Nov 21, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion env_setup.sh
    Original file line number Diff line number Diff line change
    @@ -54,7 +54,7 @@ fi
    if [ -z "$(which mn)" ]; then
    cd ~
    echo -e "${YELLOW}[*] Begin to install mininet...${NC}"
    git clone git://github.com/mininet/mininet
    git clone https://github.com/mininet/mininet
    mininet/util/install.sh -n
    fi

  3. flyotlin created this gist Nov 21, 2022.
    78 changes: 78 additions & 0 deletions env_setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    #!/bin/bash

    YELLOW='\033[1;33m'
    NC='\033[0m'

    BAZEL=0.27.0

    set -e
    cd ~
    sudo apt update -y

    # Install Bazel 0.27.0
    if [ ! -f ~/bin/bazel ]; then
    echo -e "${YELLOW}[*] Begin to install Bazel...${NC}"
    sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python3 -y
    wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL}/bazel-${BAZEL}-installer-linux-x86_64.sh
    chmod +x bazel-${BAZEL}-installer-linux-x86_64.sh
    ./bazel-${BAZEL}-installer-linux-x86_64.sh --user
    export PATH="$PATH:$HOME/bin"
    echo 'export PATH="$PATH:$HOME/bin"' >> ~/.bashrc
    fi

    # Install ONOS 2.2.0
    if [ -z "$ONOS_ROOT" ]; then
    echo -e "${YELLOW}[*] Begin to install ONOS...${NC}"
    if [ ! -d ~/onos ]; then
    sudo apt-get install git curl python bzip2 -y
    git clone https://github.com/opennetworkinglab/onos.git
    fi
    cd onos
    git checkout 2.2.0
    # replace http://repo1.maven.org/ to https://repo1.maven.org/ (if exists)
    grep -lr http://repo1.maven.org/ . | xargs -r sed -i 's/http:\/\/repo1\.maven\.org/https:\/\/repo1\.maven\.org/g'

    # if command exits with non-zero status, then not exit immediately
    set +e
    bazel build onos
    # if error occurs when building onos, then maybe some package repository urls are wrong
    if [ "$?" -ne 0 ]; then
    set -e
    find ~/.cache -path "*/external/io_grpc_grpc_java/repositories.bzl" | xargs -r sed -i 's/http:\/\/central\.maven\.org/https:\/\/repo1\.maven\.org/g'
    # fix: protobuf dependency missing
    find ~/.cache -path "*/external/com_google_protobuf/protobuf_deps.bzl" | xargs -r sed -i '12c\ sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff",'
    find ~/.cache -path "*/external/com_google_protobuf/protobuf_deps.bzl" | xargs -r sed -i '14c\ urls = ["https://github.com/madler/zlib/archive/v1.2.11.tar.gz"],'
    bazel build onos
    fi
    set -e
    export ONOS_ROOT=~/onos
    echo 'export ONOS_ROOT=~/onos' >> ~/.bashrc
    echo 'source $ONOS_ROOT/tools/dev/bash_profile' >> ~/.bashrc
    fi

    # Install mininet
    if [ -z "$(which mn)" ]; then
    cd ~
    echo -e "${YELLOW}[*] Begin to install mininet...${NC}"
    git clone git://github.com/mininet/mininet
    mininet/util/install.sh -n
    fi

    # Install OvS 2.11.4
    if [ -z "$(which ovs-vsctl)" ]; then
    cd ~
    sudo apt install gcc make
    wget https://www.openvswitch.org/releases/openvswitch-2.11.4.tar.gz
    tar zxf openvswitch-2.11.4.tar.gz
    cd openvswitch-2.11.4
    ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
    make
    sudo make install
    # sudo make uninstall
    sudo /usr/share/openvswitch/scripts/ovs-ctl start
    fi

    sudo sed -i "/exit 0$/i /usr/share/openvswitch/scripts/ovs-ctl start" /etc/rc.local

    # Finish
    echo -e "${YELLOW}*** Installation Finished! ***${NC}"