The following code does not match "datadir=/var/lib/mysql" dir=`awk '{ if ( $0 ~ /^datadir[ \t]+=/ ) { print $3 } }' < /etc/mysql/my.cnf` if [ ! -d $dir/mysql ] ; then eerror "You dont appear to have the mysql database installed yet." eerror "Please run /usr/bin/mysql_install_db to have this done..." return 1 fi Reproducible: Always Steps to Reproduce: 1. 2. 3.
Method and I talked about this on IRC, and he came up with the following: awk -F = '{ if ( $0 ~ /^datadir/ ) { sub(/[ \t]/,"",$2); print $2 } }' < /etc/mysql/my.cnf
fine. either that or this will do: my_print_defaults mysqld | grep -- --datadir | sed -e "s|^.*=\(.*\)|\1|" i like the way this mysql-bugs thing is working out. more eyes on these little bugs means they'll get atention quicker. but go for it, you found the fix first ;-)
which of the two solutions would be better? I think the method with piping in the conf file would be better, as under some cases if your conf file contains errors, my_print_defaults won't work. yup, this mysql-bugs works out well. as does php-bugs.
The sed script (#2) looks like it works. I don't think other awk script (#1) takes into consideration the case where there is whitespace before the variable name: [\s]+datadir=/var/lib/mysql
fixed in CVS. Change applied to both mysql4 and mysql3 init scripts. I've put it in as a bugfix, as that is what it really is, so no version bump.
Closing old bugs.