From 7df1bd6b07774c4c64e2ef5fb5fdd11727bcec3d Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Aug 28 2017 21:14:26 +0000 Subject: Support --defaults-group-suffix option in systemd unit file Related: #1400702 --- diff --git a/community-mysql.spec b/community-mysql.spec index f9a9c54..52c3144 100644 --- a/community-mysql.spec +++ b/community-mysql.spec @@ -962,6 +962,8 @@ fi %changelog * Mon Aug 28 2017 Honza Horak - 5.7.19-6 - Add bundled(boost) virtual provide +- Support --defaults-group-suffix option in systemd unit file + Related: #1400702 * Fri Aug 04 2017 Honza Horak - 5.7.19-5 - Allow to use MD5 in FIPS mode diff --git a/mysql-scripts-common.sh b/mysql-scripts-common.sh index 9dab30e..58f0437 100644 --- a/mysql-scripts-common.sh +++ b/mysql-scripts-common.sh @@ -18,13 +18,23 @@ get_mysql_option(){ sections="$1" option_name="$2" default_value="$3" - result=`@bindir@/my_print_defaults $sections | sed -n "s/^--${option_name}=//p" | tail -n 1` + result=`@bindir@/my_print_defaults $my_print_defaults_extra_args $sections | sed -n "s/^--${option_name}=//p" | tail -n 1` if [ -z "$result" ]; then # not found, use default result="${default_value}" fi } +# For the case of running more instances via systemd, scrits that source +# this file can get --default-group-suffix or similar option as the first +# argument. The utility my_print_defaults needs to use it as well, so the +# scripts sourcing this file work with the same options as the daemon. +my_print_defaults_extra_args='' +while echo "$1" | grep -q '^--defaults' ; do + my_print_defaults_extra_args="${my_print_defaults_extra_args} $1" + shift +done + # Defaults here had better match what mysqld_safe will default to # The option values are generally defined on three important places # on the default installation: diff --git a/mysql@.service.in b/mysql@.service.in index 0f2d58a..aad98f7 100644 --- a/mysql@.service.in +++ b/mysql@.service.in @@ -34,15 +34,14 @@ After=network.target Type=forking User=mysql Group=mysql -PIDFile=@PID_FILE_DIR@/@DAEMON_NO_PREFIX@.pid -ExecStartPre=@libexecdir@/mysql-check-socket -ExecStartPre=@libexecdir@/mysql-prepare-db-dir %n +ExecStartPre=@libexecdir@/mysql-check-socket --defaults-group-suffix=.%I +ExecStartPre=@libexecdir@/mysql-prepare-db-dir --defaults-group-suffix=.%I %n # Note: we set --basedir to prevent probes that might trigger SELinux alarms, # per bug #547485 ExecStart=@libexecdir@/mysqld --defaults-group-suffix=.%I --daemonize --basedir=@prefix@ --pid-file=@PID_FILE_DIR@/@DAEMON_NO_PREFIX@.pid -ExecStartPost=@libexecdir@/mysql-check-upgrade -ExecStopPost=@libexecdir@/mysql-wait-stop +ExecStartPost=@libexecdir@/mysql-check-upgrade --defaults-group-suffix=.%I +ExecStopPost=@libexecdir@/mysql-wait-stop --defaults-group-suffix=.%I # Give a reasonable amount of time for the server to start up/shut down TimeoutSec=300