<commit_before>define "senode_trusty" do
  copyboot

  run("run apt-update ") do
    chroot "apt-get -y --force-yes update"
  end

  run("mounting devices") do
    cmd "mount --bind /dev #{spec[:temp_dir]}/dev"
    cmd "mount -t proc none #{spec[:temp_dir]}/proc"
    cmd "mount -t sysfs none #{spec[:temp_dir]}/sys"
  end

  cleanup do
    log.debug("cleaning up procs")
    log.debug(`mount -l | grep #{spec[:hostname]}/proc | wc -l`.chomp)
    keep_doing do
      suppress_error.cmd "umount -l #{spec[:temp_dir]}/proc"
    end.until { `mount -l | grep #{spec[:hostname]}/proc | wc -l`.chomp == "0" }

    keep_doing do
      suppress_error.cmd "umount -l #{spec[:temp_dir]}/sys"
    end.until { `mount -l | grep #{spec[:hostname]}/sys | wc -l`.chomp == "0" }

    keep_doing do
      suppress_error.cmd "umount -l #{spec[:temp_dir]}/dev"
    end.until { `mount -l | grep #{spec[:hostname]}/dev | wc -l`.chomp == "0" }
  end

  run("create ci user") do
    chroot "/usr/sbin/adduser ci"
  end

  run("install selenium packages") do
    apt_install "openjdk-7-jdk"
    apt_install "acpid"
    apt_install "xvfb"
    apt_install "dbus"
    apt_install "dbus-x11"
    apt_install "hicolor-icon-theme"
    firefox_version = spec[:firefox_version] || "11.0+build1-0ubuntu4"
    apt_install "firefox=#{firefox_version}"
    chrome_version = spec[:chrome_version] || "22.0.1229.79-r158531"
    apt_install "google-chrome-stable=#{chrome_version}"
    selenium_version = spec[:selenium_version] || "2.32.0"
    apt_install "selenium=#{selenium_version}"
    apt_install "selenium-node"
    chroot "update-rc.d selenium-node defaults"
    chroot "sed -i'.bak' -e 's#^securerandom.source=file:/dev/urandom#securerandom.source=file:" \
      "/dev/../dev/urandom#g' /etc/java-7-openjdk/security/java.security"
    chroot "ln -s /usr/lib/firefox/firefox /usr/bin/firefox-bin"
  end

  cleanup do
    chroot "/etc/init.d/dbus stop"
  end

  run("place the selenium node config") do
    host = spec[:selenium_hub_host]
    port = "7799"

    cmd "mkdir -p #{spec[:temp_dir]}/etc/default"
    open("#{spec[:temp_dir]}/etc/default/selenium-node", 'w') do |f|
      f.puts "HUBHOST=#{host}"
      f.puts "HUBPORT=#{port}"
    end
  end
end<commit_msg>tomd/helen: make some predictions about how we want the trusty senode to look<commit_after>define "senode_trusty" do
  copyboot

  run("run apt-update ") do
    chroot "apt-get -y --force-yes update"
  end

  run("mounting devices") do
    cmd "mount --bind /dev #{spec[:temp_dir]}/dev"
    cmd "mount -t proc none #{spec[:temp_dir]}/proc"
    cmd "mount -t sysfs none #{spec[:temp_dir]}/sys"
  end

  cleanup do
    log.debug("cleaning up procs")
    log.debug(`mount -l | grep #{spec[:hostname]}/proc | wc -l`.chomp)
    keep_doing do
      suppress_error.cmd "umount -l #{spec[:temp_dir]}/proc"
    end.until { `mount -l | grep #{spec[:hostname]}/proc | wc -l`.chomp == "0" }

    keep_doing do
      suppress_error.cmd "umount -l #{spec[:temp_dir]}/sys"
    end.until { `mount -l | grep #{spec[:hostname]}/sys | wc -l`.chomp == "0" }

    keep_doing do
      suppress_error.cmd "umount -l #{spec[:temp_dir]}/dev"
    end.until { `mount -l | grep #{spec[:hostname]}/dev | wc -l`.chomp == "0" }
  end

  run("create ci user") do
    chroot "/usr/sbin/adduser ci"
  end

  run("install selenium packages") do
    apt_install "zulu-8"
    chroot "sed -i'.bak' -e 's#^securerandom.source=.*#securerandom.source=file:/dev/../dev/urandom#' \
      /usr/lib/jvm/zulu-8-amd64/jre/lib/security/java.security"

    apt_install "acpid"
    apt_install "xvfb"
    apt_install "dbus"
    apt_install "dbus-x11"
    apt_install "hicolor-icon-theme"

    firefox_version = spec[:firefox_version] || "11.0+build1-0ubuntu4"
    apt_install "firefox=#{firefox_version}"
    chroot "ln -s /usr/lib/firefox/firefox /usr/bin/firefox-bin"

    chrome_version = spec[:chrome_version] || "22.0.1229.79-r158531"
    apt_install "google-chrome-stable=#{chrome_version}"

    selenium_version = spec[:selenium_version] || "2.32.0"
    apt_install "selenium=#{selenium_version}"

    apt_install "selenium-node"
    chroot "update-rc.d selenium-node defaults"
  end

  cleanup do
    chroot "/etc/init.d/dbus stop"
  end

  run("place the selenium node config") do
    host = spec[:selenium_hub_host]
    port = "7799"

    cmd "mkdir -p #{spec[:temp_dir]}/etc/default"
    open("#{spec[:temp_dir]}/etc/default/selenium-node", 'w') do |f|
      f.puts "HUBHOST=#{host}"
      f.puts "HUBPORT=#{port}"
    end
  end
end
{'fraction_non_alphanumeric': 0.16427467432104217, 'fraction_numerical': 0.016339147714727314, 'mean_word_length': 3.2100371747211898, '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': '1369928', 'n_tokens_mistral': 1801, 'n_tokens_neox': 1705, 'n_words': 364}