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

80384c
diff -up mysql-5.6.23/scripts/mysqld_safe.sh.scl-env-check mysql-5.6.23/scripts/mysqld_safe.sh
80384c
--- mysql-5.6.23/scripts/mysqld_safe.sh.scl-env-check	2015-01-19 14:48:32.000000000 +0100
80384c
+++ mysql-5.6.23/scripts/mysqld_safe.sh	2015-03-14 21:30:01.256181451 +0100
80384c
@@ -11,6 +11,12 @@
80384c
 # mysql.server works by first doing a cd to the base directory and from there
80384c
 # executing mysqld_safe
80384c
 
80384c
+# we want start daemon only inside "scl enable" invocation
80384c
+if ! scl_enabled @SCL_NAME@ ; then
80384c
+    echo "Use \"scl enable @SCL_NAME@ 'service ...'\" invocation"
80384c
+    exit 1
80384c
+fi
80384c
+
80384c
 # Initialize script globals
80384c
 KILL_MYSQLD=1;
80384c
 MYSQLD=
80384c
diff -up mysql-5.6.23/scripts/mysql.init.in.scl-env-check mysql-5.6.23/scripts/mysql.init.in
80384c
--- mysql-5.6.23/scripts/mysql.init.in.scl-env-check	2015-03-14 21:30:01.255181450 +0100
80384c
+++ mysql-5.6.23/scripts/mysql.init.in	2015-03-14 21:30:01.256181451 +0100
80384c
@@ -154,6 +154,18 @@ condrestart(){
80384c
     [ -e $lockfile ] && restart || :
80384c
 }
80384c
 
80384c
+# We have to re-enable SCL environment, because /sbin/service
80384c
+# clears almost all environment variables.
80384c
+# Since X_SCLS is cleared as well, we lose information about other
80384c
+# collections enabled.
80384c
+source @SCL_SCRIPTS@/service-environment
80384c
+source scl_source enable $@SCL_NAME_UPPER@_SCLS_ENABLED
80384c
+
80384c
+# we want start daemon only inside "scl enable" invocation
80384c
+if ! scl_enabled @SCL_NAME@ ; then
80384c
+    echo "Collection @SCL_NAME@ has to be listed in @SCL_SCRIPTS@/service-environment"
80384c
+    exit 1
80384c
+fi
80384c
 
80384c
 # See how we were called.
80384c
 case "$1" in
80384c
diff -up mysql-5.6.23/scripts/mysql_install_db.sh.scl-env-check mysql-5.6.23/scripts/mysql_install_db.sh
80384c
--- mysql-5.6.23/scripts/mysql_install_db.sh.scl-env-check	2015-03-14 21:30:01.229181430 +0100
80384c
+++ mysql-5.6.23/scripts/mysql_install_db.sh	2015-03-14 21:30:01.256181451 +0100
80384c
@@ -18,6 +18,12 @@
80384c
 #
80384c
 # All unrecognized arguments to this script are passed to mysqld.
80384c
 
80384c
+# we want start daemon only inside "scl enable" invocation
80384c
+if ! scl_enabled @SCL_NAME@ ; then
80384c
+    echo "Use \"scl enable @SCL_NAME@ 'service ...'\" invocation"
80384c
+    exit 1
80384c
+fi
80384c
+
80384c
 basedir=""
80384c
 builddir=""
80384c
 ldata="@localstatedir@"
80384c
@@ -410,13 +416,13 @@ else
80384c
   echo
80384c
   echo "You can try to start the mysqld daemon with:"
80384c
   echo
80384c
-  echo "    shell> $mysqld --skip-grant-tables &"
80384c
+  echo "    shell> su -s /bin/bash - mysql -c 'scl enable @SCL_NAME@ -- $mysqld --skip-grant-tables &"
80384c
   echo
80384c
   echo "and use the command line tool $bindir/mysql"
80384c
   echo "to connect to the mysql database and look at the grant tables:"
80384c
   echo
80384c
-  echo "    shell> $bindir/mysql -u root mysql"
80384c
-  echo "    mysql> show tables"
80384c
+  echo "    shell> su -s /bin/bash - mysql -c 'scl enable @SCL_NAME@ -- $bindir/mysql -u root mysql"
80384c
+  echo "    mysql> show tables;"
80384c
   echo
80384c
   echo "Try 'mysqld --help' if you have problems with paths.  Using --log"
80384c
   echo "gives you a log in $ldata that may be helpful."
80384c
@@ -447,19 +453,15 @@ fi
80384c
 # the screen.
80384c
 if test "$cross_bootstrap" -eq 0 && test -z "$srcdir"
80384c
 then
80384c
-  s_echo
80384c
-  s_echo "To start mysqld at boot time you have to copy"
80384c
-  s_echo "support-files/mysql.server to the right place for your system"
80384c
-
80384c
   echo
80384c
   echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
80384c
   echo "To do so, start the server, then issue the following commands:"
80384c
   echo
80384c
-  echo "$bindir/mysqladmin -u root password 'new-password'"
80384c
-  echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
80384c
+  echo "scl enable @SCL_NAME@ -- $bindir/mysqladmin -u root password 'new-password'"
80384c
+  echo "scl enable @SCL_NAME@ -- $bindir/mysqladmin -u root -h $hostname password 'new-password'"
80384c
   echo
80384c
   echo "Alternatively you can run:"
80384c
-  echo "$bindir/mysql_secure_installation"
80384c
+  echo "scl enable @SCL_NAME@ -- $bindir/mysql_secure_installation"
80384c
   echo
80384c
   echo "which will also give you the option of removing the test"
80384c
   echo "databases and anonymous user created by default.  This is"
80384c
@@ -474,7 +476,8 @@ then
80384c
     echo "cd $basedir ; $bindir/mysqld_safe &"
80384c
     echo
80384c
     echo "You can test the MySQL daemon with mysql-test-run.pl"
80384c
-    echo "cd $basedir/mysql-test ; perl mysql-test-run.pl"
80384c
+    echo "after installing @SCL_NAME@-mysql-test package."
80384c
+    echo "See @prefix@/share/mysql-test/README for instructions."
80384c
   fi
80384c
 
80384c
   echo
80384c
diff -up mysql-5.6.23/scripts/mysql.service.in.scl-env-check mysql-5.6.23/scripts/mysql.service.in
80384c
--- mysql-5.6.23/scripts/mysql.service.in.scl-env-check	2015-03-14 21:30:01.254181449 +0100
80384c
+++ mysql-5.6.23/scripts/mysql.service.in	2015-03-14 21:30:51.460219665 +0100
80384c
@@ -35,14 +35,20 @@ Group=mysql
80384c
 # Execute pre and post scripts as root
80384c
 PermissionsStartOnly=true
80384c
 
80384c
-ExecStartPre=@libexecdir@/mysql-check-socket
80384c
-ExecStartPre=@libexecdir@/mysql-prepare-db-dir %n
80384c
+# Load collections set to enabled for this service
80384c
+EnvironmentFile=@SCL_SCRIPTS@/service-environment
80384c
+
80384c
+# We want to start server only inside "scl enable" invocation
80384c
+ExecStartPre=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- /usr/bin/scl_enabled @SCL_NAME@
80384c
+
80384c
+ExecStartPre=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-check-socket
80384c
+ExecStartPre=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-prepare-db-dir %n
80384c
 # Note: we set --basedir to prevent probes that might trigger SELinux alarms,
80384c
 # per bug #547485
80384c
-ExecStart=@bindir@/mysqld_safe --basedir=@prefix@
80384c
-ExecStartPost=@libexecdir@/mysql-wait-ready $MAINPID
80384c
-ExecStartPost=@libexecdir@/mysql-check-upgrade
80384c
-ExecStopPost=@libexecdir@/mysql-wait-stop
80384c
+ExecStart=@libexecdir@/mysqld_safe-scl-helper enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @bindir@/mysqld_safe --basedir=@prefix@
80384c
+ExecStartPost=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-wait-ready $MAINPID
80384c
+ExecStartPost=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-check-upgrade
80384c
+ExecStopPost=/usr/bin/scl enable $@SCL_NAME_UPPER@_SCLS_ENABLED -- @libexecdir@/mysql-wait-stop
80384c
 
80384c
 # Give a reasonable amount of time for the server to start up/shut down
80384c
 TimeoutSec=300
80384c
diff -up mysql-5.6.23/support-files/mysql-log-rotate.sh.scl-env-check mysql-5.6.23/support-files/mysql-log-rotate.sh
80384c
--- mysql-5.6.23/support-files/mysql-log-rotate.sh.scl-env-check	2015-03-14 21:30:01.219181423 +0100
80384c
+++ mysql-5.6.23/support-files/mysql-log-rotate.sh	2015-03-14 21:30:01.257181452 +0100
80384c
@@ -30,9 +30,9 @@
80384c
 #    postrotate
80384c
 #	# just if mysqld is really running
80384c
 #	if test -x @bindir@/mysqladmin && \
80384c
-#	   @bindir@/mysqladmin ping &>/dev/null
80384c
+#	   /usr/bin/scl enable @SCL_NAME@ -- @bindir@/mysqladmin ping &>/dev/null
80384c
 #	then
80384c
-#	   @bindir@/mysqladmin flush-logs
80384c
+#	   /usr/bin/scl enable @SCL_NAME@ -- @bindir@/mysqladmin flush-logs
80384c
 #	fi
80384c
 #    endscript
80384c
 #}