--- mysql.rc6-orig 2006-10-25 01:00:37.996021945 -0400 +++ mysql.rc6 2006-10-25 01:00:50.299412386 -0400 @@ -122,6 +122,8 @@ # conf.d/mysql for my_default in ${my_defaults} ; do case "${my_default}" in + --chroot=*) + [[ -z "${chroot}" ]] && chroot="${my_default#--chroot=}" ;; --basedir=*) [[ -z "${basedir}" ]] && basedir="${my_default#--basedir=}" ;; --datadir=*) @@ -144,7 +146,7 @@ socket="${socket:-"/var/run/mysqld/mysqld${MY_SUFFIX}.sock"}" unmanagedparams="${unmanagedparams} ${collations}" - wdebug 3 "chroot dir => ${CHROOT}" + wdebug 3 "chroot dir => ${chroot}" wdebug 3 "niceness => ${NICE}" wdebug 3 "basedir => ${basedir}" wdebug 3 "datadir => ${datadir}" @@ -177,38 +179,38 @@ return 0 fi - if [[ ! -d "${datadir}" ]] ; then + if [[ ! -d "${chroot}${datadir}" ]] ; then eerror "MySQL datadir is empty or invalid" eerror "Please check your my.cnf : ${MY_CNF}" wdebug 4 "<<< checkconfig() KO" return 1 fi - if [[ ! -d "${datadir}/mysql" ]] ; then + if [[ ! -d "${chroot}${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..." wdebug 4 "<<< checkconfig() KO" return 1 fi - if [[ -f "${pidfile}" ]] ; then + if [[ -f "${chroot}${pidfile}" ]] ; then kill -15 $(< ${pidfile}) 2>/dev/null if [[ $? -eq 0 ]] ; then # the process exist, we have a problem - eerror "\"${pidfile}\" is still present and the process is running." - eerror "Please stop it \"kill $(< ${pidfile})\" maybe ?" + eerror "\"${chroot}${pidfile}\" is still present and the process is running." + eerror "Please stop it \"kill $(< ${chroot}${pidfile})\" maybe ?" wdebug 4 "<<< checkconfig() KO" return 1 else - rm -f "${pidfile}" + rm -f "${chroot}${pidfile}" fi fi - if [[ -S "${socket}" ]] ; then - ewarn "Strange, the socket file already exist in \"${socket}\"" + if [[ -S "${chroot}${socket}" ]] ; then + ewarn "Strange, the socket file already exist in \"${chroot}${socket}\"" ewarn "it will be removed now and re-created by the MySQL server" ewarn "BUT please make your checks." - rm -f "${socket}" + rm -f "${chroot}${socket}" fi wdebug 4 "<<< checkconfig() ok" @@ -234,6 +236,9 @@ local ssd_thing=1 local mysqld_thing tmpnice + # Ensure that LD_PRELOAD is really exported + [[ -n ${LD_PRELOAD} ]] && export LD_PRELOAD="${LD_PRELOAD}" + ebegin "Starting ${myservice}" # try to start each server for srv in ${serverlist[*]} ; do @@ -253,15 +258,15 @@ if ! checkconfig "${datadir}" "${pidfile}" "${socket}" ; then retstatus=2 ; continue fi - if in_list "${pidfile}" "${pidfilelist}" ; then + if in_list "${chroot}${pidfile}" "${pidfilelist}" ; then eerror "Sorry, won't start with same pid-file: ${pidfile}" retstatus=3 ; continue fi - if in_list "${datadir}" "${datadirlist}" ; then + if in_list "${chroot}${datadir}" "${datadirlist}" ; then eerror "Sorry, won't start with same datadir: ${datadir}" retstatus=4 ; continue fi - if in_list "${socket}" "${socketlist}" ; then + if in_list "${chroot}${socket}" "${socketlist}" ; then eerror "Sorry, won't start with same socket: ${socket}" retstatus=5 ; continue fi @@ -280,7 +285,7 @@ if [[ ${ssd_thing} -eq 1 ]] ; then tmpnice="${NICE:+"--nicelevel "}${NICE}" start-stop-daemon --quiet ${DEBUG/*/"--verbose"} --start \ - --background ${tmpnice} --pidfile ${pidfile} \ + --background ${tmpnice} --pidfile ${chroot}${pidfile} \ --exec ${basedir}/sbin/mysqld${MY_SUFFIX} -- ${mysqld_thing} retstatus=$? else @@ -294,20 +299,20 @@ # wait for socket creation wdebug 1 - while ! [[ -S "${socket}" || "${STARTUPTIMEOUT}" -lt 1 || "${retstatus}" -ne 0 ]] ; do + while ! [[ -S "${chroot}${socket}" || "${STARTUPTIMEOUT}" -lt 1 || "${retstatus}" -ne 0 ]] ; do STARTUPTIMEOUT=$(( STARTUPTIMEOUT - 1 )) [[ ${DEBUG} -ge 1 ]] && echo -n "${STARTUPTIMEOUT}," sleep ${TIMEUNIT} done wdebug 1 "" - if [[ ! -S "${socket}" ]] ; then + if [[ ! -S "${chroot}${socket}" ]] ; then eerror "MySQL${MY_SUFFIX} NOT started (${retstatus})" retstatus=1 else globretstatus=0 - pidfilelist="${pidfilelist}${pidfile}," - datadirlist="${datadirlist}${datadir}," - socketlist="${socketlist}${socket}," + pidfilelist="${pidfilelist}${chroot}${pidfile}," + datadirlist="${datadirlist}${chroot}${datadir}," + socketlist="${socketlist}${chroot}${socket}," echo "${srv_slot}${srv_num:+"_"}${srv_num}=${pidfile}" >> "${MYSQL_GLOB_PID_FILE}" fi done @@ -331,15 +336,15 @@ runwhat=${shutdown_elem%%=*} pidfile=${shutdown_elem#*=} timeout=${STOPTIMEOUT:-"120"} - PID=$(< "${pidfile}" ) + PID=$(< "${chroot}${pidfile}" ) wdebug 3 "runwhat ${runwhat}" - wdebug 3 "pidfile ${pidfile}" + wdebug 3 "pidfile ${chroot}${pidfile}" wdebug 3 "timeout ${timeout}" wdebug 3 "PID ${PID}" einfo "Stopping mysqld (${runwhat})" - start-stop-daemon --quiet ${DEBUG/*/"--verbose"} --stop --pidfile "${pidfile}" & + start-stop-daemon --quiet ${DEBUG/*/"--verbose"} --stop --pidfile "${chroot}${pidfile}" & wdebug 1 "" while [[ -n "$PID" ]] \ && $( ps -Ao pid | grep -q "^ *$PID$" ) \