diff options
Diffstat (limited to 'support-files')
-rw-r--r-- | support-files/mariadb.service.in | 1 | ||||
-rw-r--r-- | support-files/mariadb@.service.in | 1 | ||||
-rw-r--r-- | support-files/mysql.server.sh | 31 | ||||
-rw-r--r-- | support-files/mysqld_multi.server.sh | 19 | ||||
-rw-r--r-- | support-files/rpm/plugin-postin.sh | 3 | ||||
-rw-r--r-- | support-files/rpm/server-posttrans.sh | 11 | ||||
-rw-r--r-- | support-files/rpm/server-postun.sh | 9 |
7 files changed, 53 insertions, 22 deletions
diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index ef9fa5c2a22..8d43b6db428 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -17,7 +17,6 @@ Description=MariaDB @VERSION@ database server Documentation=man:mysqld(8) Documentation=https://mariadb.com/kb/en/library/systemd/ After=network.target -After=syslog.target [Install] WantedBy=multi-user.target diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in index 465a0d94c62..a2f5cff0828 100644 --- a/support-files/mariadb@.service.in +++ b/support-files/mariadb@.service.in @@ -22,7 +22,6 @@ Description=MariaDB @VERSION@ database server (multi-instance) Documentation=man:mysqld(8) Documentation=https://mariadb.com/kb/en/library/systemd/ After=network.target -After=syslog.target ConditionPathExists=@sysconf2dir@/my%I.cnf diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 0a81b71171a..e2054a8fb98 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -126,8 +126,9 @@ esac parse_server_arguments() { for arg do + val=`echo "$arg" | sed -e 's/^[^=]*=//'` case "$arg" in - --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` + --basedir=*) basedir="$val" bindir="$basedir/bin" if test -z "$datadir_set"; then datadir="$basedir/data" @@ -141,14 +142,15 @@ parse_server_arguments() { fi libexecdir="$basedir/libexec" ;; - --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` + --datadir=*) datadir="$val" datadir_set=1 ;; --log-basename=*|--hostname=*|--loose-log-basename=*) - mysqld_pid_file_path=`echo "$arg.pid" | sed -e 's/^[^=]*=//'` + mysqld_pid_file_path="$val.pid" ;; - --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --pid-file=*) mysqld_pid_file_path="$val" ;; + --service-startup-timeout=*) service_startup_timeout="$val" ;; + --user=*) user="$val"; ;; esac done } @@ -180,6 +182,12 @@ else test -z "$print_defaults" && print_defaults="my_print_defaults" fi +user='@MYSQLD_USER@' + +su_kill() { + su - $user -s /bin/sh -c "kill $*" >/dev/null 2>&1 +} + # # Read defaults file from 'basedir'. If there is no defaults file there # check if it's in the old (depricated) place (datadir) and read it from there @@ -209,7 +217,7 @@ wait_for_gone () { while test $i -ne $service_startup_timeout ; do - if kill -0 "$pid" 2>/dev/null; then + if su_kill -0 "$pid" ; then : # the server still runs else if test ! -s "$pid_file_path"; then @@ -249,7 +257,7 @@ wait_for_ready () { if $bindir/mysqladmin ping >/dev/null 2>&1; then log_success_msg return 0 - elif kill -0 $! 2>/dev/null ; then + elif kill -0 $! ; then : # mysqld_safe is still running else # mysqld_safe is no longer running, abort the wait loop @@ -318,10 +326,9 @@ case "$mode" in then mysqld_pid=`cat "$mysqld_pid_file_path"` - if (kill -0 $mysqld_pid 2>/dev/null) - then + if su_kill -0 $mysqld_pid ; then echo $echo_n "Shutting down MariaDB" - kill $mysqld_pid + su_kill $mysqld_pid # mysqld should remove the pid file when it exits, so wait for it. wait_for_gone $mysqld_pid "$mysqld_pid_file_path"; return_value=$? else @@ -357,7 +364,7 @@ case "$mode" in 'reload'|'force-reload') if test -s "$mysqld_pid_file_path" ; then read mysqld_pid < "$mysqld_pid_file_path" - kill -HUP $mysqld_pid && log_success_msg "Reloading service MariaDB" + su_kill -HUP $mysqld_pid && log_success_msg "Reloading service MariaDB" touch "$mysqld_pid_file_path" else log_failure_msg "MariaDB PID file could not be found!" @@ -368,7 +375,7 @@ case "$mode" in # First, check to see if pid file exists if test -s "$mysqld_pid_file_path" ; then read mysqld_pid < "$mysqld_pid_file_path" - if kill -0 $mysqld_pid 2>/dev/null ; then + if su_kill -0 $mysqld_pid ; then log_success_msg "MariaDB running ($mysqld_pid)" exit 0 else diff --git a/support-files/mysqld_multi.server.sh b/support-files/mysqld_multi.server.sh index 75908a5db9d..f00c6a56af1 100644 --- a/support-files/mysqld_multi.server.sh +++ b/support-files/mysqld_multi.server.sh @@ -14,8 +14,23 @@ # Version 1.0 # -basedir=/usr/local/mysql -bindir=/usr/local/mysql/bin +### BEGIN INIT INFO +# Provides: mysqld_multi +# Required-Start: $local_fs $network $remote_fs +# Should-Start: ypbind nscd ldap ntpd xntpd +# Required-Stop: $local_fs $network $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start and stop multiple mysql database server daemon instances +# Description: Controls multiple MariaDB database server daemon instances +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +NAME=mysqld_multi +DESC=mysqld_multi + +basedir=/usr +bindir=/usr/bin if test -x $bindir/mysqld_multi then diff --git a/support-files/rpm/plugin-postin.sh b/support-files/rpm/plugin-postin.sh new file mode 100644 index 00000000000..1844de1b4f2 --- /dev/null +++ b/support-files/rpm/plugin-postin.sh @@ -0,0 +1,3 @@ +# request the server restart +mkdir -p %{restart_flag_dir} +echo > %{restart_flag} diff --git a/support-files/rpm/server-posttrans.sh b/support-files/rpm/server-posttrans.sh new file mode 100644 index 00000000000..0d242596185 --- /dev/null +++ b/support-files/rpm/server-posttrans.sh @@ -0,0 +1,11 @@ +if [ -r %{restart_flag} ] ; then + rm %{restart_flag} + if [ -x /usr/bin/systemctl ] ; then + /usr/bin/systemctl daemon-reload > /dev/null 2>&1 + fi + + # only restart the server if it was alredy running + if %{_sysconfdir}/init.d/mysql status > /dev/null 2>&1; then + %{_sysconfdir}/init.d/mysql restart + fi +fi diff --git a/support-files/rpm/server-postun.sh b/support-files/rpm/server-postun.sh index 412c6f4c67b..27e1125b78f 100644 --- a/support-files/rpm/server-postun.sh +++ b/support-files/rpm/server-postun.sh @@ -1,10 +1,7 @@ if [ $1 -ge 1 ]; then - if [ -x %{_sysconfdir}/init.d/mysql ] ; then - # only restart the server if it was alredy running - if %{_sysconfdir}/init.d/mysql status > /dev/null 2>&1; then - %{_sysconfdir}/init.d/mysql restart - fi - fi + # request the server restart + mkdir -p %{restart_flag_dir} + echo > %{restart_flag} fi if [ $1 = 0 ] ; then |