<commit_before>require 'json'
require 'base64'

private_ip=my_private_ip()
username=node["hopsworks"]["admin"]["user"]
password=node["hopsworks"]["admin"]["password"]
domain_name="domain1"
domains_dir = node["hopsworks"]["domains_dir"]
theDomain="#{domains_dir}/#{domain_name}"
admin_port = node["glassfish"]["admin"]["port"]
web_port = node["glassfish"]["port"]
mysql_user=node["mysql"]["user"]
mysql_password=node["mysql"]["password"]
mysql_host = my_private_ip()
password_file = "#{theDomain}_admin_passwd"



# For unzipping files

case node["platform_family"]
when "debian"
  
  if node.platform_version.to_f <= 14.04
    node.override["hopsworks"]["systemd"] = "false"
  end
  package "dtrx"
  package "libkrb5-dev"

when "rhel"
  package "krb5-libs"
  
  remote_file "#{Chef::Config[:file_cache_path]}/dtrx.tar.gz" do
    user node["glassfish"]["user"]
    group node["glassfish"]["group"]
    source "http://brettcsmith.org/2007/dtrx/dtrx-7.1.tar.gz"
    mode 0755
    action :create
  end
  
  bash "unpack_dtrx" do
    user "root"
    code <<-EOF
    set -e
    cd #{Chef::Config[:file_cache_path]}
    tar -xzf dtrx.tar.gz
    cd dtrx-7.1
    python setup.py install --prefix=/usr/local
  EOF
    not_if "which dtrx"
  end
end

bash "systemd_reload_for_glassfish_failures" do
  user "root"
  code <<-EOF
    systemctl daemon-reload
  EOF
end


if node["hopsworks"]["systemd"] === "true" 
  systemd = true
else
  systemd = false
end

group node["hopsworks"]["group"] do
  action :create
  not_if "getent group #{node['hopsworks']['group']}"
end

group node["jupyter"]["group"] do
  action :create
  not_if "getent group #{node['jupyter']['group']}"
end

#
# hdfs superuser group is 'hdfs'
#
group node.hops.hdfs.user do
  action :create
  not_if "getent group #{node.hops.hdfs.user}"
end

user node["hopsworks"]["user"] do
  home "/home/#{node['hopsworks']['user']}"
  gid node["hopsworks"]["group"]
  action :create
  shell "/bin/bash"
  manage_home true
  not_if "getent passwd #{node['hopsworks']['user']}"
end

group node["jupyter"]["group"] do
  action :modify
  members ["#{node['hopsworks']['user']}"]
  append true
end

# Add to the hdfs superuser group
group node["hops"]["hdfs"]["user"] do
  action :modify
  members ["#{node['hopsworks']['user']}"]
  append true
end

user node["jupyter"]["user"] do
  home node["jupyter"]["base_dir"]
  gid node["jupyter"]["group"]  
  action :create
  shell "/bin/bash"
  manage_home true
  not_if "getent passwd #{node["jupyter"]["user"]}"
end

group node["hops"]["group"] do
  action :modify
  members ["#{node['hopsworks']['user']}", "#{node['jupyter']['user']}"]
  append true
end

#update permissions of base_dir to 770
directory node["jupyter"]["base_dir"]  do
  owner node["jupyter"]["user"]  
  group node["jupyter"]["group"]
  mode "770"
  action :create
end

directory node["hopsworks"]["dir"]  do
  owner node["hopsworks"]["user"]
  group node["hopsworks"]["group"]
  mode "755"
  action :create
  not_if "test -d #{node['hopsworks']['dir']}"
end

directory domains_dir  do
  owner node["hopsworks"]["user"]
  group node["hopsworks"]["group"]
  mode "750"
  action :create
  not_if "test -d #{domains_dir}"
end


node.override = {<commit_msg>fix ordering issue in user creation<commit_after>require 'json'
require 'base64'

private_ip=my_private_ip()
username=node["hopsworks"]["admin"]["user"]
password=node["hopsworks"]["admin"]["password"]
domain_name="domain1"
domains_dir = node["hopsworks"]["domains_dir"]
theDomain="#{domains_dir}/#{domain_name}"
admin_port = node["glassfish"]["admin"]["port"]
web_port = node["glassfish"]["port"]
mysql_user=node["mysql"]["user"]
mysql_password=node["mysql"]["password"]
mysql_host = my_private_ip()
password_file = "#{theDomain}_admin_passwd"


bash "systemd_reload_for_glassfish_failures" do
  user "root"
  code <<-EOF
    systemctl daemon-reload
  EOF
end


if node["hopsworks"]["systemd"] === "true" 
  systemd = true
else
  systemd = false
end

group node["hopsworks"]["group"] do
  action :create
  not_if "getent group #{node['hopsworks']['group']}"
end

group node["jupyter"]["group"] do
  action :create
  not_if "getent group #{node['jupyter']['group']}"
end

#
# hdfs superuser group is 'hdfs'
#
group node.hops.hdfs.user do
  action :create
  not_if "getent group #{node.hops.hdfs.user}"
end

user node["hopsworks"]["user"] do
  home "/home/#{node['hopsworks']['user']}"
  gid node["hopsworks"]["group"]
  action :create
  shell "/bin/bash"
  manage_home true
  not_if "getent passwd #{node['hopsworks']['user']}"
end

group node["jupyter"]["group"] do
  action :modify
  members ["#{node['hopsworks']['user']}"]
  append true
end

# Add to the hdfs superuser group
group node["hops"]["hdfs"]["user"] do
  action :modify
  members ["#{node['hopsworks']['user']}"]
  append true
end

user node["jupyter"]["user"] do
  home node["jupyter"]["base_dir"]
  gid node["jupyter"]["group"]  
  action :create
  shell "/bin/bash"
  manage_home true
  not_if "getent passwd #{node["jupyter"]["user"]}"
end

group node["hops"]["group"] do
  action :modify
  members ["#{node['hopsworks']['user']}", "#{node['jupyter']['user']}"]
  append true
end

#update permissions of base_dir to 770
directory node["jupyter"]["base_dir"]  do
  owner node["jupyter"]["user"]  
  group node["jupyter"]["group"]
  mode "770"
  action :create
end

directory node["hopsworks"]["dir"]  do
  owner node["hopsworks"]["user"]
  group node["hopsworks"]["group"]
  mode "755"
  action :create
  not_if "test -d #{node['hopsworks']['dir']}"
end

directory domains_dir  do
  owner node["hopsworks"]["user"]
  group node["hopsworks"]["group"]
  mode "750"
  action :create
  not_if "test -d #{domains_dir}"
end


# For unzipping files

case node["platform_family"]
when "debian"
  
  if node.platform_version.to_f <= 14.04
    node.override["hopsworks"]["systemd"] = "false"
  end
  package "dtrx"
  package "libkrb5-dev"

when "rhel"
  package "krb5-libs"
  
  remote_file "#{Chef::Config[:file_cache_path]}/dtrx.tar.gz" do
    user node["glassfish"]["user"]
    group node["glassfish"]["group"]
    source "http://brettcsmith.org/2007/dtrx/dtrx-7.1.tar.gz"
    mode 0755
    action :create
  end
  
  bash "unpack_dtrx" do
    user "root"
    code <<-EOF
    set -e
    cd #{Chef::Config[:file_cache_path]}
    tar -xzf dtrx.tar.gz
    cd dtrx-7.1
    python setup.py install --prefix=/usr/local
  EOF
    not_if "which dtrx"
  end
end







node.override = {
{'fraction_non_alphanumeric': 0.17874321179208688, 'fraction_numerical': 0.010240496508921644, 'mean_word_length': 4.941013824884792, 'pattern_counts': {'":': 0, '<': 13, '<?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': '306495', 'n_tokens_mistral': 2425, 'n_tokens_neox': 2477, 'n_words': 527}