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

# GitHub Actions pinned an older mysql-client version on runners temporarily
# due to an issue with the new version, so installation is not currently possible,
# see https://github.com/actions/virtual-environments/pull/4674; uncomment once fixed
# sudo apt-get mysql-client
sudo apt-get install libffi-dev build-essential apg

# Use examplar configuration for the beginning
cd website

# create example database
SQL_PASS=$(apg -m 128 -n 1 -E "\"'")
mv example_database.sql database.sql
sed "s|user|test_user|" database.sql -i
sed "s|pass|$SQL_PASS|" database.sql -i
sed "s|localhost|%|" database.sql -i
cat database.sql
echo "MySQL user: $MYSQL_USER"
mysql --host 127.0.0.1 --port "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" < database.sql
echo "Database created"
mysql --host 127.0.0.1 --port "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e 'SHOW DATABASES;'

mv example_config.py config.py
sed "s|user:pass@localhost|test_user:$SQL_PASS@127.0.0.1:$MYSQL_PORT|" config.py -i

R_LIBS_SITE=$(Rscript -e 'cat(paste(.libPaths(), collapse=":"))')
echo "R_LIBS_SITE: $R_LIBS_SITE"
sed "s|^R_LIBRARY_PATH = .*|R_LIBRARY_PATH = '$R_LIBS_SITE'|" config.py -i
R_HOME=$(R RHOME)
echo "R_HOME: $R_HOME"
sed "s|^R_HOME = .*|R_HOME = '$R_HOME'|" config.py -i

RANDOM_KEY=$(apg -m 128 -n 1 -E "\"'")
sed "s|^SECRET_KEY = .*|SECRET_KEY = \"$RANDOM_KEY\"|" config.py -i
cat config.py
cd ..

#git clone https://github.com/juanmirocks/Levenshtein-MySQL-UDF
#cd Levenshtein-MySQL-UDF
#echo `mysql_config --include`
#gcc -o levenshtein.so -fPIC -shared levenshtein.c `mysql_config --include` `mysql_config --include`/server
#sudo cp levenshtein.so `mysql_config --plugindir`
# for MariaDB use:
# plugin_dir=$(sudo mysql -e 'select @@plugin_dir;' | grep -v '@')
# sudo cp levenshtein.so $plugin_dir
#cd ..
#rm -rf Levenshtein-MySQL-UDF

# install autoprefixer, clean-css and nunjucks
npm install --global

# fix nunjucks to add jinja-compat mode for precompile
wget https://github.com/mozilla/nunjucks/pull/1319.patch
patch $(npm root -g)/nunjucks/ 1319.patch
rm 1319.patch

# rabbitmq-server: broker for celery
# keeping it down there as it takes quite some time
sudo apt-get install rabbitmq-server

# generate keys (for testing only!)
mkdir -p celery
cd celery
ssh-keygen -t rsa -b 4096 -f worker.key -q -N '' -m PEM
yes '' | openssl req -new -key worker.key -out worker.csr<commit_msg>Patch entire directory with p0<commit_after>#!/usr/bin/env bash
set -e

# GitHub Actions pinned an older mysql-client version on runners temporarily
# due to an issue with the new version, so installation is not currently possible,
# see https://github.com/actions/virtual-environments/pull/4674; uncomment once fixed
# sudo apt-get mysql-client
sudo apt-get install libffi-dev build-essential apg

# Use examplar configuration for the beginning
cd website

# create example database
SQL_PASS=$(apg -m 128 -n 1 -E "\"'")
mv example_database.sql database.sql
sed "s|user|test_user|" database.sql -i
sed "s|pass|$SQL_PASS|" database.sql -i
sed "s|localhost|%|" database.sql -i
cat database.sql
echo "MySQL user: $MYSQL_USER"
mysql --host 127.0.0.1 --port "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" < database.sql
echo "Database created"
mysql --host 127.0.0.1 --port "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e 'SHOW DATABASES;'

mv example_config.py config.py
sed "s|user:pass@localhost|test_user:$SQL_PASS@127.0.0.1:$MYSQL_PORT|" config.py -i

R_LIBS_SITE=$(Rscript -e 'cat(paste(.libPaths(), collapse=":"))')
echo "R_LIBS_SITE: $R_LIBS_SITE"
sed "s|^R_LIBRARY_PATH = .*|R_LIBRARY_PATH = '$R_LIBS_SITE'|" config.py -i
R_HOME=$(R RHOME)
echo "R_HOME: $R_HOME"
sed "s|^R_HOME = .*|R_HOME = '$R_HOME'|" config.py -i

RANDOM_KEY=$(apg -m 128 -n 1 -E "\"'")
sed "s|^SECRET_KEY = .*|SECRET_KEY = \"$RANDOM_KEY\"|" config.py -i
cat config.py
cd ..

#git clone https://github.com/juanmirocks/Levenshtein-MySQL-UDF
#cd Levenshtein-MySQL-UDF
#echo `mysql_config --include`
#gcc -o levenshtein.so -fPIC -shared levenshtein.c `mysql_config --include` `mysql_config --include`/server
#sudo cp levenshtein.so `mysql_config --plugindir`
# for MariaDB use:
# plugin_dir=$(sudo mysql -e 'select @@plugin_dir;' | grep -v '@')
# sudo cp levenshtein.so $plugin_dir
#cd ..
#rm -rf Levenshtein-MySQL-UDF

# install autoprefixer, clean-css and nunjucks
npm install --global

# fix nunjucks to add jinja-compat mode for precompile
wget https://github.com/mozilla/nunjucks/pull/1319.patch
patch -p0 $(npm root -g)/nunjucks < 1319.patch
rm 1319.patch

# rabbitmq-server: broker for celery
# keeping it down there as it takes quite some time
sudo apt-get install rabbitmq-server

# generate keys (for testing only!)
mkdir -p celery
cd celery
ssh-keygen -t rsa -b 4096 -f worker.key -q -N '' -m PEM
yes '' | openssl req -new -key worker.key -out worker.csr
{'fraction_non_alphanumeric': 0.14394250513347023, 'fraction_numerical': 0.019301848049281315, 'mean_word_length': 4.418242491657397, 'pattern_counts': {'":': 2, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '151744', 'n_tokens_mistral': 1979, 'n_tokens_neox': 1852, 'n_words': 528}