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