From 9bbc3a3742c6ddbc97d72fad428a80baf8505232 Mon Sep 17 00:00:00 2001 From: Sophist <3001893+Sophist-UK@users.noreply.github.com> Date: Sat, 16 Dec 2023 21:03:37 +0000 Subject: [PATCH 1/2] Add support for specifying a .cnf file and a linux user --- support-files/mysql.server.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index ff37f7c62e7e..e87fc4b96540 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -40,11 +40,15 @@ # If you want to affect other MySQL variables, you should make your changes # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. +# Use cnffile if your my.cnf file is somewhere unusual or named +# something other than my.cnf. If you don't use a my.cnf file: # If you change base dir, you must also change datadir. These may get # overwritten by settings in the MySQL configuration files. - +# If you run mysql under a userid other than root, specify it here. +cnffile= basedir= datadir= +user= # Default value, in seconds, afterwhich the script should timeout waiting # for server start. @@ -137,6 +141,7 @@ parse_server_arguments() { ;; --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; esac done } @@ -231,9 +236,14 @@ fi # extra_args="" -if test -r "$basedir/my.cnf" +if test -z "$cnffile" then - extra_args="-e $basedir/my.cnf" + if test -r "$basedir/my.cnf" + then + extra_args="-e $basedir/my.cnf" + fi +else + extra_args="-e $cnffile" fi parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` @@ -251,6 +261,14 @@ else esac fi +# +# Set userid +# +if test -n "$user" +then + user="--user=$user" +fi + case "$mode" in 'start') # Start daemon @@ -263,7 +281,7 @@ case "$mode" in then # Give extra arguments to mysqld with the my.cnf file. This script # may be overwritten at next upgrade. - $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & + $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $user $other_args >/dev/null & wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? # Make lock for RedHat / SuSE From 83682d6deb389b555351e43823c56e26a883f83a Mon Sep 17 00:00:00 2001 From: Sophist <3001893+Sophist-UK@users.noreply.github.com> Date: Sat, 16 Dec 2023 23:22:09 +0000 Subject: [PATCH 2/2] Remove user option as it doesn't work --- support-files/mysql.server.sh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index e87fc4b96540..abbc5d55c1d8 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -44,11 +44,9 @@ # something other than my.cnf. If you don't use a my.cnf file: # If you change base dir, you must also change datadir. These may get # overwritten by settings in the MySQL configuration files. -# If you run mysql under a userid other than root, specify it here. cnffile= basedir= datadir= -user= # Default value, in seconds, afterwhich the script should timeout waiting # for server start. @@ -141,7 +139,6 @@ parse_server_arguments() { ;; --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; esac done } @@ -261,14 +258,6 @@ else esac fi -# -# Set userid -# -if test -n "$user" -then - user="--user=$user" -fi - case "$mode" in 'start') # Start daemon @@ -281,7 +270,7 @@ case "$mode" in then # Give extra arguments to mysqld with the my.cnf file. This script # may be overwritten at next upgrade. - $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $user $other_args >/dev/null & + $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? # Make lock for RedHat / SuSE