From 17136906c68846618c846a5723a16d683aa8e0a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Jul 2007 12:57:46 +0200 Subject: Clean up the mysql_install_db script to ensure that a sane environment is available and reduce the chance of failure. This should fix bug#28585 which is caused by the script being quite random in how it finds files it requires and not giving very good feedback to the user about what went wrong. Also update make_binary_distribution so that it provides the correct path to the required SQL scripts when generating mysql_install_db. The script only previously worked because of the permissive behaviour which looked around the current working directory before the "correct" location. This could lead to severe problems if the user happened to run the script from a location which contained older or even broken copies of the SQL scripts. We now require either a complete binary release (and the mysql_install_db script ran from inside the extracted archive), or an installed compiled tree, as this is the only way we can be sure everything that we need is available and ready to run. While working on this fix, also clean up the mysql_install_db script a lot to make it simpler, easier to read, and hopefully less prone to bugs in the future. scripts/make_binary_distribution.sh: SQL files live in ./share not ./support-files in binary distribution. scripts/mysql_install_db.sh: Use a consistent shell indentation style. --- scripts/mysql_install_db.sh | 274 ++++++++++++++++++++++---------------------- 1 file changed, 135 insertions(+), 139 deletions(-) (limited to 'scripts/mysql_install_db.sh') diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 934d245db15..c5d532ee4ed 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -18,26 +18,65 @@ # # All unrecognized arguments to this script are passed to mysqld. +force=0 in_rpm=0 +ip_only=0 windows=0 -defaults="" -user="" case "$1" in - --no-defaults|--defaults-file=*|--defaults-extra-file=*) - defaults="$1"; shift - ;; + --no-defaults|--defaults-file=*|--defaults-extra-file=*) + defaults="$1"; shift + ;; esac +usage() +{ + cat <&1` if [ $? -ne 0 ] @@ -244,39 +247,35 @@ then fi fi -if test "$ip_only" = "1" +if test "$ip_only" -eq 1 then - ip=`echo "$resolved" | awk '/ /{print $6}'` - hostname=$ip + hostname=`echo "$resolved" | awk '/ /{print $6}'` fi # Create database directories mysql & test -if test ! -d $ldata; then - mkdir $ldata; - chmod 700 $ldata ; -fi -if test ! -d $ldata/mysql; then - mkdir $ldata/mysql; - chmod 700 $ldata/mysql ; -fi -if test ! -d $ldata/test; then - mkdir $ldata/test; - chmod 700 $ldata/test ; -fi -if test -w / -a ! -z "$user"; then - chown $user $ldata $ldata/mysql $ldata/test; -fi +for dir in $ldata $ldata/mysql $ldata/test +do + if test ! -d $dir + then + mkdir -p $dir + chmod 700 $dir + fi + if test -w / -a ! -z "$user" + then + chown $user $dir + fi +done -if test -n "$user"; then +if test -n "$user" +then args="$args --user=$user" fi # Peform the install of system tables mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}" mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \ ---basedir=$basedir --datadir=$ldata --skip-innodb \ ---skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M \ ---net_buffer_length=16K" + --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb \ + --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K" # Pipe mysql_system_tables.sql to "mysqld --bootstrap" s_echo "Installing MySQL system tables..." @@ -284,23 +283,20 @@ if `(echo "use mysql;"; cat $create_system_tables $fill_system_tables) | $mysqld then s_echo "OK" - if test -n "$fill_help_tables" + s_echo "Filling help tables..." + # Pipe fill_help_tables.sql to "mysqld --bootstrap" + if `(echo "use mysql;"; cat $fill_help_tables) | $mysqld_install_cmd_line` then - s_echo "Filling help tables..." - # Pipe fill_help_tables.sql to "mysqld --bootstrap" - if `(echo "use mysql;"; cat $fill_help_tables) | $mysqld_install_cmd_line` - then - # Fill suceeded - s_echo "OK" - else - echo "" - echo "WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!" - echo "The \"HELP\" command might not work properly" - echo "" - fi + # Fill suceeded + s_echo "OK" + else + echo + echo "WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!" + echo "The \"HELP\" command might not work properly" + echo fi - s_echo "" + s_echo s_echo "To start mysqld at boot time you have to copy" s_echo "support-files/mysql.server to the right place for your system" s_echo @@ -319,7 +315,7 @@ then echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'" echo "See the manual for more instructions." - if test "$in_rpm" = "0" + if test "$in_rpm" -eq 0 then echo "You can start the MySQL daemon with:" echo "cd @prefix@ ; $bindir/mysqld_safe &" -- cgit v1.2.1 From 82bbaaf6b1d228aaf162749882830a21b45e41d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Jul 2007 14:27:36 +0200 Subject: Apply a few more cleanups to improve the robustness of mysql_install_db scripts/mysql_install_db.sh: Put back variable initialisation for those which could be passed in via the environment and confuse the script. --- scripts/mysql_install_db.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'scripts/mysql_install_db.sh') diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index c5d532ee4ed..760ece5aaed 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -18,6 +18,15 @@ # # All unrecognized arguments to this script are passed to mysqld. +basedir="" +ldata="" +srcdir="" + +args="" +defaults="" +mysqld_opt="" +user="" + force=0 in_rpm=0 ip_only=0 @@ -87,7 +96,8 @@ parse_arguments() shift fi - for arg do + for arg + do case "$arg" in --force) force=1 ;; --basedir=*) basedir=`parse_arg "$arg"` ;; @@ -203,11 +213,10 @@ then mysqld="./sql/mysqld" if test -n "$srcdir" -a -f "$srcdir/sql/share/english/errmsg.sys" then - langdir="$srcdir/sql/share/english" + mysqld_opt="--language=$srcdir/sql/share/english" else - langdir="./sql/share/english" + mysqld_opt="./sql/share/english" fi - mysqld_opt="--language=$langdir" fi # Make sure mysqld is available in default location (--basedir option is -- cgit v1.2.1 From 8f5b02541e6000d920c17ad000342d512e8aca5d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Jul 2007 14:31:11 +0200 Subject: mysql_install_db.sh: Fix error in previous change, correct --language argument. scripts/mysql_install_db.sh: Fix error in previous change, correct --language argument. --- scripts/mysql_install_db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/mysql_install_db.sh') diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 760ece5aaed..7e1f6217b7b 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -215,7 +215,7 @@ then then mysqld_opt="--language=$srcdir/sql/share/english" else - mysqld_opt="./sql/share/english" + mysqld_opt="--language=./sql/share/english" fi fi -- cgit v1.2.1 From aad42dc7f4484de4ac3b635e8db59ff2c0665bd2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Jul 2007 15:14:21 +0200 Subject: More fixes and cleanups for bug#28585: - make the 'dist-hook' from top-level Makefile work again. - we can find my_print_defaults from --basedir by parsing command line arguments prior to running my_print_defaults. - take advantage of additional command line parsing and allow the --no-defaults etc arguments to work anywhere rather than having to be the first argument. - find SQL files either from binary archive or source install. - consolidate and tidy code and error messages. scripts/mysql_install_db.sh: Consolidate error messages. --- scripts/mysql_install_db.sh | 107 ++++++++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 29 deletions(-) (limited to 'scripts/mysql_install_db.sh') diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 7e1f6217b7b..a66129af1d3 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -32,12 +32,6 @@ in_rpm=0 ip_only=0 windows=0 -case "$1" in - --no-defaults|--defaults-file=*|--defaults-extra-file=*) - defaults="$1"; shift - ;; -esac - usage() { cat <