<commit_before>#!/bin/bash
set -eu
# s2aio install from scratch an all in one swift with the storlet engine.
# s2aio has two flavors:
# 1. Jenkins job installation, for running the funciotal tests.
# 2. Developer instalation.

if [ "$#" -ne 2 ]; then
    echo "Usage: s2aio.sh <flavor> <target>"
    echo "flavor = jenkins | dev"
    echo "target = host | docker"
    exit 1
fi

FLAVOR="$1"
if [ "$FLAVOR" != "jenkins" ] && [ "$FLAVOR" != "dev" ]; then
    echo "flavor must be either \"jenkins\" or \"dev\""
    exit 1
fi

TARGET="$2"
if [ "$TARGET" != "host" ] && [ "$TARGET" != "docker" ]; then
    echo "target must be either \"host\" or \"docker\""
    exit 1
fi

# Make sure hostname is resolvable
grep -q -F ${HOSTNAME} /etc/hosts || sudo sed -i '1i127.0.0.1\t'"$HOSTNAME"'' /etc/hosts

install/install_ansible.sh

# Allow Ansible to ssh as the current user without a password
# While at it, take care of host key verification.
# This involves:
# 1. Generate an rsa key for the current user if necessary
if [ ! -f ~/.ssh/id_rsa.pub ]; then
    ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ""
fi

if [ "$TARGET" == "docker" ]; then
    # install docker
    sudo apt-get install apt-transport-https aufs-tools=1:3.2+20130722-1.1 linux-image-extra-`uname -r` -y --force-yes
    sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys <KEY>
    sudo sh -c "echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list"
    sudo apt-get update
    sudo apt-get install docker-engine -y --force-yes
    sudo sh -c "echo DOCKER_OPTS=\"--storage-driver=vfs\" >> /etc/default/docker"
    sudo service docker restart

    # run the swift docker container
    S2AIO_RUNNING=`sudo docker ps | grep s2aio | wc -l`
    S2AIO_EXISTS=`sudo docker ps -a | grep s2aio | wc -l`
    if [ "$S2AIO_RUNNING" == "0" ]; then
        if [ "$S2AIO_EXISTS" == "1" ]; then
             sudo docker rm s2aio
        fi
        sudo docker run -i -d --privileged=true --name s2aio -t ubuntu:14.04
    fi
    export S2AIO_IP=`sudo docker exec s2aio ifconfig | grep "inet addr" | head -1 | awk '{print $2}' | awk -F":" '{print $2}'`

    sudo docker exec s2aio sh -c "echo deb http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse >> /etc/apt/sources.list"
    sudo docker exec s2aio apt-get update
    sudo docker exec s2aio apt-get install software-properties-common -y --force-yes
    sudo docker exec s2aio apt-add-repository -y ppa:ansible/ansible<commit_msg>Fix s2aio.sh to address trusty -> xenial<commit_after>#!/bin/bash
set -eu
# s2aio install from scratch an all in one swift with the storlet engine.
# s2aio has two flavors:
# 1. Jenkins job installation, for running the funciotal tests.
# 2. Developer instalation.

if [ "$#" -ne 2 ]; then
    echo "Usage: s2aio.sh <flavor> <target>"
    echo "flavor = jenkins | dev"
    echo "target = host | docker"
    exit 1
fi

FLAVOR="$1"
if [ "$FLAVOR" != "jenkins" ] && [ "$FLAVOR" != "dev" ]; then
    echo "flavor must be either \"jenkins\" or \"dev\""
    exit 1
fi

TARGET="$2"
if [ "$TARGET" != "host" ] && [ "$TARGET" != "docker" ]; then
    echo "target must be either \"host\" or \"docker\""
    exit 1
fi

# Make sure hostname is resolvable
grep -q -F ${HOSTNAME} /etc/hosts || sudo sed -i '1i127.0.0.1\t'"$HOSTNAME"'' /etc/hosts

install/install_ansible.sh

# Allow Ansible to ssh as the current user without a password
# While at it, take care of host key verification.
# This involves:
# 1. Generate an rsa key for the current user if necessary
if [ ! -f ~/.ssh/id_rsa.pub ]; then
    ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ""
fi

if [ "$TARGET" == "docker" ]; then
    # install docker
    sudo apt-get install apt-transport-https aufs-tools linux-image-extra-`uname -r` -y --force-yes
    sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys <KEY>
    sudo sh -c "echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list"
    sudo apt-get update
    sudo apt-get install docker-engine -y --force-yes
    sudo sh -c "echo DOCKER_OPTS=\"--storage-driver=vfs\" >> /etc/default/docker"
    sudo service docker restart

    # run the swift docker container
    S2AIO_RUNNING=`sudo docker ps | grep s2aio | wc -l`
    S2AIO_EXISTS=`sudo docker ps -a | grep s2aio | wc -l`
    if [ "$S2AIO_RUNNING" == "0" ]; then
        if [ "$S2AIO_EXISTS" == "1" ]; then
             sudo docker rm s2aio
        fi
        sudo docker run -i -d --privileged=true --name s2aio -t ubuntu:14.04
    fi
    export S2AIO_IP=`sudo docker exec s2aio ifconfig | grep "inet addr" | head -1 | awk '{print $2}' | awk -F":" '{print $2}'`

    sudo docker exec s2aio sh -c "echo deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse >> /etc/apt/sources.list"
    sudo docker exec s2aio apt-get update
    sudo docker exec s2aio apt-get install software-properties-common -y --force-yes
    sudo docker exec s2aio apt-add-repository -y ppa:ansible/ansible
{'fraction_non_alphanumeric': 0.13978706624605677, 'fraction_numerical': 0.02089905362776025, 'mean_word_length': 2.8903374233128836, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 20, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7597954', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1790, 'n_words': 600}