commit: e1420dbafbafbe14f303da3ff96a9ef456e77cc8 Author: Brian Evans <grknight <AT> gentoo <DOT> org> AuthorDate: Wed May 13 01:51:50 2015 +0000 Commit: Brian Evans <grknight <AT> gentoo <DOT> org> CommitDate: Wed May 13 03:15:39 2015 +0000 URL: https://gitweb.gentoo.org/proj/mysql.git/commit/?id=e1420dba
Sync init script from portage; bashism and checkconfig fixes dev-db/mysql-init-scripts/files/init.d-2.0 | 33 ++++++++++++++++++------------ dev-db/mysql-init-scripts/files/init.d-s6 | 31 +++++++++++++++++----------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/dev-db/mysql-init-scripts/files/init.d-2.0 b/dev-db/mysql-init-scripts/files/init.d-2.0 index 5dc99d2..2d05745 100644 --- a/dev-db/mysql-init-scripts/files/init.d-2.0 +++ b/dev-db/mysql-init-scripts/files/init.d-2.0 @@ -1,7 +1,7 @@ #!/sbin/runscript # Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: $ +# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/init.d-2.0,v 1.3 2014/09/23 01:23:27 grknight Exp $ extra_commands="checkconfig" @@ -73,7 +73,7 @@ start() { # find which package is installed to report an error local EROOT=$(portageq envvar EROOT) local DBPKG_P=$(portageq match ${EROOT} $(portageq expand_virtual ${EROOT} virtual/mysql)) - if [[ -z ${DBPKG_P} ]] ; then + if [ -z ${DBPKG_P} ] ; then eerror "You don't appear to have a server package installed yet." else eerror "You don't appear to have the mysql database installed yet." @@ -134,19 +134,26 @@ stop() { } checkconfig() { - local basedir=$(get_config "${MY_CNF}" basedir | tail -n1) - ebegin "Checking mysqld configuration" - - # Suppress output to check the return value - "${basedir}"/sbin/mysqld --help --verbose &> /dev/null - - # If the above command does not return 0, - # then there is an error to echo to the user - if [ $? -ne 0 ] ; then - "${basedir}"/sbin/mysqld --help --verbose > /dev/null + local my_cnf="${MY_CNF:-/etc/${SVCNAME}/my.cnf}" + local basedir=$(get_config "${my_cnf}" basedir | tail -n1) + local svc_name=$(mysql_svcname) + ebegin "Checking mysqld configuration for ${svc_name}" + + if [ ${RC_CMD} = "checkconfig" ] ; then + # We are calling checkconfig specifically. Print warnings regardless. + "${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null + else + # Suppress output to check the return value + "${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null 2>&1 + + # If the above command does not return 0, + # then there is an error to echo to the user + if [ $? -ne 0 ] ; then + "${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null + fi fi - eend $? "MySQL config check failed" + eend $? "${svc_name} config check failed" } # vim: filetype=gentoo-init-d sw=2 ts=2 sts=2 noet: diff --git a/dev-db/mysql-init-scripts/files/init.d-s6 b/dev-db/mysql-init-scripts/files/init.d-s6 index 4c2424f..dfbe7f6 100644 --- a/dev-db/mysql-init-scripts/files/init.d-s6 +++ b/dev-db/mysql-init-scripts/files/init.d-s6 @@ -60,7 +60,7 @@ start_pre() { # find which package is installed to report an error local EROOT=$(portageq envvar EROOT) local DBPKG_P=$(portageq match ${EROOT} $(portageq expand_virtual ${EROOT} virtual/mysql)) - if [[ -z ${DBPKG_P} ]] ; then + if [ -z ${DBPKG_P} ] ; then eerror "You don't appear to have a server package installed yet." else eerror "You don't appear to have the mysql database installed yet." @@ -79,19 +79,26 @@ start_pre() { } checkconfig() { - local basedir=$(get_config "${MY_CNF}" basedir | tail -n1) - ebegin "Checking mysqld configuration" - - # Suppress output to check the return value - "${basedir}"/sbin/mysqld --help --verbose &> /dev/null - - # If the above command does not return 0, - # then there is an error to echo to the user - if [ $? -ne 0 ] ; then - "${basedir}"/sbin/mysqld --help --verbose > /dev/null + local my_cnf="${MY_CNF:-/etc/${SVCNAME}/my.cnf}" + local basedir=$(get_config "${my_cnf}" basedir | tail -n1) + local svc_name=$(mysql_svcname) + ebegin "Checking mysqld configuration for ${svc_name}" + + if [ ${RC_CMD} = "checkconfig" ] ; then + # We are calling checkconfig specifically. Print warnings regardless. + "${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null + else + # Suppress output to check the return value + "${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null 2>&1 + + # If the above command does not return 0, + # then there is an error to echo to the user + if [ $? -ne 0 ] ; then + "${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null + fi fi - eend $? "MySQL config check failed" + eend $? "${svc_name} config check failed" } # vim: filetype=gentoo-init-d sw=2 ts=2 sts=2 noet: