Sha256: 7634025cc18f8770acf34c53bdda7faa6ad3b9457128dc6aa440fa00993ecd88

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

#
# Cookbook Name:: mysql
# Recipe:: default
#

require_recipe 'homebrew'

homebrew 'mysql'

execute "initialize MySQL database" do
  command <<-EOS
    unset TMPDIR
    mysql_install_db --user=#{ENV['USER']} --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
  EOS
  not_if "test -d /usr/local/var/mysql/mysql"
end

gem_package "mysql" do
  action :install
end

Chef::Log.info("Configuring mysql to automatically start on login")

destination_plist = "#{ENV['HOME']}/Library/LaunchAgents/com.mysql.mysqld.plist"
plist_path = "$(brew --prefix mysql)/com.mysql.mysqld.plist"

execute "unloading existing plist" do
  command "launchctl unload -w -F #{destination_plist}"
  only_if "test -f #{destination_plist}"
end

execute "adding plist to login" do
  command <<-EOS
    mkdir -p #{ENV['HOME']}/Library/LaunchAgents
    cp -f #{plist_path} #{destination_plist}
    chmod 0644 #{destination_plist}
    launchctl load -w -F #{destination_plist}
  EOS
end

execute "sleeping to wait for mysql to come online" do
  command "sleep 5"
  not_if "mysqladmin -uroot status"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flombe-0.1.0.7 cookbooks/mysql/recipes/default.rb