<commit_before>#!/bin/bash
#
# You can install the Buildbox Agent with the following:
#
#   bash -c "`curl -sL https://raw.github.com/buildboxhq/buildbox-agent/master/install.sh`"
#
# For more information, see: https://github.com/buildboxhq/buildbox-agent

COMMAND="bash -c \"\`curl -sL https://raw.github.com/buildboxhq/buildbox-agent/master/install.sh\`\""

set -e

echo -e "\033[33m
  _           _ _     _ _                                        _
 | |         (_) |   | | |                                      | |
 | |__  _   _ _| | __| | |__   _____  __   __ _  __ _  ___ _ __ | |_
 | '_ \| | | | | |/ _\` | '_ \ / _ \ \/ /  / _\` |/ _\` |/ _ \ '_ \| __|
 | |_) | |_| | | | (_| | |_) | (_) >  <  | (_| | (_| |  __/ | | | |_
 |_.__/ \__,_|_|_|\__,_|_.__/ \___/_/\_\  \__,_|\__, |\___|_| |_|\__|
                                                 __/ |
                                                |___/\033[0m
-- https://buildbox.io

Latest Version: \033[35mv0.1-alpha\033[0m"

UNAME=`uname -sp | awk '{print tolower($0)}'`

if [[ ($UNAME == *"mac os x"*) || ($UNAME == *darwin*) ]]
then
  PLATFORM="darwin"
else
  PLATFORM="linux"
fi

if [[ ($UNAME == *x86_64*) || ($UNAME == *amd64*) ]]
then
  ARCH="amd64"
else
  ARCH="386"
fi

# Allow custom setting of the destination
if [ -z "$DESTINATION" ]; then
  # But default to the home directory
  DESTINATION="$HOME/.buildbox"
  mkdir -p $DESTINATION
fi

if [ ! -w "$DESTINATION" ]
then
  echo -e "\n\033[31mUnable to write to destination \`$DESTINATION\`\n\nYou can change the destination by running:\n\nDESTINATION=/my/path $COMMAND\033[0m\n"
  exit 1
fi

echo -e "Destination: \033[35m$DESTINATION\033[0m"

# Download and unzip the file to the destination
FILE=$DESTINATION/buildbox-agent
URL="https://github.com/buildboxhq/buildbox-agent/releases/download/v0.1-alpha/buildbox-agent-$PLATFORM-$ARCH.gz"
echo -e "\nDownloading $URL"

if command -v wget >/dev/null
then
  wget -qO- $URL | zcat > $FILE
else
  curl -sL $URL | zcat > $FILE
fi

# Make sure it's exectuable
chmod +x $FILE

# Copy the bootstrap sample and make sure it's writable
if [[ -e $DESTINATION/bootstrap.sh ]]
then
  echo -e "\n\033[34mSkipping bootstrap.sh installation as it already exists\033[0m"
else
  BOOTSTRAP_URL=https://raw.github.com/buildboxhq/buildbox-agent/master/templates/bootstrap.sh
  BOOTSTRAP_DESTINATION=$DESTINATION/bootstrap.sh

  echo -e "Downloading $BOOTSTRAP_URL"

  if command -v wget >/dev/null
  then
    wget -q $BOOTSTRAP_URL -O $BOOTSTRAP_DESTINATION
  else
    curl -s -o $BOOTSTRAP_DESTINATION $BOOTSTRAP_URL
  fi

  chmod +x $DESTINATION/bootstrap.sh
fi

echo -e "\n\033[32mSuccessfully installed to: $FILE\033[0m

You can now start the agent like so:

  $DESTINATION/buildbox-agent start --access-token token<PASSWORD>

You can find your agent's Access Token on your Account Settings
page under \"Agents\".

To customize how builds are run on your server, you can edit:

  $DESTINATION/bootstrap.sh

This file is run for every build and it's responsible for checking out
the source code and running the build script.

The source code of the agent is available here:<commit_msg>Updated the installer to support extracting multiple files.<commit_after>#!/bin/bash
#
# You can install the Buildbox Agent with the following:
#
#   bash -c "`curl -sL https://raw.github.com/buildboxhq/buildbox-agent/master/install.sh`"
#
# For more information, see: https://github.com/buildboxhq/buildbox-agent

COMMAND="bash -c \"\`curl -sL https://raw.github.com/buildboxhq/buildbox-agent/master/install.sh\`\""

set -e

echo -e "\033[33m
  _           _ _     _ _                                        _
 | |         (_) |   | | |                                      | |
 | |__  _   _ _| | __| | |__   _____  __   __ _  __ _  ___ _ __ | |_
 | '_ \| | | | | |/ _\` | '_ \ / _ \ \/ /  / _\` |/ _\` |/ _ \ '_ \| __|
 | |_) | |_| | | | (_| | |_) | (_) >  <  | (_| | (_| |  __/ | | | |_
 |_.__/ \__,_|_|_|\__,_|_.__/ \___/_/\_\  \__,_|\__, |\___|_| |_|\__|
                                                 __/ |
                                                |___/\033[0m
-- https://buildbox.io

Latest Version: \033[35mv0.1-alpha\033[0m"

UNAME=`uname -sp | awk '{print tolower($0)}'`

if [[ ($UNAME == *"mac os x"*) || ($UNAME == *darwin*) ]]
then
  PLATFORM="darwin"
else
  PLATFORM="linux"
fi

if [[ ($UNAME == *x86_64*) || ($UNAME == *amd64*) ]]
then
  ARCH="amd64"
else
  ARCH="386"
fi

# Allow custom setting of the destination
if [ -z "$DESTINATION" ]; then
  # But default to the home directory
  DESTINATION="$HOME/.buildbox"
  mkdir -p $DESTINATION
fi

if [ ! -w "$DESTINATION" ]
then
  echo -e "\n\033[31mUnable to write to destination \`$DESTINATION\`\n\nYou can change the destination by running:\n\nDESTINATION=/my/path $COMMAND\033[0m\n"
  exit 1
fi

echo -e "Destination: \033[35m$DESTINATION\033[0m"

# Download and unzip the file to the destination
DOWNLOAD="buildbox-agent-$PLATFORM-$ARCH.tar.gz"
URL="https://github.com/buildboxhq/buildbox-agent/releases/download/v0.1-alpha/$DOWNLOAD"
echo -e "\nDownloading $URL"

# Remove the download if it already exists
rm -f $DESTINATION/$DOWNLOAD

if command -v wget >/dev/null
then
  wget -q $URL -O $DESTINATION/$DOWNLOAD
else
  curl -L -s -o $DESTINATION/$DOWNLOAD $URL
fi

tar -C $DESTINATION -zxvf $DESTINATION/$DOWNLOAD

# Make sure it's exectuable
chmod +x $DESTINATION/buildbox-agent
chmod +x $DESTINATION/buildbox-artifact

# Clean up the download
rm -f $DESTINATION/$DOWNLOAD

# Copy the bootstrap sample and make sure it's writable
if [[ -e $DESTINATION/bootstrap.sh ]]
then
  echo -e "\n\033[34mSkipping bootstrap.sh installation as it already exists\033[0m"
else
  BOOTSTRAP_URL=https://raw.github.com/buildboxhq/buildbox-agent/master/templates/bootstrap.sh
  BOOTSTRAP_DESTINATION=$DESTINATION/bootstrap.sh

  echo -e "Downloading $BOOTSTRAP_URL"

  if command -v wget >/dev/null
  then
    wget -q $BOOTSTRAP_URL -O $BOOTSTRAP_DESTINATION
  else
    curl -L -s -o $BOOTSTRAP_DESTINATION $BOOTSTRAP_URL
  fi

  chmod +x $DESTINATION/bootstrap.sh
fi

echo -e "\n\033[32mSuccessfully installed to: $FILE\033[0m

You can now start the agent like so:

  $DESTINATION/buildbox-agent start --access-token token<PASSWORD>

You can find your agent's Access Token on your Account Settings
page under \"Agents\".

To customize how builds are run on your server, you can edit:

  $DESTINATION/bootstrap.sh

This file is run for every build and it's responsible for checking out
the source code and running the build script.

The source code of the agent is available here:
{'fraction_non_alphanumeric': 0.14544072948328268, 'fraction_numerical': 0.021580547112462007, 'mean_word_length': 2.6480044345898004, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2579137', 'n_tokens_mistral': 2523, 'n_tokens_neox': 2393, 'n_words': 581}