<commit_before>#!/bin/bash -e

JOB_DIR=/var/vcap/jobs/postgres
PACKAGE_DIR=/var/vcap/packages/postgres-9.4
PACKAGE_DIR_OLD=/var/vcap/packages/postgres

STORE_DIR=/var/vcap/store
DATA_DIR=$STORE_DIR/postgres-9.4
DATA_DIR_OLD=$STORE_DIR/postgres
DATA_DIR_PREVIOUS=$STORE_DIR/postgres-previous

RUN_DIR=/var/vcap/sys/run/postgres
PIDFILE=$RUN_DIR/postgres.pid

HOST='0.0.0.0'
PORT="<%= p("databases.port") %>"
LD_LIBRARY_PATH=$PACKAGE_DIR/lib:$LD_LIBRARY_PATH

if [ -d $DATA_DIR -a -f $STORE_DIR/FLAG_POSTGRES_UPGRADE ]; then
  echo "FAIL: DB upgrade stopped in the middle, manual intervention required, quitting..."
  exit 1
fi


# Ensure that default postgres bin_dir of the postgres plugin is able to locate the bin_dir
if [ ! -d $PACKAGE_DIR ]; then
  ln -s $PACKAGE_DIR $PACKAGE_DIR_OLD
fi

sysctl -w "kernel.shmmax=284934144"

if [ ! -d $STORE_DIR ]; then
  echo "ERROR: storage directory doesn't exist"
  echo "Please add persistent disk to this job"
  exit 1
fi

if [ ! -d $DATA_DIR -o ! -f $DATA_DIR/postgresql.conf ]; then
  mkdir -p $DATA_DIR
  chown vcap:vcap $DATA_DIR
<commit_msg>Correct test for existence of postgres (symlinked) directory (#62)<commit_after>#!/bin/bash -e

JOB_DIR=/var/vcap/jobs/postgres
PACKAGE_DIR=/var/vcap/packages/postgres-9.4
PACKAGE_DIR_OLD=/var/vcap/packages/postgres

STORE_DIR=/var/vcap/store
DATA_DIR=$STORE_DIR/postgres-9.4
DATA_DIR_OLD=$STORE_DIR/postgres
DATA_DIR_PREVIOUS=$STORE_DIR/postgres-previous

RUN_DIR=/var/vcap/sys/run/postgres
PIDFILE=$RUN_DIR/postgres.pid

HOST='0.0.0.0'
PORT="<%= p("databases.port") %>"
LD_LIBRARY_PATH=$PACKAGE_DIR/lib:$LD_LIBRARY_PATH

if [ -d $DATA_DIR -a -f $STORE_DIR/FLAG_POSTGRES_UPGRADE ]; then
  echo "FAIL: DB upgrade stopped in the middle, manual intervention required, quitting..."
  exit 1
fi


# Ensure that default postgres bin_dir of the postgres plugin is able to locate the bin_dir
if [ ! -d $PACKAGE_DIR_OLD ]; then
  ln -s $PACKAGE_DIR $PACKAGE_DIR_OLD
fi

sysctl -w "kernel.shmmax=284934144"

if [ ! -d $STORE_DIR ]; then
  echo "ERROR: storage directory doesn't exist"
  echo "Please add persistent disk to this job"
  exit 1
fi

if [ ! -d $DATA_DIR -o ! -f $DATA_DIR/postgresql.conf ]; then
  mkdir -p $DATA_DIR
  chown vcap:vcap $DATA_DIR

{'fraction_non_alphanumeric': 0.12282268870031264, 'fraction_numerical': 0.01786511835640911, 'mean_word_length': 4.642317380352645, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7382434', 'n_tokens_mistral': 932, 'n_tokens_neox': 877, 'n_words': 204}