Lines 122-127
Link Here
|
122 |
# conf.d/mysql |
122 |
# conf.d/mysql |
123 |
for my_default in ${my_defaults} ; do |
123 |
for my_default in ${my_defaults} ; do |
124 |
case "${my_default}" in |
124 |
case "${my_default}" in |
|
|
125 |
--chroot=*) |
126 |
[[ -z "${chroot}" ]] && chroot="${my_default#--chroot=}" ;; |
125 |
--basedir=*) |
127 |
--basedir=*) |
126 |
[[ -z "${basedir}" ]] && basedir="${my_default#--basedir=}" ;; |
128 |
[[ -z "${basedir}" ]] && basedir="${my_default#--basedir=}" ;; |
127 |
--datadir=*) |
129 |
--datadir=*) |
Lines 144-150
Link Here
|
144 |
socket="${socket:-"/var/run/mysqld/mysqld${MY_SUFFIX}.sock"}" |
146 |
socket="${socket:-"/var/run/mysqld/mysqld${MY_SUFFIX}.sock"}" |
145 |
unmanagedparams="${unmanagedparams} ${collations}" |
147 |
unmanagedparams="${unmanagedparams} ${collations}" |
146 |
|
148 |
|
147 |
wdebug 3 "chroot dir => ${CHROOT}" |
149 |
wdebug 3 "chroot dir => ${chroot}" |
148 |
wdebug 3 "niceness => ${NICE}" |
150 |
wdebug 3 "niceness => ${NICE}" |
149 |
wdebug 3 "basedir => ${basedir}" |
151 |
wdebug 3 "basedir => ${basedir}" |
150 |
wdebug 3 "datadir => ${datadir}" |
152 |
wdebug 3 "datadir => ${datadir}" |
Lines 177-214
Link Here
|
177 |
return 0 |
179 |
return 0 |
178 |
fi |
180 |
fi |
179 |
|
181 |
|
180 |
if [[ ! -d "${datadir}" ]] ; then |
182 |
if [[ ! -d "${chroot}${datadir}" ]] ; then |
181 |
eerror "MySQL datadir is empty or invalid" |
183 |
eerror "MySQL datadir is empty or invalid" |
182 |
eerror "Please check your my.cnf : ${MY_CNF}" |
184 |
eerror "Please check your my.cnf : ${MY_CNF}" |
183 |
wdebug 4 "<<< checkconfig() KO" |
185 |
wdebug 4 "<<< checkconfig() KO" |
184 |
return 1 |
186 |
return 1 |
185 |
fi |
187 |
fi |
186 |
|
188 |
|
187 |
if [[ ! -d "${datadir}/mysql" ]] ; then |
189 |
if [[ ! -d "${chroot}${datadir}/mysql" ]] ; then |
188 |
eerror "You don't appear to have the mysql database installed yet." |
190 |
eerror "You don't appear to have the mysql database installed yet." |
189 |
eerror "Please run /usr/bin/mysql_install_db to have this done..." |
191 |
eerror "Please run /usr/bin/mysql_install_db to have this done..." |
190 |
wdebug 4 "<<< checkconfig() KO" |
192 |
wdebug 4 "<<< checkconfig() KO" |
191 |
return 1 |
193 |
return 1 |
192 |
fi |
194 |
fi |
193 |
|
195 |
|
194 |
if [[ -f "${pidfile}" ]] ; then |
196 |
if [[ -f "${chroot}${pidfile}" ]] ; then |
195 |
kill -15 $(< ${pidfile}) 2>/dev/null |
197 |
kill -15 $(< ${pidfile}) 2>/dev/null |
196 |
if [[ $? -eq 0 ]] ; then |
198 |
if [[ $? -eq 0 ]] ; then |
197 |
# the process exist, we have a problem |
199 |
# the process exist, we have a problem |
198 |
eerror "\"${pidfile}\" is still present and the process is running." |
200 |
eerror "\"${chroot}${pidfile}\" is still present and the process is running." |
199 |
eerror "Please stop it \"kill $(< ${pidfile})\" maybe ?" |
201 |
eerror "Please stop it \"kill $(< ${chroot}${pidfile})\" maybe ?" |
200 |
wdebug 4 "<<< checkconfig() KO" |
202 |
wdebug 4 "<<< checkconfig() KO" |
201 |
return 1 |
203 |
return 1 |
202 |
else |
204 |
else |
203 |
rm -f "${pidfile}" |
205 |
rm -f "${chroot}${pidfile}" |
204 |
fi |
206 |
fi |
205 |
fi |
207 |
fi |
206 |
|
208 |
|
207 |
if [[ -S "${socket}" ]] ; then |
209 |
if [[ -S "${chroot}${socket}" ]] ; then |
208 |
ewarn "Strange, the socket file already exist in \"${socket}\"" |
210 |
ewarn "Strange, the socket file already exist in \"${chroot}${socket}\"" |
209 |
ewarn "it will be removed now and re-created by the MySQL server" |
211 |
ewarn "it will be removed now and re-created by the MySQL server" |
210 |
ewarn "BUT please make your checks." |
212 |
ewarn "BUT please make your checks." |
211 |
rm -f "${socket}" |
213 |
rm -f "${chroot}${socket}" |
212 |
fi |
214 |
fi |
213 |
|
215 |
|
214 |
wdebug 4 "<<< checkconfig() ok" |
216 |
wdebug 4 "<<< checkconfig() ok" |
Lines 234-239
Link Here
|
234 |
local ssd_thing=1 |
236 |
local ssd_thing=1 |
235 |
local mysqld_thing tmpnice |
237 |
local mysqld_thing tmpnice |
236 |
|
238 |
|
|
|
239 |
# Ensure that LD_PRELOAD is really exported |
240 |
[[ -n ${LD_PRELOAD} ]] && export LD_PRELOAD="${LD_PRELOAD}" |
241 |
|
237 |
ebegin "Starting ${myservice}" |
242 |
ebegin "Starting ${myservice}" |
238 |
# try to start each server |
243 |
# try to start each server |
239 |
for srv in ${serverlist[*]} ; do |
244 |
for srv in ${serverlist[*]} ; do |
Lines 253-267
Link Here
|
253 |
if ! checkconfig "${datadir}" "${pidfile}" "${socket}" ; then |
258 |
if ! checkconfig "${datadir}" "${pidfile}" "${socket}" ; then |
254 |
retstatus=2 ; continue |
259 |
retstatus=2 ; continue |
255 |
fi |
260 |
fi |
256 |
if in_list "${pidfile}" "${pidfilelist}" ; then |
261 |
if in_list "${chroot}${pidfile}" "${pidfilelist}" ; then |
257 |
eerror "Sorry, won't start with same pid-file: ${pidfile}" |
262 |
eerror "Sorry, won't start with same pid-file: ${pidfile}" |
258 |
retstatus=3 ; continue |
263 |
retstatus=3 ; continue |
259 |
fi |
264 |
fi |
260 |
if in_list "${datadir}" "${datadirlist}" ; then |
265 |
if in_list "${chroot}${datadir}" "${datadirlist}" ; then |
261 |
eerror "Sorry, won't start with same datadir: ${datadir}" |
266 |
eerror "Sorry, won't start with same datadir: ${datadir}" |
262 |
retstatus=4 ; continue |
267 |
retstatus=4 ; continue |
263 |
fi |
268 |
fi |
264 |
if in_list "${socket}" "${socketlist}" ; then |
269 |
if in_list "${chroot}${socket}" "${socketlist}" ; then |
265 |
eerror "Sorry, won't start with same socket: ${socket}" |
270 |
eerror "Sorry, won't start with same socket: ${socket}" |
266 |
retstatus=5 ; continue |
271 |
retstatus=5 ; continue |
267 |
fi |
272 |
fi |
Lines 280-286
Link Here
|
280 |
if [[ ${ssd_thing} -eq 1 ]] ; then |
285 |
if [[ ${ssd_thing} -eq 1 ]] ; then |
281 |
tmpnice="${NICE:+"--nicelevel "}${NICE}" |
286 |
tmpnice="${NICE:+"--nicelevel "}${NICE}" |
282 |
start-stop-daemon --quiet ${DEBUG/*/"--verbose"} --start \ |
287 |
start-stop-daemon --quiet ${DEBUG/*/"--verbose"} --start \ |
283 |
--background ${tmpnice} --pidfile ${pidfile} \ |
288 |
--background ${tmpnice} --pidfile ${chroot}${pidfile} \ |
284 |
--exec ${basedir}/sbin/mysqld${MY_SUFFIX} -- ${mysqld_thing} |
289 |
--exec ${basedir}/sbin/mysqld${MY_SUFFIX} -- ${mysqld_thing} |
285 |
retstatus=$? |
290 |
retstatus=$? |
286 |
else |
291 |
else |
Lines 294-313
Link Here
|
294 |
|
299 |
|
295 |
# wait for socket creation |
300 |
# wait for socket creation |
296 |
wdebug 1 |
301 |
wdebug 1 |
297 |
while ! [[ -S "${socket}" || "${STARTUPTIMEOUT}" -lt 1 || "${retstatus}" -ne 0 ]] ; do |
302 |
while ! [[ -S "${chroot}${socket}" || "${STARTUPTIMEOUT}" -lt 1 || "${retstatus}" -ne 0 ]] ; do |
298 |
STARTUPTIMEOUT=$(( STARTUPTIMEOUT - 1 )) |
303 |
STARTUPTIMEOUT=$(( STARTUPTIMEOUT - 1 )) |
299 |
[[ ${DEBUG} -ge 1 ]] && echo -n "${STARTUPTIMEOUT}," |
304 |
[[ ${DEBUG} -ge 1 ]] && echo -n "${STARTUPTIMEOUT}," |
300 |
sleep ${TIMEUNIT} |
305 |
sleep ${TIMEUNIT} |
301 |
done |
306 |
done |
302 |
wdebug 1 "" |
307 |
wdebug 1 "" |
303 |
if [[ ! -S "${socket}" ]] ; then |
308 |
if [[ ! -S "${chroot}${socket}" ]] ; then |
304 |
eerror "MySQL${MY_SUFFIX} NOT started (${retstatus})" |
309 |
eerror "MySQL${MY_SUFFIX} NOT started (${retstatus})" |
305 |
retstatus=1 |
310 |
retstatus=1 |
306 |
else |
311 |
else |
307 |
globretstatus=0 |
312 |
globretstatus=0 |
308 |
pidfilelist="${pidfilelist}${pidfile}," |
313 |
pidfilelist="${pidfilelist}${chroot}${pidfile}," |
309 |
datadirlist="${datadirlist}${datadir}," |
314 |
datadirlist="${datadirlist}${chroot}${datadir}," |
310 |
socketlist="${socketlist}${socket}," |
315 |
socketlist="${socketlist}${chroot}${socket}," |
311 |
echo "${srv_slot}${srv_num:+"_"}${srv_num}=${pidfile}" >> "${MYSQL_GLOB_PID_FILE}" |
316 |
echo "${srv_slot}${srv_num:+"_"}${srv_num}=${pidfile}" >> "${MYSQL_GLOB_PID_FILE}" |
312 |
fi |
317 |
fi |
313 |
done |
318 |
done |
Lines 331-345
Link Here
|
331 |
runwhat=${shutdown_elem%%=*} |
336 |
runwhat=${shutdown_elem%%=*} |
332 |
pidfile=${shutdown_elem#*=} |
337 |
pidfile=${shutdown_elem#*=} |
333 |
timeout=${STOPTIMEOUT:-"120"} |
338 |
timeout=${STOPTIMEOUT:-"120"} |
334 |
PID=$(< "${pidfile}" ) |
339 |
PID=$(< "${chroot}${pidfile}" ) |
335 |
wdebug 3 "runwhat ${runwhat}" |
340 |
wdebug 3 "runwhat ${runwhat}" |
336 |
wdebug 3 "pidfile ${pidfile}" |
341 |
wdebug 3 "pidfile ${chroot}${pidfile}" |
337 |
wdebug 3 "timeout ${timeout}" |
342 |
wdebug 3 "timeout ${timeout}" |
338 |
wdebug 3 "PID ${PID}" |
343 |
wdebug 3 "PID ${PID}" |
339 |
|
344 |
|
340 |
einfo "Stopping mysqld (${runwhat})" |
345 |
einfo "Stopping mysqld (${runwhat})" |
341 |
|
346 |
|
342 |
start-stop-daemon --quiet ${DEBUG/*/"--verbose"} --stop --pidfile "${pidfile}" & |
347 |
start-stop-daemon --quiet ${DEBUG/*/"--verbose"} --stop --pidfile "${chroot}${pidfile}" & |
343 |
wdebug 1 "" |
348 |
wdebug 1 "" |
344 |
while [[ -n "$PID" ]] \ |
349 |
while [[ -n "$PID" ]] \ |
345 |
&& $( ps -Ao pid | grep -q "^ *$PID$" ) \ |
350 |
&& $( ps -Ao pid | grep -q "^ *$PID$" ) \ |