<commit_before>#! /bin/sh

set -x

[ -z $ANSIBLE_SSH_HOST ] && echo "ANSIBLE_SSH_HOST is missing." && exit 1

if [ -z ${PROJECT_SRC_PATH} ] || [ ! -d ${PROJECT_SRC_PATH} ]; then
  echo "Failed to locate source dir ${PROJECT_SRC_PATH}"
  exit 1
fi

quiet() {
  ( $@ ) > /dev/null 2>&1
}

abs_dir() {
  cd "${1%/*}"; link=`readlink ${1##*/}`;
  if [ -z "$link" ]; then pwd; else abs_dir $link; fi
}
ROOT_PATH=`abs_dir ${BASH_SOURCE:-$0}`
cd ${ROOT_PATH}

set -e

ROOT_SSH_PATH="/root/.ssh"
mkdir -p ${ROOT_SSH_PATH}
echo > playbooks/roles/configure/files/authorized_keys
if [ -d ${LOCAL_SSH_KEYS_PATH} ] && quiet ls ${LOCAL_SSH_KEYS_PATH}/*.pub; then
  if [ "${LOCAL_SSH_KEYS_PATH%/}" != "${ROOT_SSH_PATH}" ]; then
    cp -R ${LOCAL_SSH_KEYS_PATH}/* ${ROOT_SSH_PATH}
  fi
else
  if ! quiet ls ${ROOT_SSH_PATH}/id_rsa.pub; then
    ssh-keygen -t rsa -b 4096 -N "" -f ${ROOT_SSH_PATH}/id_rsa
  fi
fi
cat ${ROOT_SSH_PATH}/*.pub >> playbooks/roles/configure/files/authorized_keys

export ANSIBLE_HOST_KEY_CHECKING=False

[ -z $ANSIBLE_SSH_USER ] && \
  ANSIBLE_SSH_USER='git'
[ -z $ANSIBLE_SSH_PASS ] && \
  ANSIBLE_SSH_PASS=$( date +%s | sha256sum | base64 | head -c 32 | sha256sum | awk '{print $1}' )
[ -z $ANSIBLE_SSH_ROOT_USER ] && \
  ANSIBLE_SSH_ROOT_USER='root'
[ -z $ANSIBLE_SSH_PORT ] && \
  ANSIBLE_SSH_PORT='22'
[ -z $AZK_DOMAIN ] && \
  AZK_DOMAIN='dev.azk.io'
<commit_msg>Adding default values for PROJECT_SRC_PATH and LOCAL_SSH_KEYS_PATH<commit_after>#! /bin/sh

set -x

[ -z $ANSIBLE_SSH_HOST ] && echo "ANSIBLE_SSH_HOST is missing." && exit 1

[ -z ${PROJECT_SRC_PATH} ] && PROJECT_SRC_PATH="/azk/deploy/src"

if [ ! -d ${PROJECT_SRC_PATH} ]; then
  echo "Failed to locate source dir ${PROJECT_SRC_PATH}"
  exit 1
fi

quiet() {
  ( $@ ) > /dev/null 2>&1
}

abs_dir() {
  cd "${1%/*}"; link=`readlink ${1##*/}`;
  if [ -z "$link" ]; then pwd; else abs_dir $link; fi
}
ROOT_PATH=`abs_dir ${BASH_SOURCE:-$0}`
cd ${ROOT_PATH}

set -e

ROOT_SSH_PATH="/root/.ssh"
[ -z ${LOCAL_SSH_KEYS_PATH} ] && LOCAL_SSH_KEYS_PATH="/azk/deploy/.ssh"
mkdir -p ${ROOT_SSH_PATH}
echo > playbooks/roles/configure/files/authorized_keys
if [ -d ${LOCAL_SSH_KEYS_PATH} ] && quiet ls ${LOCAL_SSH_KEYS_PATH}/*.pub; then
  if [ "${LOCAL_SSH_KEYS_PATH%/}" != "${ROOT_SSH_PATH}" ]; then
    cp -R ${LOCAL_SSH_KEYS_PATH}/* ${ROOT_SSH_PATH}
  fi
else
  if ! quiet ls ${ROOT_SSH_PATH}/id_rsa.pub; then
    ssh-keygen -t rsa -b 4096 -N "" -f ${ROOT_SSH_PATH}/id_rsa
  fi
fi
cat ${ROOT_SSH_PATH}/*.pub >> playbooks/roles/configure/files/authorized_keys

export ANSIBLE_HOST_KEY_CHECKING=False

[ -z $ANSIBLE_SSH_USER ] && \
  ANSIBLE_SSH_USER='git'
[ -z $ANSIBLE_SSH_PASS ] && \
  ANSIBLE_SSH_PASS=$( date +%s | sha256sum | base64 | head -c 32 | sha256sum | awk '{print $1}' )
[ -z $ANSIBLE_SSH_ROOT_USER ] && \
  ANSIBLE_SSH_ROOT_USER='root'
[ -z $ANSIBLE_SSH_PORT ] && \
  ANSIBLE_SSH_PORT='22'
[ -z $AZK_DOMAIN ] && \
  AZK_DOMAIN='dev.azk.io'

{'fraction_non_alphanumeric': 0.18041766518315647, 'fraction_numerical': 0.01643272851763095, 'mean_word_length': 4.081739130434783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, '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': '3575129', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1283, 'n_words': 250}