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

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