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

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