@@ -24,6 +24,15 @@ module Travis
               end
             end
 
+            if services.delete('mysql')
+              sh.if "$(grep -E '^socket = /run/mysql-5.6' #{HOME_DIR}/.my.cnf)" do
+                sh.cmd "sudo service mysql-5.6 start", assert: false, echo: true, timing: true
+              end
+              sh.else do
+                sh.cmd "sudo service mysql start", assert: false, echo: true, timing: true
+              end
+            end
+
             services.each do |name|
               sh.cmd "sudo service #{name.shellescape} start", assert: false, echo: true, timing: true
             end
require 'shellwords'
require 'travis/build/appliances/base'

module Travis
  module Build
    module Appliances
      class Services < Base
        SERVICES = {
          'hbase'        => 'hbase-master', # for HBase status, see travis-ci/travis-cookbooks#40. MK.
          'memcache'     => 'memcached',
          'neo4j-server' => 'neo4j',
          'rabbitmq'     => 'rabbitmq-server',
          'redis'        => 'redis-server'
        }

        def apply
          sh.fold 'services' do
            if services.delete('mongodb')
              sh.if "$(lsb_release -cs) != 'precise'" do
                sh.cmd "sudo service mongod start", assert: false, echo: true, timing: true
              end
              sh.else do
                sh.cmd "sudo service mongodb start", assert: false, echo: true, timing: true
              end
            end

            services.each do |name|
              sh.cmd "sudo service #{name.shellescape} start", assert: false, echo: true, timing: true
            end
            sh.raw 'sleep 3'
          end
        end

        def apply?
          services.any?
        end

        private

          def services
            @services ||= Array(config[:services]).map do |name|
              normalize(name)
            end
          end

          def normalize(name)
            name = name.to_s.downcase
            SERVICES[name] ? SERVICES[name] : name
          end
      end
    end
  end
end

Can we announce the start of `mysql` service? (or does it happen elsewhere?)