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

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