<commit_before>#!/bin/bash

if [ "$MASTER_SSH_CONFIG" = "" ] ; then
  echo "Please set the MASTER_SSH_CONFIG environment variable before using client-env"
  return 2
fi

if [ "$LOCAL_DEV_DIR" = "" ] ; then
  echo "Please set the LOCAL_DEV_DIR environment variable before using client-env"
  return 2
fi

function __client-env-get-client() {
  if [ -L "$HOME/.current-client-env" ] ; then
    echo $(basename `readlink $HOME/.current-client-env`)
    return 0
  else
    echo "Please make sure to have called client-env-set before using client-env functions"
    return 3
  fi
}

function __client-env-etc-hosts-merge() {
  # Merge our /etc/hosts templates together for the client
  local client=`__client-env-get-client`
  local client_hosts_file_name=$LOCAL_DEV_DIR/$client/${client}-env/conf/hosts

  # Don't bother messing with the files if there isn't a
  # custom override for the client
  if [ ! -f $client_hosts_file_name ] ; then
    return
  fi

  if [ ! -f /etc/hosts.orig ] ; then
    sudo cp /etc/hosts /etc/hosts.orig
  fi

  cat /etc/hosts.orig                                     | sudo tee    /etc/hosts > /dev/null
  echo "# The following is from:                        " | sudo tee -a /etc/hosts > /dev/null
  echo "#                                               " | sudo tee -a /etc/hosts > /dev/null
  echo "#     $client_hosts_file_name                   " | sudo tee -a /etc/hosts > /dev/null
  echo "#                                               " | sudo tee -a /etc/hosts > /dev/null
  echo "# The original hosts file is at /etc/hosts.orig " | sudo tee -a /etc/hosts > /dev/null
  echo "# and will be restored when client-env-clear is " | sudo tee -a /etc/hosts > /dev/null
  echo "# called by the user.                           " | sudo tee -a /etc/hosts > /dev/null
  cat $client_hosts_file_name                             | sudo tee -a /etc/hosts > /dev/null
}

function __client-env-etc-hosts-revert() {
  # Copy our original template back
  if [ -f /etc/hosts.orig ] ; then
    sudo mv /etc/hosts.orig /etc/hosts
  fi
}

function __client-env-ssh-config-merge() {
  # Merge our SSH config templates together for the client
  local client=`__client-env-get-client`

  cat $MASTER_SSH_CONFIG                                    > $HOME/.ssh/config
  cat $LOCAL_DEV_DIR/$client/${client}-env/conf/ssh_config >> $HOME/.ssh/config
}

function __client-env-ssh-config-revert() {
  # Copy our original config template back
  cp $MASTER_SSH_CONFIG $HOME/.ssh/config
}

function __client-env-cp() {
  local client=`__client-env-get-client`
  local dst_dir=$1
  local file_name=$2
  local dst_file_name=$dst_dir/$file_name<commit_msg>Removed ability to merge SSH config and /etc/hosts as it got too hairy<commit_after>#!/bin/bash

if [ "$MASTER_SSH_CONFIG" = "" ] ; then
  echo "Please set the MASTER_SSH_CONFIG environment variable before using client-env"
  return 2
fi

if [ "$LOCAL_DEV_DIR" = "" ] ; then
  echo "Please set the LOCAL_DEV_DIR environment variable before using client-env"
  return 2
fi

function __client-env-get-client() {
  if [ -L "$HOME/.current-client-env" ] ; then
    echo $(basename `readlink $HOME/.current-client-env`)
    return 0
  else
    echo "Please make sure to have called client-env-set before using client-env functions"
    return 3
  fi
}

function __client-env-cp() {
  local client=`__client-env-get-client`
  local dst_dir=$1
  local file_name=$2
  local dst_file_name=$dst_dir/$file_name
{'fraction_non_alphanumeric': 0.11165750650853341, 'fraction_numerical': 0.0034712178189181373, 'mean_word_length': 2.4510978043912175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '785459', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1089, 'n_words': 321}