<commit_before>namespace :deploy do

  task :before_setup do
    sudo "mkdir -p #{deploy_to}"
    sudo "chown #{user}:#{user} #{deploy_to}"
  end
  
  namespace :shared do
  
    desc 'Setup shared directories'
    task :setup do
      Dir[File.dirname(__FILE__) + '/../../db/**/*'].each do |path|
        next if path =~ /migrate/
        next unless File.directory?(path)
        run "mkdir -p #{shared_path}/db/#{path.split('db/').last}"
      end
      run "mkdir -p #{shared_path}/config"
      run "mkdir -p #{shared_path}/public"
      run "mkdir -p #{shared_path}/themes"
      run "mkdir -p #{shared_path}/plugins"
    end
    after 'deploy:setup', 'deploy:shared:setup'
    
  end
  
  task :create_database do
    mysql_root_password = <PASSWORD>('MySQL ROOT password: ') { |q| q.echo = false }
    run "mysql -uroot -p#{mysql_root_password} -e \"create database onebody; grant all on onebody.* to onebody@localhost identified by '#{get_db_password}'\""
    yml = render_erb_template(File.dirname(__FILE__) + '/templates/database.yml')
    put yml, "#{shared_path}/config/database.yml"
  end
  after 'deploy:setup', 'deploy:create_database'
  
  task :after_update_code do
    rb = render_erb_template(File.dirname(__FILE__) + '/templates/links.rb')
    put rb, "#{release_path}/config/initializers/links.rb"
    run "ln -sf #{shared_path}/config/database.yml #{release_path}/config/database.yml"
    run "if [ -e #{shared_path}/config/email.yml ]; then ln -sf #{shared_path}/config/email.yml #{release_path}/config/email.yml; fi"
    run "rm -rf #{release_path}/public/assets && ln -s #{shared_path}/public/assets #{release_path}/public/assets"
    run "cd #{shared_path}/plugins; if [ \"$(ls -A)\" ]; then rsync -a * #{release_path}/plugins/; fi"
    run "cd #{release_path} && whenever -w RAILS_ENV=production"
  end
  
  task :copy_ssh_key do
    run "mkdir -p ~/.ssh"
    pubkey = File.read(ENV['HOME'] + '/.ssh/id_rsa.pub')
    run "echo #{pubkey} >> ~/.ssh/authorized_keys"
  end
  
end<commit_msg>Update cap recipe to copy shared/initializers upon deploy.<commit_after>namespace :deploy do

  task :before_setup do
    sudo "mkdir -p #{deploy_to}"
    sudo "chown #{user}:#{user} #{deploy_to}"
  end
  
  namespace :shared do
  
    desc 'Setup shared directories'
    task :setup do
      Dir[File.dirname(__FILE__) + '/../../db/**/*'].each do |path|
        next if path =~ /migrate/
        next unless File.directory?(path)
        run "mkdir -p #{shared_path}/db/#{path.split('db/').last}"
      end
      run "mkdir -p #{shared_path}/config"
      run "mkdir -p #{shared_path}/public"
      run "mkdir -p #{shared_path}/themes"
      run "mkdir -p #{shared_path}/plugins"
      run "mkdir -p #{shared_path}/initializers"
    end
    after 'deploy:setup', 'deploy:shared:setup'
    
  end
  
  task :create_database do
    mysql_root_password = HighLine.new.ask('MySQL ROOT password: ') { |q| q.echo = false }
    run "mysql -uroot -p#{mysql_root_password} -e \"create database onebody; grant all on onebody.* to onebody@localhost identified by '#{get_db_password}'\""
    yml = render_erb_template(File.dirname(__FILE__) + '/templates/database.yml')
    put yml, "#{shared_path}/config/database.yml"
  end
  after 'deploy:setup', 'deploy:create_database'
  
  task :after_update_code do
    rb = render_erb_template(File.dirname(__FILE__) + '/templates/links.rb')
    put rb, "#{release_path}/config/initializers/links.rb"
    run "ln -sf #{shared_path}/config/database.yml #{release_path}/config/database.yml"
    run "if [ -e #{shared_path}/config/email.yml ]; then ln -sf #{shared_path}/config/email.yml #{release_path}/config/email.yml; fi"
    run "rm -rf #{release_path}/public/assets && ln -s #{shared_path}/public/assets #{release_path}/public/assets"
    run "cd #{shared_path}/plugins; if [ \"$(ls -A)\" ]; then rsync -a * #{release_path}/plugins/; fi"
    run "cd #{shared_path}/initializers; if [ \"$(ls -A)\" ]; then rsync -a * #{release_path}/config/initializers/; fi"
    run "cd #{release_path} && whenever -w RAILS_ENV=production"
  end
  
  task :copy_ssh_key do
    run "mkdir -p ~/.ssh"
    pubkey = File.read(ENV['HOME'] + '/.ssh/id_rsa.pub')
    run "echo #{pubkey} >> ~/.ssh/authorized_keys"
  end
  
end
{'fraction_non_alphanumeric': 0.1632173095014111, 'fraction_numerical': 0.0, 'mean_word_length': 3.3221544715447155, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '6161811', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1431, 'n_words': 351}