Sha256: f8d26154821a0edae9f7e62188b3920f9f5926ae0482da459115cf70dc00b154

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

Standup.script :node do
  def run
    install_package 'debconf-utils'
    sudo 'echo "mysql-server-5.1 mysql-server/root_password       password root" | debconf-set-selections'
    sudo 'echo "mysql-server-5.1 mysql-server/root_password_again password root" | debconf-set-selections'
    install_package 'mysql-server-5.1'
    install_package 'libmysqlclient-dev'
    
    # todo: tune performance
  end
  
  def exec_sql sql, local = false
    command = "mysql -uroot -proot -e \"#{sql}\""
    if local
      local_exec command
    else
      exec command
    end
  end
  
  def create_database name, local = false
    if exec_sql("show databases like '#{name}'", local).present?
      false
    else
      exec_sql "create database #{name}", local
      true
    end
  end
  
  def dump_command database, username = 'root', password = 'root'
    "mysqldump -u#{username} -p#{password} --compact -e --create-options --add-drop-table #{database}"
  end
  
  def load_command database, username = 'root', password = 'root'
    "mysql -u#{username} -p#{password} #{database}"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
standup-0.6.9 scripts/mysql.rb
standup-0.6.8 scripts/mysql.rb
standup-0.6.7 scripts/mysql.rb
standup-0.6.6 scripts/mysql.rb