<commit_before>#!/bin/bash

mkdir /root/serve
exec > /root/serve/logs.txt 2>&1 # log all output to that file
set -e -x

function onerror {
  curl --data "{\"full_name\": \"{{STATUS_SERVER_FULL_NAME}}\", \"branch\": \"{{BRANCH}}\", \"installation_id\": {{GITHUB_INSTALLATION_ID}}, \"ip\": \"$FEATURE_DEPLOY_IP\", \"hash\": \"{{GITHASH}}\", \"secret\": \"{{STATUS_SERVER_SECRET}}\"}" https://featuredeploy.herokuapp.com/error -H "Content-Type: application/json"
}
trap onerror ERR

apt-get -y update
apt-get install -y webfs
/etc/init.d/webfs stop # gets started right after install

cd /root/serve
ufw allow 80
webfsd -p 80 -f logs.txt -b {{HTTP_AUTH_USER}}:{{HTTP_AUTH_PASS}}
cd /root

cat > ~/startup <<- 'UniqueText550e8400e29b11d4a716446655440000'
{{STARTUP}}
UniqueText550e8400e29b11d4a716446655440000
chmod 744 ~/startup

FEATURE_DEPLOY_IP=$(curl http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
export FEATURE_DEPLOY_IP

fallocate -l 8G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon -s

cat > /root/self_destroy <<- SelfDestroy
  curl --data '{"secret": "{{STATUS_SERVER_SECRET}}", "full_name": "{{STATUS_SERVER_FULL_NAME}}", "branch": "{{BRANCH}}", "installation_id": {{GITHUB_INSTALLATION_ID}}}' {{STATUS_SERVER_URL}}destroy -H "Content-Type: application/json"
  curl -X DELETE -H 'Content-Type: application/json' -H 'Authorization: Bearer {{DIGITAL_OCEAN_TOKEN}}' 'https://api.digitalocean.com/v2/droplets/$(curl -s http://1172.16.31.104/metadata/v1/id)'
SelfDestroy

cat /root/self_destroy | at "now + 2 days"

# install tools
curl -sSL https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
curl -sS https://bootstrap.pypa.io/get-pip.py | python - "pip==8.1.2"
update-rc.d -f  apache2 remove # makes and install of apache not start it
sudo apt-get install -y apache2
sudo apt-get install -y build-essential
sudo apt-get install -y python-dev

# checkout the project
cat > ~/.ssh/id_rsa <<- MyPrivateKey
{{PRIVATE_SSH_KEY}}
MyPrivateKey
chmod 400 ~/.ssh/id_rsa
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
git clone {{GIT_CLONE}} app
rm ~/.ssh/id_rsa

cd app
git checkout {{GITHASH}}<commit_msg>Install python before trying to install pip<commit_after>#!/bin/bash

mkdir /root/serve
exec > /root/serve/logs.txt 2>&1 # log all output to that file
set -e -x

function onerror {
  curl --data "{\"full_name\": \"{{STATUS_SERVER_FULL_NAME}}\", \"branch\": \"{{BRANCH}}\", \"installation_id\": {{GITHUB_INSTALLATION_ID}}, \"ip\": \"$FEATURE_DEPLOY_IP\", \"hash\": \"{{GITHASH}}\", \"secret\": \"{{STATUS_SERVER_SECRET}}\"}" https://featuredeploy.herokuapp.com/error -H "Content-Type: application/json"
}
trap onerror ERR

apt-get -y update
apt-get install -y webfs
/etc/init.d/webfs stop # gets started right after install

cd /root/serve
ufw allow 80
webfsd -p 80 -f logs.txt -b {{HTTP_AUTH_USER}}:{{HTTP_AUTH_PASS}}
cd /root

cat > ~/startup <<- 'UniqueText550e8400e29b11d4a716446655440000'
{{STARTUP}}
UniqueText550e8400e29b11d4a716446655440000
chmod 744 ~/startup

FEATURE_DEPLOY_IP=$(curl http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
export FEATURE_DEPLOY_IP

fallocate -l 8G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon -s

cat > /root/self_destroy <<- SelfDestroy
  curl --data '{"secret": "{{STATUS_SERVER_SECRET}}", "full_name": "{{STATUS_SERVER_FULL_NAME}}", "branch": "{{BRANCH}}", "installation_id": {{GITHUB_INSTALLATION_ID}}}' {{STATUS_SERVER_URL}}destroy -H "Content-Type: application/json"
  curl -X DELETE -H 'Content-Type: application/json' -H 'Authorization: Bearer {{DIGITAL_OCEAN_TOKEN}}' 'https://api.digitalocean.com/v2/droplets/$(curl -s http://169.254.169.254/metadata/v1/id)'
SelfDestroy

cat /root/self_destroy | at "now + 2 days"

# install tools
curl -sSL https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

# install python because it isn't installed by default
apt-get install -y python

curl -sS https://bootstrap.pypa.io/get-pip.py | python - "pip==8.1.2"
update-rc.d -f  apache2 remove # makes and install of apache not start it
sudo apt-get install -y apache2
sudo apt-get install -y build-essential
sudo apt-get install -y python-dev

# checkout the project
cat > ~/.ssh/id_rsa <<- MyPrivateKey
{{PRIVATE_SSH_KEY}}
MyPrivateKey
chmod 400 ~/.ssh/id_rsa
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
git clone {{GIT_CLONE}} app
rm ~/.ssh/id_rsa

cd app
git checkout {{GITHASH}}
{'fraction_non_alphanumeric': 0.16530348687042618, 'fraction_numerical': 0.04670684459750323, 'mean_word_length': 4.5059241706161135, 'pattern_counts': {'":': 20, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1271374', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1744, 'n_words': 413}