2015-08-01 07:31:57 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
# copyright: 2015, Vulcano Security GmbH
|
|
|
|
# license: All rights reserved
|
|
|
|
|
2015-08-28 19:41:48 +00:00
|
|
|
class Mysql < Vulcano.resource(1)
|
|
|
|
name 'mysql'
|
|
|
|
|
2015-08-01 07:31:57 +00:00
|
|
|
attr_reader :package, :service, :conf_dir, :conf_path, :data_dir, :log_dir, :log_path, :log_group, :log_dir_group
|
|
|
|
def initialize
|
|
|
|
# set OS-dependent filenames and paths
|
2015-09-14 14:37:25 +00:00
|
|
|
case vulcano.os[:family]
|
2015-08-01 07:31:57 +00:00
|
|
|
when 'ubuntu', 'debian'
|
2015-09-09 16:56:28 +00:00
|
|
|
init_ubuntu
|
2015-08-01 07:31:57 +00:00
|
|
|
when 'redhat', 'fedora'
|
2015-09-09 16:56:28 +00:00
|
|
|
init_redhat
|
2015-08-01 07:31:57 +00:00
|
|
|
when 'arch'
|
2015-09-09 16:56:28 +00:00
|
|
|
init_arch
|
2015-08-01 07:31:57 +00:00
|
|
|
else
|
2015-09-04 07:59:30 +00:00
|
|
|
# TODO: could not detect
|
2015-09-09 16:56:28 +00:00
|
|
|
init_default
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def init_ubuntu
|
|
|
|
@package = 'mysql-server'
|
|
|
|
@service = 'mysql'
|
|
|
|
@conf_path = '/etc/mysql/my.cnf'
|
|
|
|
@conf_dir = '/etc/mysql/'
|
|
|
|
@data_dir = '/var/lib/mysql/'
|
|
|
|
@log_dir = '/var/log/'
|
|
|
|
@log_path = '/var/log/mysql.log'
|
|
|
|
@log_group = 'adm'
|
|
|
|
case os[:release]
|
|
|
|
when '14.04'
|
|
|
|
@log_dir_group = 'syslog'
|
|
|
|
else
|
2015-08-01 07:31:57 +00:00
|
|
|
@log_dir_group = 'root'
|
|
|
|
end
|
|
|
|
end
|
2015-09-09 16:56:28 +00:00
|
|
|
|
|
|
|
def init_redhat
|
|
|
|
@package = 'mysql-server'
|
|
|
|
@service = 'mysqld'
|
|
|
|
@conf_path = '/etc/my.cnf'
|
|
|
|
@conf_dir = '/etc/'
|
|
|
|
@data_dir = '/var/lib/mysql/'
|
|
|
|
@log_dir = '/var/log/'
|
|
|
|
@log_path = '/var/log/mysqld.log'
|
|
|
|
@log_group = 'mysql'
|
|
|
|
@log_dir_group = 'root'
|
|
|
|
end
|
|
|
|
|
|
|
|
def init_arch
|
|
|
|
@package = 'mariadb'
|
|
|
|
@service = 'mysql'
|
|
|
|
@conf_path = '/etc/mysql/my.cnf'
|
|
|
|
@conf_dir = '/etc/mysql/'
|
|
|
|
@data_dir = '/var/lib/mysql/'
|
|
|
|
@log_dir = '/var/log/'
|
|
|
|
@log_path = '/var/log/mysql.log'
|
|
|
|
@log_group = 'mysql'
|
|
|
|
@log_dir_group = 'root'
|
|
|
|
end
|
|
|
|
|
|
|
|
def init_default
|
|
|
|
@service = 'mysqld'
|
|
|
|
@conf_path = '/etc/my.cnf'
|
|
|
|
@conf_dir = '/etc/'
|
|
|
|
@data_dir = '/var/lib/mysql/'
|
|
|
|
@log_dir = '/var/log/'
|
|
|
|
@log_path = '/var/log/mysqld.log'
|
|
|
|
@log_group = 'mysql'
|
|
|
|
@log_dir_group = 'root'
|
|
|
|
end
|
2015-08-01 07:31:57 +00:00
|
|
|
end
|