class DanarchyDeploy::Services::MySQL

Public Class Methods

generate_my_cnf(mysql, options) click to toggle source
# File lib/danarchy_deploy/services/mysql.rb, line 43
def self.generate_my_cnf(mysql, options)
  source = options[:deploy_dir] +
           '/templates/services/mysql/my.cnf.erb'
  
  templates = [{ target: mysql[:my_cnf],
                 source: source,
                 variables: {
                   datadir:      mysql[:datadir],
                   bind_address: mysql[:bind_address] }
               }]

  DanarchyDeploy::Templater.new(templates, options)
end
new(os, mysql, options) click to toggle source
# File lib/danarchy_deploy/services/mysql.rb, line 7
def self.new(os, mysql, options)
  puts "\n" + self.name
  puts "\n > Configuring MySQL service."

  mysql = self.set_parameters(mysql)
  self.generate_my_cnf(mysql, options)

  if File.exist?(mysql[:my_cnf]) && Dir.exist?(mysql[:datadir] + '/mysql')
    puts "   |+ Using existing MySQL service."
  else
    MySQL::NewServer.new(os, mysql, options)
  end

  if mysql[:privileges]
    puts "\n > Configuring MySQL Privileges"
    MySQL::Privileges.new(mysql, options)
  end
end
set_parameters(mysql) click to toggle source
# File lib/danarchy_deploy/services/mysql.rb, line 26
def self.set_parameters(mysql)
  mysql[:default_file] = mysql[:default_file] ?
                           mysql[:default_file] :
                           '/root/.my.cnf'
  mysql[:my_cnf] = mysql[:my_cnf] ?
                     mysql[:my_cnf] :
                     '/etc/mysql/my.cnf'
  mysql[:datadir] = mysql[:datadir] ?
                      mysql[:datadir] :
                      '/var/lib/mysql'
  mysql[:bind_address] = mysql[:bind_address] ?
                           mysql[:bind_address] :
                           '127.0.0.1'

  mysql
end