<commit_before>#!/bin/bash

docker_machine_name=${DEFAULT_DOCKER_MACHINE_NAME:-boot2docker}

dns_set="${1:-empty}"
what="${2:-network_service_dns|dlite|docker-machine|networksetup}"
what="^(${what})\$"

if [ "$dns_set"  != "empty" ]
then
  if [[ 'network_service_dns' =~ $what ]]
  then
    scutil <<< "list State:/Network/Service/[^/]+/DNS" |
    while read subkey index eq network_service_dns
    do
      sudo scutil << EOF
        open
        d.init
        d.add ServerAddresses * $dns_set
        set $network_service_dns
        quit
EOF
    done
  fi

  if [[ 'dlite' =~ $what ]]
  then
    if which dlite > /dev/null 2>&1
    then
      ssh -T docker@local.docker << EOF > /dev/null
      sudo tee /etc/resolv.conf << TEE
      nameserver $dns_set
TEE
EOF
    fi
  fi

  if [[ 'docker-machine' =~ $what ]]
  then
    if which docker-machine > /dev/null 2>&1
    then
      if docker-machine ls -filter state=running | grep -q "^$docker_machine_name"
      then
        docker-machine ssh $docker_machine_name << EOF > /dev/null
          sudo tee /etc/resolv.conf << TEE
            nameserver $dns_set
TEE
EOF
      fi
    fi<commit_msg>resolv.conf dont like spaces before nameserver (sometimes)<commit_after>#!/bin/bash

docker_machine_name=${DEFAULT_DOCKER_MACHINE_NAME:-boot2docker}

dns_set="${1:-empty}"
what="${2:-network_service_dns|dlite|docker-machine|networksetup}"
what="^(${what})\$"

if [ "$dns_set"  != "empty" ]
then
  if [[ 'network_service_dns' =~ $what ]]
  then
    scutil <<< "list State:/Network/Service/[^/]+/DNS" |
    while read subkey index eq network_service_dns
    do
      sudo scutil << EOF
        open
        d.init
        d.add ServerAddresses * $dns_set
        set $network_service_dns
        quit
EOF
    done
  fi

  if [[ 'dlite' =~ $what ]]
  then
    if which dlite > /dev/null 2>&1
    then
      ssh -T docker@local.docker << EOF > /dev/null
      sudo tee /etc/resolv.conf << TEE
nameserver $dns_set
TEE
EOF
    fi
  fi

  if [[ 'docker-machine' =~ $what ]]
  then
    if which docker-machine > /dev/null 2>&1
    then
      if docker-machine ls -filter state=running | grep -q "^$docker_machine_name"
      then
        docker-machine ssh $docker_machine_name << EOF > /dev/null
          sudo tee /etc/resolv.conf << TEE
nameserver $dns_set
TEE
EOF
      fi
    fi
{'fraction_non_alphanumeric': 0.13129573826947913, 'fraction_numerical': 0.006026689625484288, 'mean_word_length': 2.5753846153846154, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 15, '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': '5575549', 'n_tokens_mistral': 899, 'n_tokens_neox': 842, 'n_words': 197}