128
128
129
129
parse_server_arguments () {
130
130
for arg do
131
+ val=` echo " $arg " | sed -e ' s/^[^=]*=//' `
131
132
case " $arg " in
132
- --basedir=* ) basedir=` echo " $arg " | sed -e ' s/^[^=]*=// ' `
133
+ --basedir=* ) basedir=" $val "
133
134
bindir=" $basedir /bin"
134
135
if test -z " $datadir_set " ; then
135
136
datadir=" $basedir /data"
@@ -143,14 +144,15 @@ parse_server_arguments() {
143
144
fi
144
145
libexecdir=" $basedir /libexec"
145
146
;;
146
- --datadir=* ) datadir=` echo " $arg " | sed -e ' s/^[^=]*=// ' `
147
+ --datadir=* ) datadir=" $val "
147
148
datadir_set=1
148
149
;;
149
150
--log-basename=* |--hostname=* |--loose-log-basename=* )
150
- mysqld_pid_file_path=` echo " $arg .pid" | sed -e ' s/^[^=]*=// ' `
151
+ mysqld_pid_file_path=" $val .pid"
151
152
;;
152
- --pid-file=* ) mysqld_pid_file_path=` echo " $arg " | sed -e ' s/^[^=]*=//' ` ;;
153
- --service-startup-timeout=* ) service_startup_timeout=` echo " $arg " | sed -e ' s/^[^=]*=//' ` ;;
153
+ --pid-file=* ) mysqld_pid_file_path=" $val " ;;
154
+ --service-startup-timeout=* ) service_startup_timeout=" $val " ;;
155
+ --user=* ) user=" $val " ; ;;
154
156
esac
155
157
done
156
158
}
@@ -182,6 +184,12 @@ else
182
184
test -z " $print_defaults " && print_defaults=" my_print_defaults"
183
185
fi
184
186
187
+ user=' @MYSQLD_USER@'
188
+
189
+ su_kill () {
190
+ su - $user -s /bin/sh -c " kill $* " > /dev/null 2>&1
191
+ }
192
+
185
193
#
186
194
# Read defaults file from 'basedir'. If there is no defaults file there
187
195
# check if it's in the old (depricated) place (datadir) and read it from there
@@ -210,7 +218,7 @@ wait_for_gone () {
210
218
211
219
while test $i -ne $service_startup_timeout ; do
212
220
213
- if kill -0 " $pid " 2> /dev/null ; then
221
+ if su_kill -0 " $pid " ; then
214
222
: # the server still runs
215
223
else
216
224
if test ! -s " $pid_file_path " ; then
@@ -250,7 +258,7 @@ wait_for_ready () {
250
258
if $bindir /mysqladmin ping > /dev/null 2>&1 ; then
251
259
log_success_msg
252
260
return 0
253
- elif kill -0 $! 2> /dev/null ; then
261
+ elif kill -0 $! ; then
254
262
: # mysqld_safe is still running
255
263
else
256
264
# mysqld_safe is no longer running, abort the wait loop
@@ -319,10 +327,9 @@ case "$mode" in
319
327
then
320
328
mysqld_pid=` cat " $mysqld_pid_file_path " `
321
329
322
- if (kill -0 $mysqld_pid 2> /dev/null)
323
- then
330
+ if su_kill -0 $mysqld_pid ; then
324
331
echo $echo_n " Shutting down MariaDB"
325
- kill $mysqld_pid
332
+ su_kill $mysqld_pid
326
333
# mysqld should remove the pid file when it exits, so wait for it.
327
334
wait_for_gone $mysqld_pid " $mysqld_pid_file_path " ; return_value=$?
328
335
else
@@ -355,7 +362,7 @@ case "$mode" in
355
362
' reload' |' force-reload' )
356
363
if test -s " $mysqld_pid_file_path " ; then
357
364
read mysqld_pid < " $mysqld_pid_file_path "
358
- kill -HUP $mysqld_pid && log_success_msg " Reloading service MariaDB"
365
+ su_kill -HUP $mysqld_pid && log_success_msg " Reloading service MariaDB"
359
366
touch " $mysqld_pid_file_path "
360
367
else
361
368
log_failure_msg " MariaDB PID file could not be found!"
@@ -366,7 +373,7 @@ case "$mode" in
366
373
# First, check to see if pid file exists
367
374
if test -s " $mysqld_pid_file_path " ; then
368
375
read mysqld_pid < " $mysqld_pid_file_path "
369
- if kill -0 $mysqld_pid 2> /dev/null ; then
376
+ if su_kill -0 $mysqld_pid ; then
370
377
log_success_msg " MariaDB running ($mysqld_pid )"
371
378
exit 0
372
379
else
0 commit comments