Skip to content

Commit

Permalink
Revert "Change db_initialized function to check against database inst…
Browse files Browse the repository at this point in the history
…ead of files"

This reverts commit f77f744.
  • Loading branch information
tomkrouper committed Dec 12, 2024
1 parent f77f744 commit 44c651b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ All notable changes to this project will be documented in this file.

## Unreleased

Fix #715: Update `db_initialized?` to be based on database connection instead of file existence

## 11.1.9 - *2024-12-09*

## 11.1.8 - *2024-11-18*
Expand Down Expand Up @@ -663,7 +661,7 @@ Adding Ubuntu 13.04 to Platforminfo
- **[COOK-2966] - Address foodcritic failures'
- **[COOK-4182] - Template parse failure in /etc/init/mysql.conf (data_dir)'
- **[COOK-4198] - Added missing tunable'
- **[COOK-4206] - create `root@127.0.0.1`, as well as `root@localhost`'
- **[COOK-4206] - create root@127.0.0.1, as well as root@localhost'

## [4.0.20] - 2014-01-18

Expand Down
26 changes: 5 additions & 21 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,11 @@ def db_init
end

def db_initialized?
cmd = shell_out("test \"#{db_initialized_check_cmd}\" -gt 0", user: 'root')
cmd.exitstatus == 0
end

def db_initialized_check_cmd
# If MySQL is running, mysqladmin ping will return 0 even with invalid credentials
# if MySQL is not running, mysqladmin will return 1 even with valid credentials
cmd = mysqladmin_bin
cmd << ' --user=UNKNOWN_MYSQL_USER'
cmd << ' ping > /dev/null 2>&1 &&'
cmd << " #{mysql_client_bin} #{defaults_file}"
cmd << ' --skip-column-names --batch'
cmd << " --execute=\"SELECT count(*) FROM mysql.db WHERE db LIKE 'test%'\""
return "scl enable #{scl_name} \"#{cmd}\"" if scl_package?
cmd
if v80plus
::File.exist? "#{data_dir}/mysql.ibd"
else
::File.exist? "#{data_dir}/mysql/user.frm"
end
end

def mysql_install_db_bin
Expand All @@ -289,12 +279,6 @@ def mysql_install_db_cmd
cmd
end

def mysql_client_bin
return "#{prefix_dir}/bin/mysql" if platform_family?('smartos')
return 'mysql' if scl_package?
"#{prefix_dir}/usr/bin/mysql"
end

def mysqladmin_bin
return "#{prefix_dir}/bin/mysqladmin" if platform_family?('smartos')
return 'mysqladmin' if scl_package?
Expand Down

0 comments on commit 44c651b

Please sign in to comment.