<commit_before>#!/bin/bash -x

if [[ $(docker inspect --format='{{.State.Status}}' kubelet-volumes) = 'exited' ]]
then
  exit
else

  docker_root=/var/lib/docker
  kubelet_root=/var/lib/kubelet

  if [ -d /rootfs/etc ] && [ -f /rootfs/etc/os-release ]
  then
    case "$(eval `cat /rootfs/etc/os-release` ; echo $ID)" in
      boot2docker)
        docker_root=/mnt/sda1/var/lib/docker
        kubelet_root=/mnt/sda1/var/lib/kubelet
        mkdir -p /rootfs$kubelet_root
        ln -sf $kubelet_root /rootfs/var/lib/kubelet
        break
        ;;
      *)
        break
        ;;
    esac
  fi

  docker run \
    --volume="/:/rootfs:ro" \
    --volume="/sys:/sys:ro" \
    --volume="/dev:/dev" \
    --volume="${docker_root}/:${docker_root}:rw" \
    --volume="${kubelet_root}/:/var/lib/kubelet:rw" \
    --volume="/var/run:/var/run:rw" \
    --volume="/var/run/weave/weave.sock:/weave.sock" \
    --name=kubelet-volumes \
    weaveworks/kubernetes-anywhere:tools /bin/true
fi<commit_msg>Fix and refactor volume setup helper<commit_after>#!/bin/bash -x

if [[ $(docker inspect --format='{{.State.Status}}' kubelet-volumes) = 'exited' ]]
then
  exit
else

  def_docker_root="/var/lib/docker"
  def_kubelet_root="/var/lib/kubelet"

  if [ -d /rootfs/etc ] && [ -f /rootfs/etc/os-release ]
  then
    case "$(eval `cat /rootfs/etc/os-release` ; echo $ID)" in
      boot2docker)
        docker_root="/mnt/sda1/${def_docker_root}"
        kubelet_root="/mnt/sda1/${def_kubelet_root}"
        mkdir -p "/rootfs/${kubelet_root}"
        ln -sf "${kubelet_root}" "/rootfs/var/lib/kubelet"
        docker_root_vol=" \
          --volume=\"${docker_root}:${docker_root}:rw\" \
          --volume=\"${def_docker_root}:${def_docker_root}:rw\" \
        "
        kubelet_root_vol=" \
          --volume=\"${kubelet_root}:${def_kubelet_root}:rw\" \
        "
        break
        ;;
      *)
        docker_root_vol="\
          --volume=\"${def_docker_root}/:${def_docker_root}:rw\" \
        "
        kubelet_root_vol=" \
          --volume=\"${def_kubelet_root}:${def_kubelet_root}:rw\" \
        "
        break
        ;;
    esac
  fi

  docker run \
    --volume="/:/rootfs:ro" \
    --volume="/sys:/sys:ro" \
    --volume="/dev:/dev" \
    --volume="/var/run:/var/run:rw" \
    ${kubelet_root_vol} \
    ${docker_root_vol} \
    --volume="/var/run/weave/weave.sock:/weave.sock" \
    --name="kubelet-volumes" \
    weaveworks/kubernetes-anywhere:tools "/bin/true"
fi
{'fraction_non_alphanumeric': 0.19383617193836172, 'fraction_numerical': 0.0024330900243309003, 'mean_word_length': 2.1997405966277563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7233975', 'n_tokens_mistral': 996, 'n_tokens_neox': 933, 'n_words': 119}