Skip to content

Commit

Permalink
Add and use a function to save the MySQL version number
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Dec 27, 2016
1 parent ad381d1 commit 1fd2f39
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions mysql/mysql-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
$mysql_login = $userconfig{'login'};
$mysql_pass = $userconfig{'pass'};
}
if (open(VERSION, "$user_module_config_directory/version")) {
chop($mysql_version = <VERSION>);
close(VERSION);
}
chop($mysql_version = &read_file_contents(
"$user_module_config_directory/version"));
$max_dbs = $userconfig{'max_dbs'};
$commands_file = "$user_module_config_directory/commands";
$sql_charset = $userconfig{'charset'};
Expand All @@ -48,13 +46,9 @@
$mysql_login = $config{'login'};
$mysql_pass = $config{'pass'};
}
if (open(VERSION, "$module_config_directory/version")) {
chop($mysql_version = <VERSION>);
close(VERSION);
}
else {
$mysql_version = &get_mysql_version();
}
chop($mysql_version = &read_file_contents(
"$module_config_directory/version"));
$mysql_version ||= &get_mysql_version();
$cron_cmd = "$module_config_directory/backup.pl";
$max_dbs = $config{'max_dbs'};
$commands_file = "$module_config_directory/commands";
Expand Down Expand Up @@ -815,6 +809,19 @@ sub get_remote_mysql_version
return $data->{'data'}->[0]->[0];
}

# save_mysql_version([number])
# Update the saved local MySQL version number
sub save_mysql_version
{
local ($ver) = @_;
$ver ||= &get_mysql_version();
if ($ver) {
&open_tempfile(VERSION, ">$module_config_directory/version");
&print_tempfile(VERSION, $ver,"\n");
&close_tempfile(VERSION);
}
}

# date_subs(filename)
# Does strftime-style date substitutions on a filename, if enabled
sub date_subs
Expand Down

0 comments on commit 1fd2f39

Please sign in to comment.