<commit_before>#!/usr/bin/env bash
set -e

echo "#############################################################################################"
echo "############################# Prepare Hubot and StackStorm ##################################"
# Install StackStorm hubot integration pack
st2 run packs.install packs=hubot register=all

# Install Hubot dependencies
apt-get install -y build-essential redis-server

# Install Nodejs and npm
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
apt-get install -y nodejs

# Install Hubot
npm install -g hubot coffee-script yo generator-hubot

# Prepare hubot installation from stanley linux user, previously created by StackStorm
# we will run chatops commands from that user
mkdir -p /opt/hubot
chown stanley:stanley /opt/hubot

# Generate Hubot config under /opt/hubot
sudo -H -u stanley bash -c 'cd /opt/hubot && echo "n" | yo hubot --name=stanley --description="Stanley StackStorm bot" --defaults'

# Install Slack and StackStorm plugins
sudo -H -u stanley bash -c 'cd /opt/hubot && npm install hubot-slack hubot-stackstorm --save'

# Add "hubot-stackstorm" entry into /opt/hubot/external-scripts.json file (only if it doesn't exist)
grep -q 'hubot-stackstorm' /opt/hubot/external-scripts.json || sed -i 's/.*\[.*/&\n  "hubot-stackstorm",/' /opt/hubot/external-scripts.json

# Create upstart script
cp /vagrant/hubot/hubot.conf /etc/init/hubot.conf
chmod -x /etc/init/hubot.conf

# Save HUBOT_SLACK_TOKEN into /etc/init/hubot.conf if not present
grep -q "HUBOT_SLACK_TOKEN=${HUBOT_SLACK_TOKEN}" /etc/init/hubot.conf || sed -i "s/HUBOT_SLACK_TOKEN.*/HUBOT_SLACK_TOKEN=${HUBOT_SLACK_TOKEN}/" /etc/init/hubot.conf
<commit_msg>sudo as stanley for sed<commit_after>#!/usr/bin/env bash
set -e

echo "#############################################################################################"
echo "############################# Prepare Hubot and StackStorm ##################################"
# Install StackStorm hubot integration pack
st2 run packs.install packs=hubot register=all

# Install Hubot dependencies
apt-get install -y build-essential redis-server

# Install Nodejs and npm
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
apt-get install -y nodejs

# Install Hubot
npm install -g hubot coffee-script yo generator-hubot

# Prepare hubot installation from stanley linux user, previously created by StackStorm
# we will run chatops commands from that user
mkdir -p /opt/hubot
chown stanley:stanley /opt/hubot

# Generate Hubot config under /opt/hubot
sudo -H -u stanley bash -c 'cd /opt/hubot && echo "n" | yo hubot --name=stanley --description="Stanley StackStorm bot" --defaults'

# Install Slack and StackStorm plugins
sudo -H -u stanley bash -c 'cd /opt/hubot && npm install hubot-slack hubot-stackstorm --save'

# Add "hubot-stackstorm" entry into /opt/hubot/external-scripts.json file (only if it doesn't exist)
grep -q 'hubot-stackstorm' /opt/hubot/external-scripts.json || sudo -H -u stanley sed -i 's/.*\[.*/&\n  "hubot-stackstorm",/' /opt/hubot/external-scripts.json

# Create upstart script
cp /vagrant/hubot/hubot.conf /etc/init/hubot.conf
chmod -x /etc/init/hubot.conf

# Save HUBOT_SLACK_TOKEN into /etc/init/hubot.conf if not present
grep -q "HUBOT_SLACK_TOKEN=${HUBOT_SLACK_TOKEN}" /etc/init/hubot.conf || sed -i "s/HUBOT_SLACK_TOKEN.*/HUBOT_SLACK_TOKEN=${HUBOT_SLACK_TOKEN}/" /etc/init/hubot.conf

{'fraction_non_alphanumeric': 0.1991163475699558, 'fraction_numerical': 0.00235640648011782, 'mean_word_length': 4.594728171334432, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2413654', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1132, 'n_words': 326}