<commit_before>#!/bin/bash

hostsfile=/etc/hosts

mydir=$(cd `dirname $(realpath "${BASH_SOURCE[0]}")` && pwd)
ip=$1
hostname=$2

hostfile_entry="${ip} ${hostname} # generated by d7-docker"
if [ -w ${hostsfile} ]; then
  if [ "$(cat ${hostsfile} | grep ${hostname})" != "" ]; then
    cp ${hostsfile} /tmp/.hostsfile
    sed -i "s|^.*${hostname}.*\$|${hostfile_entry}|g" /tmp/.hostsfile
    cp /tmp/.hostsfile ${hostsfile}
  else
    echo ${hostfile_entry} >> ${hostsfile}
  fi
else
  echo "============================================================================"
  echo "I cannot write your hostsfile, so cannot provide you with a nice hostname."
  echo "Do"
  echo "    chown root:$(whoami) /etc/hosts"
  echo "    chmod 770 /etc/hosts"
  echo " in order to fix this..."
  echo ""
  exit 1
fi<commit_msg>Better hostname replacement in hosts file<commit_after>#!/bin/bash

hostsfile=/etc/hosts

mydir=$(cd `dirname $(realpath "${BASH_SOURCE[0]}")` && pwd)
ip=$1
hostname=$2

hostfile_entry="${ip} ${hostname} # generated by d7-docker"
if [ -w ${hostsfile} ]; then
  if [ "$(cat ${hostsfile} | grep ${hostname})" != "" ]; then
    cat ${hostsfile} | grep -v "\s${hostname}\s.*generated" > /tmp/.hostsfile
    cp /tmp/.hostsfile ${hostsfile}
  fi
  echo ${hostfile_entry} >> ${hostsfile}
else
  echo "============================================================================"
  echo "I cannot write your hostsfile, so cannot provide you with a nice hostname."
  echo "Do"
  echo "    chown root:$(whoami) /etc/hosts"
  echo "    chmod 770 /etc/hosts"
  echo " in order to fix this..."
  echo ""
  exit 1
fi
{'fraction_non_alphanumeric': 0.25914445133292, 'fraction_numerical': 0.009919404835709857, 'mean_word_length': 4.02803738317757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '2595672', 'n_tokens_mistral': 569, 'n_tokens_neox': 527, 'n_words': 156}