#!/sbin/runscript # Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/mysql.rc6,v 1.2 2007/03/04 15:47:03 vivo Exp $ depend() { use dns net localmount netmount nfsmount } get_config() { my_print_defaults --config-file="$1" mysqld | sed -n -e "s/^--$2=//p" } start() { local ebextra= case "${SVCNAME}" in mysql*) ;; *) ebextra="(mysql)" ;; esac ebegin "Starting ${SVCNAME} ${ebextra}" MY_CNF="${MY_CNF:-/etc/${SVCNAME}/my.cnf}" if [ ! -r "${MY_CNF}" ] ; then eerror "Cannot read the configuration file \`${MY_CNF}'" return 1 fi local basedir=$(get_config "${MY_CNF}" basedir) local datadir=$(get_config "${MY_CNF}" datadir) local pidfile=$(get_config "${MY_CNF}" pid-file) local socket=$(get_config "${MY_CNF}" socket) if [ ! -d "${datadir}" ] ; then eerror "MySQL datadir \`${datadir}' is empty or invalid" eerror "Please check your config file \`${MY_CNF}'" return 1 fi if [ ! -d "${datadir}"/mysql ] ; then eerror "You don't appear to have the mysql database installed yet." eerror "Please run /usr/bin/mysql_install_db to have this done..." return 1 fi start-stop-daemon \ --start \ --exec "${basedir}"/sbin/mysqld \ --pidfile "${pidfile}" \ --background \ -- --defaults-file="${MY_CNF}" ${MY_ARGS} local ret=$? if [ ${ret} -ne 0 ] ; then eend ${ret} return ${ret} fi ewaitfile 60 "${socket}" eend $? || return 1 save_options pidfile "${pidfile}" save_options basedir "${basedir}" } stop() { local ebextra= case "${SVCNAME}" in mysql*) ;; *) ebextra="(mysql)" ;; esac ebegin "Stopping ${SVCNAME} ${ebextra}" local pidfile="$(get_options pidfile)" local basedir="$(get_options basedir)" start-stop-daemon \ --stop \ --exec "${basedir}"/sbin/mysqld \ --pidfile "${pidfile}" eend $? }