[Dbconfig-common-devel] dbconfig-common/internal mysql,1.3,1.4
seanius@haydn.debian.org
seanius@haydn.debian.org
Update of /cvsroot/dbconfig-common/dbconfig-common/internal
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv11001/internal
Modified Files:
mysql
Log Message:
bugfixes and a couple enhancements:
* dbconfig-common now defaults to blank passwords implying the
admin wants a random password (this makes automatic installations
even easier) thanks to Tobias Grimm <tobias.grimm@e-tobi.net> for
the inspiration.
* the admin is prompted only once if the app. password is blank. thanks
to tobias for the idea.
* added dependency on pwgen for generating passwords.
* the manpage for dbconfig-generate-include was never built into
the binary. d'oh!
* character encoding fix in the changelog to make lintian happy.
* limit mysql usernames to 16 characters long, as that's a built
in limit.
* the dbc_log functions now always produce output, as it's actually
helpful to see what's going on.
* dbconfig-generate-include has changed behavior. -P/--dbport is now for
port and -m/--mode is for mode (was -P/--perms, but i can't think of
a good name for port otherwise!).
* forget the host/port responses if reconfigured to use a local connection.
otherwise that causes confusion.
* better error notification in the internal mysql code.
* if something goes wrong in the install process, forget that we've
seen the relevant debconf questions (so they will be asked again).
Index: mysql
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/internal/mysql,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mysql 18 Apr 2005 03:48:42 -0000 1.3
+++ mysql 28 Apr 2005 03:11:29 -0000 1.4
@@ -41,14 +41,10 @@
local constat mycnf
constat="bad"
mycnf=`_dbc_generate_mycnf $1`
- mysql --defaults-extra-file="$mycnf" </dev/null && constat=good
+ dbc_error=`mysql --defaults-extra-file="$mycnf" </dev/null 2>&1` && constat=good
rm -f $mycnf
if [ "$constat" = "bad" ]; then
- dbc_error="Error when trying to connect to the mysql
- database. This error can occur if you have no database
- to connect to, or if the password was incorrect. use:
- dpkg-reconfigure -plow packagename to reconfigure."
- dbc_logline "unable to connect to mysql server"
+ dbc_logline="unable to connect to mysql server"
return 1
fi
}
@@ -85,15 +81,21 @@
## including the mysql command itself
##
dbc_mysql_exec_command(){
- local statement l_sqlfile
+ local statement l_sqlfile l_retval l_error
statement=$@
+ l_retval=0
l_sqlfile=`mktemp -t dbconfig-common_sqlfile.XXXXXX`
cat << EOF > $l_sqlfile
$statement
EOF
mycnf=`_dbc_generate_mycnf`
- mysql --defaults-extra-file="$mycnf" $dbc_dbname < $l_sqlfile
+ l_error=`mysql --defaults-extra-file="$mycnf" $dbc_dbname < $l_sqlfile 2>&1`
+ l_retval=$?
rm -f $mycnf $l_sqlfile
+ if [ $l_retval -ne 0 ]; then
+ dbc_error="mysql said: $l_error"
+ return $l_retval
+ fi
}
##
@@ -149,7 +151,6 @@
dbc_mysql_createdb(){
local ret l_dbname
dbc_status=error
- dbc_error=''
_dbc_sanity_check dbname dbadmin mysql || return 1
_dbc_mysql_check_connect || return 1
@@ -170,14 +171,12 @@
dbc_logpart "verifying database $dbc_dbname exists:"
if ! _dbc_mysql_check_database "$dbc_dbname"; then
dbc_logline "failed"
- dbc_error="unable to create database $dbc_dbname."
else
dbc_logline "success"
dbc_status=create
fi
else
dbc_logline "failed"
- dbc_error="unable to create database, mysql exit status $?"
fi
fi
}
@@ -193,7 +192,6 @@
dbc_mysql_dropdb(){
dbc_status=error
- dbc_error=""
_dbc_sanity_check dbname dbadmin mysql || return 1
_dbc_mysql_check_connect || return 1
@@ -206,13 +204,11 @@
dbc_logpart "verifying database $dbc_dbname was dropped:"
if _dbc_mysql_check_database "$dbc_dbname"; then
dbc_logline "failed"
- dbc_error="could not drop database $dbc_dbname"
else
dbc_logline "success"
dbc_status=drop
fi
else
- dbc_error="unable to drop database, mysql exit code $?"
dbc_logline "does not exist"
fi
else
@@ -237,7 +233,6 @@
local l_dballow l_sqlfile l_dbname l_ret
dbc_status=error
- dbc_error=""
_dbc_sanity_check dbuser dbname dbadmin mysql || return 1
_dbc_mysql_check_connect || return 1
@@ -276,14 +271,12 @@
dbc_logline "success"
dbc_logpart "verifying access for $dbc_dbuser@$l_dballow:"
if ! _dbc_mysql_check_user ; then
- dbc_error="unable to grant privileges to user $dbc_dbuser."
dbc_logline "failed"
else
dbc_status=create
dbc_logline "success"
fi
else
- dbc_error="unable to grant privileges to $dbc_dbuser, mysql error $?"
dbc_logline "failed"
fi
fi
@@ -305,7 +298,6 @@
local l_sqlfile l_dballow
dbc_status=error
- dbc_error=""
_dbc_sanity_check dbuser dbname dbadmin mysql || return 1
_dbc_mysql_check_connect || return 1
@@ -336,7 +328,6 @@
dbc_status=drop
dbc_logline "success"
else
- dbc_error="unable to revoke privileges, mysql error $?."
dbc_logline "failed"
fi
rm -f $l_sqlfile