1
1
From: Terje Røsten <terje.rosten@oracle.com>
2
Description: Updates script to use existing my.cnf and not delete it if created from template
2
Description: Maintains the pending --skip-my-cnf option in mainline
5
5
diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in
6
6
index 440a977..7d068fc 100644
7
7
--- a/scripts/mysql_install_db.pl.in
8
8
+++ b/scripts/mysql_install_db.pl.in
9
@@ -75,6 +97,8 @@ Usage: $0 [OPTIONS]
10
--help Display this help and exit.
11
--ldata=path The path to the MySQL data directory. Same as --datadir.
12
--no-defaults Don't read default options from any option file.
13
+ --keep-my-cnf Don't try to create my.cnf based on template.
14
+ Useful for systems with working, updated my.cnf.
16
if ( $^O !~ m/^(MSWin32|cygwin)$/ ) {
18
@@ -86,6 +110,7 @@ EOF2
9
@@ -113,6 +113,7 @@ EOF2
20
11
--rpm For internal use. This option is used by RPM files
21
12
during the MySQL installation process.
23
14
--skip-name-resolve Use IP addresses rather than hostnames when creating
24
15
grant table entries. This option can be useful if
25
16
your DNS does not work.
26
@@ -149,6 +174,7 @@ sub parse_arguments
34
@@ -356,13 +382,19 @@ sub tell_root_password {
35
##############################################################################
37
sub generate_random_password {
38
- # On (at least) Linux and Solaris, a "random" device is available, use it:
39
- # cat /dev/urandom | LC_ALL=C tr -dc "[:alnum:]" | fold -w 8 | head -1
40
- # Without LC_ALL, "tr" may not know the "alnum" character class -
41
- # and there are user profiles which do not have this set.
43
- my $password = `cat /dev/urandom | LC_ALL=C tr -dc "[:alnum:]" | fold -w 8 | head -1`;
45
+ # On Linux, Solaris, Max OS X and FreeBSD we have a random device available.
46
+ my $randfile = "/dev/urandom";
47
+ open(FD, $randfile) || die "Can't open $randfile for reading: $!";
51
+ while (length($password) < $pass_len) {
61
@@ -399,11 +431,16 @@ $basedir= "@prefix@" if ! $basedir; # Default
62
# ----------------------------------------------------------------------
67
if ( $opt->{srcdir} and $opt->{basedir} )
17
@@ -439,7 +440,7 @@ if ( $opt->{srcdir} and $opt->{basedir} )
69
19
error($opt,"Specify either --basedir or --srcdir, not both");
21
-if ( $opt->{'keep-my-cnf'} )
71
22
+if ( $opt->{rpm} || $opt->{'keep-my-cnf'} )
77
$opt->{builddir} = $opt->{srcdir} unless $opt->{builddir};
78
@@ -425,7 +462,7 @@ my $config_file;
81
# ----------------------------------------------------------------------
82
-# This will be the default config file
83
+# This will be the default config file (unless creation is unwanted)
84
# ----------------------------------------------------------------------
86
my $cnfext = ( $^O =~ m/^(MSWin32|cygwin)$/ ) ? "ini" : "cnf";
87
@@ -434,6 +471,11 @@ $config_file= "$basedir/my.$cnfext";
89
my $cfg_template= find_in_basedir($opt,"file","my-default.$cnfext",
90
".", "share","share/mysql","support-files");
91
+# Distros might move files
92
+if ((! -r $cfg_template) && (-r "@pkgdatadir@/my-default.cnf")) {
93
+ $cfg_template = "@pkgdatadir@/my-default.cnf";
96
-e $cfg_template or cannot_find_file("my-default.$cnfext");
98
$copy_cfg_file= $config_file;
99
@@ -443,22 +485,21 @@ if (-e $copy_cfg_file)
100
$copy_cfg_file =~ s/my.$cnfext/my-new.$cnfext/;
101
# Too early to print warning here, the user may not notice
103
-open (TEMPL, $cfg_template) or error($opt, "Could not open config template $cfg_template");
104
-if (open (CFG, "> $copy_cfg_file"))
108
- # Remove lines beginning with # *** which are template comments
109
- print CFG $_ unless /^# \*\*\*/;
111
+if ( ! $keep_my_cnf ) {
112
+ open (TEMPL, $cfg_template) or error($opt, "Could not open config template $cfg_template");
113
+ if (open (CFG, "> $copy_cfg_file")) {
115
+ # Remove lines beginning with # *** which are template comments
116
+ print CFG $_ unless /^# \*\*\*/;
120
+ warning($opt,"Could not write to config file $copy_cfg_file: $!");
121
+ $failed_write_cfg= 1;
128
- warning($opt,"Could not write to config file $copy_cfg_file: $!");
129
- $failed_write_cfg= 1;
133
# ----------------------------------------------------------------------
134
# Now we can get arguments from the groups [mysqld] and [mysql_install_db]
135
@@ -621,7 +662,7 @@ if ( $opt->{'skip-name-resolve'} and $resolved and $resolved =~ /\s/ )
26
@@ -664,7 +665,7 @@ if ( $opt->{'skip-name-resolve'} and $resolved and $resolved =~ /\s/ )
138
29
# ----------------------------------------------------------------------
151
42
mkdir($dir, 0700) unless -d $dir;
152
43
if ($opt_user and -w "/")
153
@@ -848,7 +889,13 @@ if ( open(PIPE, "| $mysqld_install_cmd_line") )
155
"Support MySQL by buying support/licenses at http://shop.mysql.com");
157
- if ($copy_cfg_file eq $config_file and !$failed_write_cfg)
161
+ "Note: new default config file not created.",
162
+ "Please make sure your config file is current");
164
+ elsif ($copy_cfg_file eq $config_file and !$failed_write_cfg)
167
"New default config file was created as $config_file and",