<commit_before>#
# Cookbook Name:: chef-zerotier
# Recipe:: default
#
# Copyright 2015,  <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# We only need to install zerotier if the binary is not available yet
unless File.exist?(node['zerotier']['binary_path'])
  require 'tempfile'

  installer_path = Tempfile.new('zerotier-installer').path

  remote_file installer_path do
    source node['zerotier']['installer_url']
    mode 0755
  end

  execute "install zerotier" do
    command installer_path
  end
end

# Attempt to join any networks specified
node['zerotier']['networks'].each do | network |
  execute "zerotier join %s" % network do
    command "zerotier-cli join %s" % network
  end
end<commit_msg>Added a retry count, as setting up zerotier frequently fails joining on the first attempt<commit_after>#
# Cookbook Name:: chef-zerotier
# Recipe:: default
#
# Copyright 2015,  <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# We only need to install zerotier if the binary is not available yet
unless File.exist?(node['zerotier']['binary_path'])
  require 'tempfile'

  installer_path = Tempfile.new('zerotier-installer').path

  remote_file installer_path do
    source node['zerotier']['installer_url']
    mode 0755
  end

  execute "install zerotier" do
    command installer_path
  end
end

# Attempt to join any networks specified
node['zerotier']['networks'].each do | network |
  execute "zerotier join %s" % network do
    command "zerotier-cli join %s" % network
    retries 5
  end
end
{'fraction_non_alphanumeric': 0.08531746031746032, 'fraction_numerical': 0.00992063492063492, 'mean_word_length': 4.285115303983228, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4396021', 'n_tokens_mistral': 741, 'n_tokens_neox': 711, 'n_words': 303}