<commit_before>rails_app_path = "#{node['rails-app']['path']}/current"
bundle_path = "/usr/local/bin"

package "unison" do
  action :install
end

directory "/opt/keys" do
  owner node["scoreboard"]["user"]
  group node["scoreboard"]["user"]
  mode 00755
  action :create
end

cron 'sync_jumpbox_keys' do
  action :create
  minute "*"
  user node["scoreboard"]["user"]
  path "/usr/local/bin:/usr/bin:$PATH"
  command "cd #{rails_app_path} && RAILS_ENV=production bundle exec rake scoreboard:certificates:copy"
end

cron 'backup_scoreboard_database' do
  action :create
  minute "0" # Backup on every hour.
  user node["scoreboard"]["user"]
  path "/usr/local/bin:/usr/bin:$PATH"
  command "cd #{rails_app_path} && RAILS_ENV=production bundle exec rake scoreboard:db:backup"
end

# open access with ufw for port 80
firewall_rule "http" do
  port 80
  action :allow
end

# open access with ufw for port 443
firewall_rule "ssl" do
  port 443
  action :allow
end

# deny all outbound access 
execute "deny outbound" do
  command "ufw default deny outgoing"
end

# allow ssh out for openvpn server
execute "allow ssh" do
  command "ufw allow out ssh"
end<commit_msg>Add in code for seeding database which was removed in refactor.<commit_after>rails_app_path = "#{node['rails-app']['path']}/current"
bundle_path = "/usr/local/bin"

package "unison" do
  action :install
end

directory "/opt/keys" do
  owner node["scoreboard"]["user"]
  group node["scoreboard"]["user"]
  mode 00755
  action :create
end

cron 'sync_jumpbox_keys' do
  action :create
  minute "*"
  user node["scoreboard"]["user"]
  path "/usr/local/bin:/usr/bin:$PATH"
  command "cd #{rails_app_path} && RAILS_ENV=production bundle exec rake scoreboard:certificates:copy"
end

cron 'backup_scoreboard_database' do
  action :create
  minute "0" # Backup on every hour.
  user node["scoreboard"]["user"]
  path "/usr/local/bin:/usr/bin:$PATH"
  command "cd #{rails_app_path} && RAILS_ENV=production bundle exec rake scoreboard:db:backup"
end

bash "seed-scoreboard" do
  user "root"
  cwd rails_app_path
  code <<-EOH
    RAILS_ENV=production bundle exec rake db:seed
    rm -f db/seeds.rb
  EOH
  only_if { ::File.exists?("#{rails_app_path}/db/seeds.rb") }
end

# open access with ufw for port 80
firewall_rule "http" do
  port 80
  action :allow
end

# open access with ufw for port 443
firewall_rule "ssl" do
  port 443
  action :allow
end

# deny all outbound access 
execute "deny outbound" do
  command "ufw default deny outgoing"
end

# allow ssh out for openvpn server
execute "allow ssh" do
  command "ufw allow out ssh"
end
{'fraction_non_alphanumeric': 0.11651234567901235, 'fraction_numerical': 0.012345679012345678, 'mean_word_length': 4.528784648187633, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3903911', 'n_tokens_mistral': 943, 'n_tokens_neox': 900, 'n_words': 280}