<commit_before>#!/usr/bin/env bash

# this runs as root

set -x

source /root/library-functions.sh

# install node
install_node

# create /opt/histograph and set as user home
mkdir -p /opt/histograph
chown -R histograph:histograph /opt/histograph
usermod -d /opt/histograph histograph
chmod -R g+rwX /opt/histograph

# own some shit
chown -R histograph /opt/histograph/.npm
chown -R histograph /usr/local/lib/node_modules

# dir for configs
# TODO rename dir? remove?
mkdir /opt/histograph/run

# dirs for log and PID files
mkdir -p /var/log/histograph /var/run/histograph
chown histograph:histograph /var/log/histograph/ /var/run/histograph/

# install histograph

cd /opt/histograph

cat > setup.sh << SETUP

# clean up
rm -rf ~/api ~/core

# clone master branch
git clone https://github.com/histograph/api
git clone https://github.com/histograph/core

# install node dependencies
cd ~/api
npm install

cd ~/core
npm install
SETUP

chmod +x /opt/histograph/setup.sh
su histograph /opt/histograph/setup.sh

# histograph config file
cat > /opt/histograph/config.yaml << HISTOGRAPH<commit_msg>core not needed on API<commit_after>#!/usr/bin/env bash

# this runs as root

set -x

source /root/library-functions.sh

# install node
install_node

# create /opt/histograph and set as user home
mkdir -p /opt/histograph
chown -R histograph:histograph /opt/histograph
usermod -d /opt/histograph histograph
chmod -R g+rwX /opt/histograph

# own some shit
chown -R histograph /opt/histograph/.npm
chown -R histograph /usr/local/lib/node_modules

# dir for configs
# TODO rename dir? remove?
mkdir /opt/histograph/run

# dirs for log and PID files
mkdir -p /var/log/histograph /var/run/histograph
chown histograph:histograph /var/log/histograph/ /var/run/histograph/

# install histograph

cd /opt/histograph

cat > setup.sh << SETUP

# clean up
rm -rf ~/api

# clone master branch
git clone https://github.com/histograph/api

# install node dependencies
cd ~/api
npm install
SETUP

chmod +x /opt/histograph/setup.sh
su histograph /opt/histograph/setup.sh

# histograph config file
cat > /opt/histograph/config.yaml << HISTOGRAPH
{'fraction_non_alphanumeric': 0.10387157695939565, 'fraction_numerical': 0.0, 'mean_word_length': 3.783295711060948, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 3, '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': '2116417', 'n_tokens_mistral': 753, 'n_tokens_neox': 733, 'n_words': 225}