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

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