Blame SOURCES/mysql-scl-env-check.patch

2aefdf
diff -up mysql-8.0.11/scripts/mysqld_safe.sh.p90 mysql-8.0.11/scripts/mysqld_safe.sh
2aefdf
--- mysql-8.0.11/scripts/mysqld_safe.sh.p90	2018-04-08 08:44:49.000000000 +0200
2aefdf
+++ mysql-8.0.11/scripts/mysqld_safe.sh	2018-06-23 21:28:20.533825845 +0200
2aefdf
@@ -11,6 +11,12 @@
2aefdf
 # mysql.server works by first doing a cd to the base directory and from there
2aefdf
 # executing mysqld_safe
2aefdf
 
2aefdf
+# we want start daemon only inside "scl enable" invocation
2aefdf
+if ! scl_enabled @SCL_NAME@ ; then
2aefdf
+    echo "Use \"scl enable @SCL_NAME@ 'service ...'\" invocation"
2aefdf
+    exit 1
2aefdf
+fi
2aefdf
+
2aefdf
 # Initialize script globals
2aefdf
 KILL_MYSQLD=1;
2aefdf
 MYSQLD=
2aefdf
diff -up mysql-8.0.11/scripts/mysql.init.in.p90 mysql-8.0.11/scripts/mysql.init.in
2aefdf
--- mysql-8.0.11/scripts/mysql.init.in.p90	2018-06-23 21:28:20.531825833 +0200
2aefdf
+++ mysql-8.0.11/scripts/mysql.init.in	2018-06-23 21:28:20.533825845 +0200
2aefdf
@@ -71,8 +71,8 @@ start(){
2aefdf
 	action $"Starting $prog: " /bin/true
2aefdf
 	ret=0
2aefdf
     else
2aefdf
-        @libexecdir@/mysql-check-socket || return 1
2aefdf
-        su - $MYUSER -s /bin/bash -c "@libexecdir@/mysql-prepare-db-dir $MYUSER $MYGROUP" || return 4
2aefdf
+        scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-check-socket || return 1
2aefdf
+        su - $MYUSER -s /bin/bash -c "scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-prepare-db-dir $MYUSER $MYGROUP" || return 4
2aefdf
 
2aefdf
 	# Pass all the options determined above, to ensure consistent behavior.
2aefdf
 	# In many cases mysqld_safe would arrive at the same conclusions anyway
2aefdf
@@ -81,13 +81,13 @@ start(){
2aefdf
 	# and some users might prefer to configure logging to syslog.)
2aefdf
 	# Note: set --basedir to prevent probes that might trigger SELinux
2aefdf
 	# alarms, per bug #547485
2aefdf
-	su - $MYUSER -s /bin/bash -c "$exec   --datadir='$datadir' --socket='$socketfile' \
2aefdf
+	su - $MYUSER -s /bin/bash -c "scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- $exec   --datadir='$datadir' --socket='$socketfile' \
2aefdf
 		--pid-file='$pidfile' \
2aefdf
 		--basedir=@prefix@ --user=$MYUSER" >/dev/null 2>&1 &
2aefdf
 	safe_pid=$!
2aefdf
 
2aefdf
 	# Wait until the daemon is up
2aefdf
-	su - $MYUSER -s /bin/bash -c "@libexecdir@/mysql-wait-ready '$safe_pid'"
2aefdf
+	su - $MYUSER -s /bin/bash -c "scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-wait-ready '$safe_pid'"
2aefdf
 	ret=$?
2aefdf
 
2aefdf
 	if [ $ret -eq 0 ]; then
2aefdf
@@ -154,6 +154,18 @@ condrestart(){
2aefdf
     [ -e $lockfile ] && restart || :
2aefdf
 }
2aefdf
 
2aefdf
+# We have to re-enable SCL environment, because /sbin/service
2aefdf
+# clears almost all environment variables.
2aefdf
+# Since X_SCLS is cleared as well, we lose information about other
2aefdf
+# collections enabled.
2aefdf
+source @SCL_SCRIPTS@/service-environment
2aefdf
+source scl_source enable $@SCL_NAME_UPPER@_SCLS_ENABLED
2aefdf
+
2aefdf
+# we want start daemon only inside "scl enable" invocation
2aefdf
+if ! scl_enabled @SCL_NAME@ ; then
2aefdf
+    echo "Collection @SCL_NAME@ has to be listed in @SCL_SCRIPTS@/service-environment"
2aefdf
+    exit 1
2aefdf
+fi
2aefdf
 
2aefdf
 # See how we were called.
2aefdf
 case "$1" in
2aefdf
diff -up mysql-8.0.11/scripts/mysql.service.in.p90 mysql-8.0.11/scripts/mysql.service.in
2aefdf
--- mysql-8.0.11/scripts/mysql.service.in.p90	2018-06-23 21:28:20.531825833 +0200
2aefdf
+++ mysql-8.0.11/scripts/mysql.service.in	2018-06-23 21:34:19.940881913 +0200
2aefdf
@@ -32,16 +32,23 @@ After=network.target
2aefdf
 
2aefdf
 [Service]
2aefdf
 Type=notify
2aefdf
+NotifyAccess=all
2aefdf
 User=mysql
2aefdf
 Group=mysql
2aefdf
 
2aefdf
-ExecStartPre=@libexecdir@/mysql-check-socket
2aefdf
-ExecStartPre=@libexecdir@/mysql-prepare-db-dir %n
2aefdf
+# Load collections set to enabled for this service
2aefdf
+EnvironmentFile=@SCL_SCRIPTS@/service-environment
2aefdf
+
2aefdf
+# We want to start server only inside "scl enable" invocation
2aefdf
+ExecStartPre=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- /usr/bin/scl_enabled @SCL_NAME@
2aefdf
+
2aefdf
+ExecStartPre=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-check-socket
2aefdf
+ExecStartPre=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-prepare-db-dir %n
2aefdf
 # Note: we set --basedir to prevent probes that might trigger SELinux alarms,
2aefdf
 # per bug #547485
2aefdf
-ExecStart=@libexecdir@/mysqld --basedir=@prefix@
2aefdf
-ExecStartPost=@libexecdir@/mysql-check-upgrade
2aefdf
-ExecStopPost=@libexecdir@/mysql-wait-stop
2aefdf
+ExecStart=@libexecdir@/mysqld-scl-helper enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysqld --basedir=@prefix@
2aefdf
+ExecStartPost=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-check-upgrade
2aefdf
+ExecStopPost=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-wait-stop
2aefdf
 
2aefdf
 # Give a reasonable amount of time for the server to start up/shut down
2aefdf
 TimeoutSec=300
2aefdf
diff -up mysql-8.0.11/scripts/mysql@.service.in.p90 mysql-8.0.11/scripts/mysql@.service.in
2aefdf
--- mysql-8.0.11/scripts/mysql@.service.in.p90	2018-06-23 21:28:20.531825833 +0200
2aefdf
+++ mysql-8.0.11/scripts/mysql@.service.in	2018-06-23 21:34:30.583942800 +0200
2aefdf
@@ -32,16 +32,23 @@ After=network.target
2aefdf
 
2aefdf
 [Service]
2aefdf
 Type=notify
2aefdf
+NotifyAccess=all
2aefdf
 User=mysql
2aefdf
 Group=mysql
2aefdf
 
2aefdf
-ExecStartPre=@libexecdir@/mysql-check-socket --defaults-group-suffix=.%I
2aefdf
-ExecStartPre=@libexecdir@/mysql-prepare-db-dir --defaults-group-suffix=.%I %n
2aefdf
+# Load collections set to enabled for this service
2aefdf
+EnvironmentFile=@SCL_SCRIPTS@/service-environment
2aefdf
+
2aefdf
+# We want to start server only inside "scl enable" invocation
2aefdf
+ExecStartPre=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- /usr/bin/scl_enabled @SCL_NAME@
2aefdf
+
2aefdf
+ExecStartPre=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-check-socket --defaults-group-suffix=.%I
2aefdf
+ExecStartPre=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-prepare-db-dir --defaults-group-suffix=.%I %n
2aefdf
 # Note: we set --basedir to prevent probes that might trigger SELinux alarms,
2aefdf
 # per bug #547485
2aefdf
-ExecStart=@libexecdir@/mysqld --defaults-group-suffix=.%I --basedir=@prefix@
2aefdf
-ExecStartPost=@libexecdir@/mysql-check-upgrade --defaults-group-suffix=.%I
2aefdf
-ExecStopPost=@libexecdir@/mysql-wait-stop --defaults-group-suffix=.%I
2aefdf
+ExecStart=@libexecdir@/mysqld-scl-helper enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysqld --defaults-group-suffix=.%I --basedir=@prefix@
2aefdf
+ExecStartPost=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-check-upgrade --defaults-group-suffix=.%I
2aefdf
+ExecStopPost=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-wait-stop --defaults-group-suffix=.%I
2aefdf
 
2aefdf
 # Give a reasonable amount of time for the server to start up/shut down
2aefdf
 TimeoutSec=300
2aefdf
diff -up mysql-8.0.11/support-files/mysql-log-rotate.sh.p90 mysql-8.0.11/support-files/mysql-log-rotate.sh
2aefdf
--- mysql-8.0.11/support-files/mysql-log-rotate.sh.p90	2018-04-08 08:44:49.000000000 +0200
2aefdf
+++ mysql-8.0.11/support-files/mysql-log-rotate.sh	2018-06-23 21:28:20.533825845 +0200
2aefdf
@@ -51,9 +51,9 @@
2aefdf
     postrotate
2aefdf
 	# just if mysqld is really running
2aefdf
 	if test -x @bindir@/mysqladmin && \
2aefdf
-	   @bindir@/mysqladmin ping &>/dev/null
2aefdf
+	   /usr/bin/scl enable @SCL_NAME@ -- @bindir@/mysqladmin ping &>/dev/null
2aefdf
 	then
2aefdf
-	   @bindir@/mysqladmin flush-logs
2aefdf
+	   /usr/bin/scl enable @SCL_NAME@ -- @bindir@/mysqladmin flush-logs
2aefdf
 	fi
2aefdf
     endscript
2aefdf
 }