SHA256
1
0
forked from pool/mariadb

Accepting request 313689 from home:scarabeus_iv:branches:server:database

- Update to 10.0.20:
  https://mariadb.com/kb/en/mariadb/mariadb-10020-release-notes/
- Sync the package to git state, redoing initscripts to be more
  robust

OBS-URL: https://build.opensuse.org/request/show/313689
OBS-URL: https://build.opensuse.org/package/show/server:database/mariadb?expand=0&rev=174
This commit is contained in:
Kristyna Streitova 2015-06-25 13:57:47 +00:00 committed by Git OBS Bridge
parent 2b6130dcbe
commit f837494b39
17 changed files with 497 additions and 1570 deletions

View File

@ -45,14 +45,6 @@ following line to your /etc/my.cnf into section [mysqld]:
core-file
Note: this unfortunatelly doesn't work in SUSE Linux 10.1 and older.
On these systems, you need to run safe_mysqld directly under user
mysql:
su - mysql
mysqld_safe --socket=/var/lib/mysql/mysql.sock \
--datadir=/var/lib/mysql --core-file &
The core file will be written to the /var/lib/mysql/ directory. I
suggest setting the kernel variable kernel.core_uses_pid to 1
@ -64,31 +56,19 @@ multiple crashes.
After you got the core file, install the gdb and mysql-debuginfo
packages and run
gdb /usr/sbin/mysqld /var/lib/mysql/core
gdb /usr/sbin/mysqld /var/lib/mysql/<core>
(gdb) bt
Replace mysqld with the mysqld version you used (mysqld, mysqld-max)
and core with the actual name of the coredump.
Replace the <core> with the actual name of the coredump.
3) Trace files
--------------
Start mysqld using following command:
$ MYSQLD_DEBUG=yes rcmysql start
The init script will then start mysqld and add the --core-file,
--log and --debug options for you. The query log will be stored in
/var/lib/mysql/myqld-query.log
and the trace file in
/var/lib/mysql/mysqld.trace
If you don't like the options set by the init script, just put your own
into /etc/my.cnf and the init script will honor them.
The trace file will contain various debug information and function
calls/returns and will become _extremly_ huge after a while, so don't
attach it to bugzilla unless requested.
Add the following line to your /etc/my.cnf into section [mysqld]:
stack-trace
The trace file will be then written to /var/lib/mysql directory.

View File

@ -9,7 +9,7 @@ PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h misibook password 'new-password'
'/usr/bin/mysqladmin' -u root -h <hostname> password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:903fae90258c7b429449752b3cb8cdcc8bfd4ae844e758cf8cb4c7b82cbc997f
size 309
oid sha256:5dd090b9dde89d15eebedd789d3a8a50d6f95a2f1d752b5aa80d505ff25a6833
size 318

View File

@ -1,146 +0,0 @@
%cmake_install benchdir_root=/usr/share/
install -m 644 build/sql/mysqld.sym %buildroot%_libdir/mysql/mysqld.sym
# remove handler socket client
rm -f %buildroot%_libdir/libhsclient*
rm -f %buildroot%_bindir/hsclient*
[ \! -f "%{buildroot}%{_bindir}/mytop" ] || mv %{buildroot}%{_bindir}/mytop %{buildroot}%{_bindir}/%{name}_mytop
rm -f %buildroot%_libdir/mysql/plugin/handlersocket.so
# remove most static libs (FIXME: don't build them at all...)
[ \! -f "%buildroot%_libdir/"libmysqld.a ] || mv "%buildroot%_libdir/"libmysqld.a "%buildroot%_libdir/"libmysqld.static
rm -f %buildroot%_libdir/*.a
[ \! -f "%buildroot%_libdir/"libmysqld.static ] || mv "%buildroot%_libdir/"libmysqld.static "%buildroot%_libdir/"libmysqld.a
rm -f %buildroot%_libdir/mysql/{,plugin}/*.{a,la}
rm -f %buildroot%_libdir/mysql/libndbclient.*
rm -f %buildroot%_libdir/mysql/plugin/debug_key_management.so
rm -f %{buildroot}/usr/share/mysql-test/{mysql-test-run,mtr}
rm -f %{buildroot}/usr/share/mysql/{binary-configure,errmsg-utf8.txt,magic,mysql-log-rotate,mysql*.server}
rm -f %{buildroot}%{_libdir}/mysql/plugin/daemon_example.ini
ln -sf mysql-test-run.pl %{buildroot}/usr/share/mysql-test/mtr
ln -sf mysql-test-run.pl %{buildroot}/usr/share/mysql-test/mysql-test-run
mv %{buildroot}/usr/share/mysql-test/lib/My/SafeProcess/my_safe_process %{buildroot}%{_bindir}
# generate filelist for binaries and their manpages
filelist()
{
echo '%%defattr(-, root, root)'
pushd %buildroot >/dev/null
for i; do
if test -e usr/sbin/"$i"; then
echo /usr/sbin/"$i"
fi
if test -e usr/bin/"$i"; then
echo /usr/bin/"$i"
fi
if test -d usr/share/*/"$i"; then
echo "/`echo usr/share/*/"$i"`"
fi
if test -n "`ls -1 %buildroot$i 2> /dev/null`"; then
echo "$i"
fi
if ls usr/share/man/*/"$i".[1-9]* >/dev/null 2>&1; then
echo "%%doc %_mandir/*/$i.[1-9]*"
fi
done
popd >/dev/null
}
filelist innochecksum my_print_defaults myisam_ftdump myisamchk myisamlog myisampack mysql_fix_extensions mysql_fix_privilege_tables mysql_install_db mysql_secure_installation mysql_upgrade mysqlbug mysqld mysqld_multi mysqld_safe mysqlbinlog mysqldumpslow mysqlmanager mroonga resolve_stack_dump resolveip {m,}aria_chk {m,}aria_dump_log {m,}aria_ftdump {m,}aria_pack {m,}aria_read_log xtstat tokuftdump >mysql.files
filelist mysql mysqladmin mysqlcheck mysqldump mysqlimport mysqlshow mysql_config_editor >mysql-client.files
filelist mysql_config /usr/share/pkgconfig/mariadb.pc >libmysqlclient-devel.files
filelist mysqlslap >mysql-bench.files
filelist mysql_client_test mysql_client_test_embedded mysql_waitpid mysqltest mysqltest_embedded >mysql-test.files
# all binaries that don't need to be in a "default" install (mysql.rpm +
# mysql-client.rpm)
filelist msql2mysql mysql_plugin mysql_convert_table_format mysql_find_rows mysql_setpermission mysql_tzinfo_to_sql mysql_zap mysqlaccess mysqlhotcopy perror replace mysql_embedded %{name}_mytop hsclient %{_bindir}/wsrep* /usr/share/mysql/wsrep_notify >mysql-tools.files
filelist ndbd ndbmtd ndbd_redo_log_reader >mysql-ndb-storage.files
filelist ndb_mgmd >mysql-ndb-management.files
filelist ndb_{config,desc,error_reporter,mgm,print_backup_file,print_schema_file,print_sys_file,restore,select_all,select_count,show_tables,size.pl,test_platform,waiter} >mysql-ndb-tools.files
filelist ndb_{cpcd,delete_all,drop_index,index_stat,print_file,redo_log_reader,drop_table} ndbinfo_select_all memcached >mysql-ndb-extra.files
[ -z "`ls -1 "%buildroot/usr/share/mysql/"*.ini`" ] || echo '/usr/share/mysql/*.ini' >> mysql.files
[ -z "`ls -1 "%buildroot/usr/share/mysql/"*.cnf`" ] || echo '/usr/share/mysql/*.cnf' >> mysql.files
[ \! -f "%buildroot/usr/share/%name"/dictionary.txt ] || echo "/usr/share/%name/dictionary.txt" >> mysql.files
errmsg_list()
{
echo '%%defattr(-, root, root)'
pushd %buildroot >/dev/null
for f in usr/share/%{name}/*; do
if test -e $f/errmsg.sys; then
echo "%%dir /$f"
fi
done
echo /usr/share/%{name}/errmsg-utf8.txt
popd >/dev/null
}
errmsg_list > errormessages.files
### files not installed by make install
# Create directory structure
DOCS=(COPYING README EXCEPTIONS-CLIENT %_sourcedir/README.debug %_sourcedir/README.SUSE plugin/daemon_example/daemon_example.ini)
DOCDIR=%buildroot%_defaultdocdir/%name
install -d -m 755 ${DOCDIR}
install -d -m 755 %buildroot/etc/logrotate.d
install -m 644 build/support-files/mysql-log-rotate %buildroot/etc/logrotate.d/mysql
install -m 660 %{S:14} %buildroot/etc/my.cnf
[ \! -f scripts/mysqlaccess.conf ] || install -m 640 scripts/mysqlaccess.conf %buildroot/etc/mysqlaccess.conf
for i in "${DOCS[@]}"; do
install -m 644 "${i}" "${DOCDIR}" || true
done
install -D -m 755 %_sourcedir/rc.mysql.systemd '%buildroot'/usr/lib/mysql/rcmysql
sed -i 's|@MYSQLVER@|%{version}|' '%buildroot'/usr/lib/mysql/rcmysql
ln -sf service '%buildroot'/usr/sbin/rcmysql
install -D -m 644 %_sourcedir/mysql.service '%buildroot'/usr/lib/systemd/system/mysql.service
sed -i 's|doc/packages/mysql|doc/packages/%{name}|g' '%buildroot'/usr/lib/mysql/rcmysql
rm -rf '%buildroot'/etc/init.d
# SuSEfirewall service description
install -D -m 644 %_sourcedir/mysql.SuSEfirewall2 \
%buildroot/etc/sysconfig/SuSEfirewall2.d/services/mysql
# testsuite
mkdir -p '%buildroot'/usr/share/mysql-test/
install -m 755 suse-test-run '%buildroot'/usr/share/mysql-test/
mkdir '%buildroot'/usr/share/mysql-test/var
# Final fixes
find '%buildroot'/usr/share/mysql-test -name '*.orig' -delete
%fdupes -s '%buildroot'/usr/share/mysql-test
fdupes -q -n -r '%buildroot'/usr/share/mysql-test
dos2unixConversion() {
%{__sed} -i 's/\r//g' "$1"
}
for i in `grep -Rl '\r' '%buildroot'/usr/share/sql-bench`; do
dos2unixConversion "$i"
done
%if ! 0%{preferred} > 0
cat libmysqlclient-devel.files | sed 's|%%doc\ ||' | while read tmp; do
cd '%buildroot'
rm -f ."$tmp"
done
rm -rf '%buildroot'/%_libdir/libmysqld.*
rm -rf '%buildroot'/%_libdir/{*.la,*.so,*.a}
rm -rf '%buildroot'/%_datadir/man/*/mysql_config.1*
rm -rf '%buildroot'/%_includedir
rm -rf '%buildroot'/%_datadir/aclocal
%endif
ln -s mysqlcheck '%buildroot'%_bindir/mysqlrepair
ln -s mysqlcheck '%buildroot'%_bindir/mysqlanalyze
ln -s mysqlcheck '%buildroot'%_bindir/mysqloptimize
if [ -f '%buildroot'/usr/bin/mysqlaccess.conf ]; then
mv '%buildroot'/usr/bin/mysqlaccess.conf '%buildroot'/etc/mysqlaccess.conf
fi
[ \! -f '%buildroot'/etc/mysqlaccess.conf ] || echo '%config(noreplace) %attr(0640, root, mysql) /etc/mysqlaccess.conf' >> mysql-client.files
rm -rf '%buildroot'/etc/my.cnf.d
mkdir -p '%buildroot'/etc/my.cnf.d
bzip2 -cd '%_sourcedir'/configuration-tweaks.tar.bz2 | tar -C '%buildroot'/etc/my.cnf.d -xvf -
[ -z "`ls '%buildroot'/usr/share/info/mysql.info* 2> /dev/null`" ] || rm -f '%buildroot'/usr/share/info/mysql.info*
[ -z "`ls '%buildroot'/usr/share/mysql-test/suite/innodb/t/*.zip`" ] || chmod a-x '%buildroot'/usr/share/mysql-test/suite/innodb/t/*.zip
if [ "`ls '%buildroot'%_libdir/mysql/plugin/dialog*.so 2> /dev/null`" ]; then
echo '%%dir %%_libdir/mysql' >> mysql-client.files
echo '%%dir %%_libdir/mysql/plugin' >> mysql-client.files
echo '%%_libdir/mysql/plugin/dialog*.so' >> mysql-client.files
fi
if [ %{_defaultdocdir} \!= /usr/share/doc ]; then
rm -rf '%buildroot'/usr/share/doc/{mysql,mariadb}*
fi
if [ %{name} \!= mysql ]; then
rm -rf '%buildroot'/usr/share/doc/mysql
fi
if [ %{name} \!= mariadb ]; then
rm -rf '%buildroot'/usr/share/doc/mariadb
fi
rm -f '%buildroot'/usr/share/doc/* 2> /dev/null || true
rm -rf '%buildroot'/usr/share/mysql/{solaris,SELinux}

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2fbf5e5d7d8094691601ece8ae60b941478d73c98a58a960aeebfa021091a132
size 56224123

3
mariadb-10.0.20.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3a4f6963c794977af5d5fd9ec06a337a2ad556b3a287196fddbd2243c1388b7b
size 56241178

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Jun 25 13:50:12 UTC 2015 - tchvatal@suse.com
- Update to 10.0.20:
https://mariadb.com/kb/en/mariadb/mariadb-10020-release-notes/
- Sync the package to git state, redoing initscripts to be more
robust
-------------------------------------------------------------------
Tue Jun 23 13:16:03 UTC 2015 - tchvatal@suse.com

View File

@ -16,13 +16,17 @@
#
### WARNING!!!! ##############################################################
# This package is developed on http://github.com/openSUSE/mysql-packaging/
# Do not change anything here in OBS.
##############################################################################
%define pretty_name MariaDB
%define libname mysqlclient
%define soname 18
%define preferred 01
%define preferred 1
%define builtin_plugins partition,csv,heap,aria,pbxt,myisam,myisammrg,xtradb
%define extra_provides mariadb_100
%define srv_vers 5.6.24
%define with_mandatory_boost 0
# Remove when 13.1 is out of support scope
%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
@ -37,7 +41,7 @@
%define with_cassandra 0
%endif
Name: mariadb
Version: 10.0.19
Version: 10.0.20
Release: 0
Summary: Server part of %{pretty_name}
License: SUSE-GPL-2.0-with-FLOSS-exception
@ -51,15 +55,16 @@ Source5: mysql.SuSEfirewall2
Source7: README.install
Source8: README.SUSE
Source9: mysql-patches.tar.bz2
Source11: install.inc
Source12: series
Source13: configuration-tweaks.tar.bz2
Source14: my.ini
Source15: rc.mysql.sysvinit
Source16: rc.mysql.systemd
Source17: mysql.service
Source15: mysql.service
Source16: mysql.target
Source17: mysql-systemd-helper
Source18: mysql@.service
BuildRequires: bison
BuildRequires: cmake
BuildRequires: dos2unix
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: libaio-devel
@ -73,6 +78,7 @@ BuildRequires: ncurses-devel
BuildRequires: openssl-devel
BuildRequires: pam-devel
BuildRequires: pcre-devel
BuildRequires: pkgconfig
BuildRequires: procps
BuildRequires: pwdutils
BuildRequires: readline-devel
@ -90,19 +96,25 @@ Conflicts: otherproviders(mariadb-server)
Conflicts: otherproviders(mysql)
Conflicts: otherproviders(mysql-debug)
Conflicts: otherproviders(mysql-server)
Provides: mysql-Max = %{srv_vers}
# Compatibility with Fedora/CentOS
Provides: mysql-server = %{srv_vers}
Provides: mariadb-server = %{srv_vers}
Provides: mysql-server = %{version}
Provides: mariadb-server = %{version}
# Compatibility with old version
Provides: %{name}-debug-version = %{srv_vers}
Obsoletes: %{name}-debug-version < %{srv_vers}
Provides: %{name}-debug = %{srv_vers}
Obsoletes: %{name}-debug < %{srv_vers}
Provides: mysql = %{srv_vers}
Provides: mysql-debug = %{srv_vers}
Provides: %{name}-debug-version = %{version}
Obsoletes: %{name}-debug-version < %{version}
Provides: %{name}-debug = %{version}
Obsoletes: %{name}-debug < %{version}
Provides: mysql = %{version}
Provides: mysql-debug = %{version}
Provides: %{extra_provides} = %{version}
Obsoletes: %{extra_provides} < %{version}
Provides: %{extra_provides}-debug-version = %{version}
Obsoletes: %{extra_provides}-debug-version < %{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%{?systemd_requires}
%if 0%{with_mandatory_boost} > 0
BuildRequires: boost-devel >= 1.57.0
%endif
%if 0%{with_oqgraph} > 0 || 0%{with_cassandra} > 0
BuildRequires: boost-devel
%endif
@ -115,14 +127,9 @@ BuildRequires: judy-devel
%if 0%{with_cassandra} > 0
BuildRequires: libthrift-devel
%endif
Provides: %{extra_provides} = %{version}
Obsoletes: %{extra_provides} < %{version}
Provides: %{extra_provides}-debug-version = %{version}
Obsoletes: %{extra_provides}-debug-version < %{version}
%if 0%{?preferred} > 0
Obsoletes: mysql-Max < %{srv_vers}
Obsoletes: mysql < %{srv_vers}
Obsoletes: mysql-debug < %{srv_vers}
Obsoletes: mysql < %{version}
Obsoletes: mysql-debug < %{version}
%endif
%description
@ -137,8 +144,8 @@ This package only contains the server-side programs.
Summary: %{pretty_name} development header files and libraries
Group: Development/Libraries/C and C++
Requires: glibc-devel
Requires: libmysqlclient_r%{soname} = %{version}
Requires: libmysqlclient%{soname} = %{version}
Requires: libmysqlclient_r%{soname} = %{version}
Requires: openssl-devel
Requires: zlib-devel
@ -193,11 +200,11 @@ Requires: %{name}-errormessages = %{version}
Requires: lib%{libname}%{soname}
Requires(pre): pwdutils
Conflicts: otherproviders(mysql-client)
Provides: mysql-client = %{srv_vers}
Provides: mysql-client = %{version}
Provides: %{extra_provides}-client = %{version}
Obsoletes: %{extra_provides}-client < %{version}
%if 0%{?preferred} > 0
Obsoletes: mysql-client < %{srv_vers}
Obsoletes: mysql-client < %{version}
%endif
%description client
@ -217,11 +224,11 @@ Group: Productivity/Databases/Tools
Requires: %{name}-client
Requires: perl-DBD-mysql
Conflicts: otherproviders(mysql-bench)
Provides: mysql-bench = %{srv_vers}
Provides: mysql-bench = %{version}
Provides: %{extra_provides}-bench = %{version}
Obsoletes: %{extra_provides}-bench < %{version}
%if 0%{?preferred} > 0
Obsoletes: mysql-bench < %{srv_vers}
Obsoletes: mysql-bench < %{version}
%endif
%description bench
@ -239,11 +246,11 @@ Requires: %{name}-client = %{version}
Requires: %{name}-tools = %{version}
Requires: perl-DBD-mysql
Conflicts: otherproviders(mysql-test)
Provides: mysql-test = %{srv_vers}
Provides: mysql-test = %{version}
Provides: %{extra_provides}-test = %{version}
Obsoletes: %{extra_provides}-test < %{version}
%if 0%{?preferred} > 0
Obsoletes: mysql-test < %{srv_vers}
Obsoletes: mysql-test < %{version}
%endif
%description test
@ -259,11 +266,11 @@ Conflicts: otherproviders(mysql-tools)
# make sure this package is installed when updating from 10.2 and older
Provides: mysql-client:%{_bindir}/perror
Provides: mysql:%{_bindir}/mysqlhotcopy
Provides: mysql-tools = %{srv_vers}
Provides: mysql-tools = %{version}
Provides: %{extra_provides}-tools = %{version}
Obsoletes: %{extra_provides}-tools < %{version}
%if 0%{?preferred} > 0
Obsoletes: mysql-tools < %{srv_vers}
Obsoletes: mysql-tools < %{version}
%endif
%description tools
@ -352,73 +359,246 @@ make %{?_smp_mflags}
nm --numeric-sort sql/mysqld > sql/mysqld.sym
%install
%{expand:%(cat %{_sourcedir}/install.inc)}
# Helper function to generate filelist for binaries and their manpages
filelist()
{
echo '%%defattr(-, root, root)'
pushd %{buildroot} >/dev/null
for i; do
if test -e usr/sbin/"$i"; then
echo %{_sbindir}/"$i"
fi
if test -e usr/bin/"$i"; then
echo %{_bindir}/"$i"
fi
if test -d usr/share/*/"$i"; then
echo "/`echo usr/share/*/"$i"`"
fi
if test -n "`ls -1 %{buildroot}$i 2> /dev/null`"; then
echo "$i"
fi
if ls usr/share/man/*/"$i".[1-9]* >/dev/null 2>&1; then
echo "%{_mandir}/*/$i.[1-9]*"
fi
done
popd >/dev/null
}
# Install the package itself
%cmake_install benchdir_root=%{_datadir}/
# Logrotate file should be named as the package
if [ ! -e %{buildroot}%{_sysconfdir}/logrotate.d/mysql ]; then
# some versions do not install it automatically
install -D -m 644 build/support-files/mysql-log-rotate %{buildroot}%{_sysconfdir}/logrotate.d/mysql
fi
mv %{buildroot}%{_sysconfdir}/logrotate.d/mysql %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
# Create log directory with the expected perms of mysql
install -d -m 700 %{buildroot}%{_localstatedir}/log/mysql/
# Symbols from build to go into libdir
install -m 644 build/sql/mysqld.sym %{buildroot}%{_libdir}/mysql/mysqld.sym
# Remove handler socket client
rm -f %{buildroot}%{_libdir}/mysql/plugin/handlersocket.so
# Remove debug management for keys Mariadb 101+
rm -f %{buildroot}%{_libdir}/mysql/plugin/debug_key_management.so
# Remove most static libs (FIXME: don't build them at all...)
[ \! -f "%{buildroot}%{_libdir}/"libmysqld.a ] || mv "%{buildroot}%{_libdir}/"libmysqld.a "%{buildroot}%{_libdir}/"libmysqld.static
rm -f %{buildroot}%{_libdir}/*.a
[ \! -f "%{buildroot}%{_libdir}/"libmysqld.static ] || mv "%{buildroot}%{_libdir}/"libmysqld.static "%{buildroot}%{_libdir}/"libmysqld.a
# Rename mytop to have name prefixed with the implementation
[ \! -f "%{buildroot}%{_bindir}/mytop" ] || mv %{buildroot}%{_bindir}/mytop %{buildroot}%{_bindir}/%{name}_mytop
# Remove few configure/examples
rm -f %{buildroot}%{_datadir}/mysql/{binary-configure,errmsg-utf8.txt,magic,mysql-log-rotate,mysql*.server}
rm -f %{buildroot}%{_libdir}/mysql/plugin/daemon_example.ini
mv %{buildroot}%{_datadir}/mysql-test/lib/My/SafeProcess/my_safe_process %{buildroot}%{_bindir}
# Generate various filelists
filelist innochecksum my_print_defaults myisam_ftdump myisamchk myisamlog myisampack mysql_fix_extensions mysql_fix_privilege_tables mysql_install_db mysql_secure_installation mysql_upgrade mysqlbug mysqld mysqld_multi mysqld_safe mysqlbinlog mysqldumpslow mysqlmanager mroonga resolve_stack_dump resolveip {m,}aria_chk {m,}aria_dump_log {m,}aria_ftdump {m,}aria_pack {m,}aria_read_log xtstat tokuft_logprint tokuftdump >mysql.files
filelist mysql mysqladmin mysqlcheck mysqldump mysqlimport mysqlshow mysql_config_editor >mysql-client.files
# The dialog stuff is mariadb only
if [ "`ls '%buildroot'%_libdir/mysql/plugin/dialog*.so 2> /dev/null`" ]; then
echo '%%dir %%_libdir/mysql' >> mysql-client.files
echo '%%dir %%_libdir/mysql/plugin' >> mysql-client.files
echo '%%_libdir/mysql/plugin/dialog*.so' >> mysql-client.files
fi
# Mysql has configuration file in _bindir
if [ -f scripts/mysqlaccess.conf ] ; then
install -m 640 scripts/mysqlaccess.conf %{buildroot}%{_sysconfdir}/mysqlaccess.conf
rm -f %{buildroot}%{_bindir}/mysqlaccess.conf
echo '%config(noreplace) %attr(0640, root, mysql) %{_sysconfdir}/mysqlaccess.conf' >> mysql-client.files
fi
filelist mysql_config %{_datadir}/pkgconfig/mariadb.pc >libmysqlclient-devel.files
filelist mysqlslap >mysql-bench.files
filelist mysql_client_test mysql_client_test_embedded mysql_waitpid mysqltest mysqltest_embedded >mysql-test.files
filelist msql2mysql mysql_plugin mysql_convert_table_format mysql_find_rows mysql_setpermission mysql_tzinfo_to_sql mysql_zap mysqlaccess mysqlhotcopy perror replace mysql_embedded %{name}_mytop hsclient %{_bindir}/wsrep* %{_datadir}/mysql/wsrep_notify >mysql-tools.files
filelist ndbd ndbmtd ndbd_redo_log_reader >mysql-ndb-storage.files
filelist ndb_mgmd >mysql-ndb-management.files
filelist ndb_{config,desc,error_reporter,mgm,print_backup_file,print_schema_file,print_sys_file,restore,select_all,select_count,show_tables,size.pl,test_platform,waiter} >mysql-ndb-tools.files
filelist ndb_{cpcd,delete_all,drop_index,index_stat,print_file,redo_log_reader,drop_table} ndbinfo_select_all memcached >mysql-ndb-extra.files
# All configuration files
echo '%{_datadir}/mysql/*.cnf' >> mysql.files
# Mysql-community server has dictionary file in datadir
if [ -f "%{buildroot}%{_datadir}/%{name}"/dictionary.txt ]; then
echo "%{_datadir}/%{name}/dictionary.txt" >> mysql.files
fi
# Special errormessages approach
echo '%%defattr(-, root, root)' > %{_builddir}/errormessages.files
pushd %{buildroot} >/dev/null
for f in usr/share/%{name}/*; do
if test -e $f/errmsg.sys; then
echo "%%dir /$f" >> %{_builddir}/errormessages.files
fi
done
echo %{_datadir}/%{name}/errmsg-utf8.txt >> %{_builddir}/errormessages.files
popd >/dev/null
mv %{_builddir}/errormessages.files errormessages.files
### files not installed by make install
# Some of the documentation we need to have installed
DOCS=(COPYING README EXCEPTIONS-CLIENT %{_sourcedir}/README.debug %{_sourcedir}/README.SUSE plugin/daemon_example/daemon_example.ini)
DOCDIR=%{buildroot}%{_defaultdocdir}/%{name}
install -d -m 755 ${DOCDIR}
for i in "${DOCS[@]}"; do
install -m 644 "${i}" "${DOCDIR}" || true
done
# Default configuration file
install -m 660 %{SOURCE14} %{buildroot}%{_sysconfdir}/my.cnf
# Systemd/initscript
install -D -m 755 %{_sourcedir}/mysql-systemd-helper '%{buildroot}'%{_libexecdir}/mysql/mysql-systemd-helper
sed -i 's|@MYSQLVER@|%{version}|' '%{buildroot}'%{_libexecdir}/mysql/mysql-systemd-helper
ln -sf service '%{buildroot}'%{_sbindir}/rcmysql
install -D -m 644 %{_sourcedir}/mysql.service '%{buildroot}'%{_libexecdir}/systemd/system/mysql.service
install -D -m 644 %{_sourcedir}/mysql@.service '%{buildroot}'%{_libexecdir}/systemd/system/mysql@.service
install -D -m 644 %{_sourcedir}/mysql.target '%{buildroot}'%{_libexecdir}/systemd/system/mysql.target
ln -s mysql@.service '%{buildroot}'%{_libexecdir}/systemd/system/mysql@default.service
rm -rf '%{buildroot}'%{_sysconfdir}/init.d
# SuSEfirewall service description
install -D -m 644 %{_sourcedir}/mysql.SuSEfirewall2 %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/mysql
# testsuite
install -d -m 755 '%{buildroot}'%{_datadir}/mysql-test/
install -m 755 suse-test-run '%{buildroot}'%{_datadir}/mysql-test/
mkdir '%{buildroot}'%{_datadir}/mysql-test/var
# Final fixes
find '%{buildroot}'%{_datadir}/mysql-test -name '*.orig' -delete
%fdupes -s '%{buildroot}'%{_datadir}/mysql-test
fdupes -q -n -r '%{buildroot}'%{_datadir}/mysql-test
for i in `grep -Rl '\r' '%{buildroot}'%{_datadir}/sql-bench`; do
dos2unix "$i"
done
# If not preffered simply reduce main develpackage to NULL
%if ! 0%{preferred} > 0
cat libmysqlclient-devel.files | sed 's|%%doc\ ||' | while read tmp; do
cd '%{buildroot}'
rm -f ."$tmp"
done
rm -rf '%{buildroot}'/%{_libdir}/libmysqld.*
rm -rf '%{buildroot}'/%{_libdir}/{*.so,*.a}
rm -rf '%{buildroot}'/%{_mandir}/*/mysql_config.1*
rm -rf '%{buildroot}'/%{_includedir}
rm -rf '%{buildroot}'/%{_datadir}/aclocal
%endif
# Compat with old scripts
ln -s mysqlcheck '%{buildroot}'%{_bindir}/mysqlrepair
ln -s mysqlcheck '%{buildroot}'%{_bindir}/mysqlanalyze
ln -s mysqlcheck '%{buildroot}'%{_bindir}/mysqloptimize
# Use our configuration stuff instead of upstream one
rm -rf '%{buildroot}'%{_sysconfdir}/my.cnf.d
install -d -m 755 '%{buildroot}'%{_sysconfdir}/my.cnf.d
bzip2 -cd '%{_sourcedir}'/configuration-tweaks.tar.bz2 | tar -C '%{buildroot}'%{_sysconfdir}/my.cnf.d -xvf -
# Documentation that was copied to wrong folder
rm -f '%{buildroot}'%{_datadir}/doc/* 2> /dev/null || true
# Unwanted packaged stuff
rm -rf '%{buildroot}'%{_datadir}/mysql/{solaris,SELinux}
# client does not require server and needs the user too
%pre client
getent group mysql >/dev/null || groupadd -r mysql
getent passwd mysql >/dev/null || useradd -r -o -g mysql -u 60 -c "MySQL database admin" \
-s /bin/false -d %{_localstatedir}/lib/mysql mysql
usermod -g mysql -s /bin/false mysql
exit 0
%pre
%{_sbindir}/groupadd -r mysql >/dev/null 2>/dev/null || :
%{_sbindir}/useradd -r -o -g mysql -u 60 -c "MySQL database admin" \
-s /bin/false -d %{_localstatedir}/lib/mysql mysql 2> /dev/null || :
%{_sbindir}/usermod -g mysql -s /bin/false mysql 2> /dev/null || :
%service_add_pre mysql.service
getent group mysql >/dev/null || groupadd -r mysql
getent passwd mysql >/dev/null || useradd -r -o -g mysql -u 60 -c "MySQL database admin" \
-s /bin/false -d %{_localstatedir}/lib/mysql mysql
usermod -g mysql -s /bin/false mysql
%pre client
%{_sbindir}/groupadd -r mysql >/dev/null 2>/dev/null || :
%{_sbindir}/useradd -r -o -g mysql -u 60 -c "MySQL database admin" \
-s /bin/false -d %{_localstatedir}/lib/mysql mysql 2> /dev/null || :
%{_sbindir}/usermod -g mysql -s /bin/false mysql 2> /dev/null || :
%service_add_pre mysql.service mysql@.service mysql.target mysql@default.service
%post
%service_add_post mysql.service
%service_add_post mysql.service mysql@.service mysql.target mysql@default.service
#######################################################################
# preun and posttran takes care of restart #
#######################################################################
%preun
[ $1 = 1 ] || %{_sbindir}/rcmysql stop || true
%posttrans
rm -f %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}
# SLE11 Migration support
for in in protected tmp; do
rmdir %{_localstatedir}/lib/mysql/.$i 2>/dev/null || :
rmdir "$datadir"/.$i 2>/dev/null || :
done
# During package rename, there might be config file move
# Remove any messages that could've been in place about the upgrade
rm -f %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}
# During package rename (migration maria->mysql-community-server),
# there might be config file move and we get rpmsave that we should keep
if [ -f %{_sysconfdir}/my.cnf.rpmsave ]; then
mv %{_sysconfdir}/my.cnf{,.rpmnew}
mv %{_sysconfdir}/my.cnf{.rpmsave,}
cat >> %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release} << EOF
mv %{_sysconfdir}/my.cnf{,.rpmnew}
mv %{_sysconfdir}/my.cnf{.rpmsave,}
cat >> %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release} << EOF
WARNING: %{_sysconfdir}/my.cnf.rpmsave file detected!
This probably means that you are upgrading from different variant of MySQL.
Your original configuration file was restored. If it is not a case, you can
find your original %{_sysconfdir}/my.cnf as %{_sysconfdir}/my.cnf.rpmnew
This probably means that you are migrating from different variant of MySQL.
Your configuration was left intact and you can see the new configuration in
%{_sysconfdir}/my.cnf.rpmnew
EOF
fi
fi
# warn on first run
if [ -x %{_bindir}/my_print_defaults ]; then
datadir="`%{_bindir}/my_print_defaults mysqld mysql_server | sed -n 's|--datadir=||p'`"
fi
datadir="`%{_bindir}/my_print_defaults mysqld mysql_server | sed -n 's|--datadir=||p'`"
[ -n "$datadir" ] || datadir="%{_localstatedir}/lib/mysql"
if [ -d "$datadir/mysql" ]; then
touch "$datadir/.run-mysql_upgrade"
touch "$datadir/.run-mysql_upgrade"
fi
for in in protected tmp; do
rmdir "$datadir"/.$i 2>/dev/null || :
done
if [ \! -f "$datadir/mysql_upgrade_info" ]; then
cat >> %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release} << EOF
if [ $1 -eq 1 ]; then
cat >> %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release} << EOF
%(cat %{_sourcedir}/README.install)
EOF
fi
else
MYSQLVER="`echo %{version} | sed 's|\.[0-9]\+$||'`"
if [ -f "$datadir/mysql_upgrade_info" ] && \
[ -z "`grep "^$MYSQLVER" "$datadir/mysql_upgrade_info" 2> /dev/null`" ]; then
cat >> %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release} << EOF
MYSQLVER="`echo %{version} | sed 's|\.[0-9]\+$||'`"
if [ -f "$datadir/mysql_upgrade_info" ] && \
[ -z "`grep "^$MYSQLVER" "$datadir/mysql_upgrade_info" 2> /dev/null`" ]; then
cat >> %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release} << EOF
WARNING: You are upgrading from different stable version of MySQL!
@ -427,18 +607,15 @@ Before you do that make sure you have up to date backup of your data. It
should be mainly in $datadir directory.
EOF
fi
fi
fi
# start mysql again if it should run - migration from old setup
if [ -d %{_rundir}/mysql/restart ]; then
[ -x %{_sbindir}/rcmysql ] && %{_sbindir}/rcmysql start
# Might not be there, so ignoring errors
rmdir %{_rundir}/mysql/restart 2> /dev/null
fi
exit 0
#######################################################################
# Various ldconfig post scripts #
#######################################################################
%preun
%service_del_preun mysql.service mysql@.service mysql.target mysql@default.service
%postun
%service_del_postun mysql.service mysql@.service mysql.target mysql@default.service
%post -n lib%{libname}%{soname} -p /sbin/ldconfig
@ -449,34 +626,25 @@ fi
%postun -n lib%{libname}_r%{soname} -p /sbin/ldconfig
%if 0%{preferred} > 0
%post -n libmysqld18 -p /sbin/ldconfig
%post -n libmysqld%{soname} -p /sbin/ldconfig
%postun -n libmysqld18 -p /sbin/ldconfig
%postun -n libmysqld%{soname} -p /sbin/ldconfig
%endif
%postun
if [ $1 = 0 ]; then
%insserv_cleanup
rm -f "%{_localstatedir}/lib/systemd/migrated/mysql.service"
if [ -x %{_bindir}/systemctl ]; then
%{_bindir}/systemctl daemon-reload >/dev/null 2>&1 || :
fi
fi
#######################################################################
# Files section #
#######################################################################
%files -f mysql.files
%defattr(-, root, root)
%config(noreplace) %attr(0640, root, mysql) %{_sysconfdir}/my.cnf
%dir %attr(0750, root, mysql) %{_sysconfdir}/my.cnf.d
%config(noreplace) %attr(0640, root, mysql) %{_sysconfdir}/my.cnf.d/*
%config %{_sysconfdir}/logrotate.d/mysql
%config %{_sysconfdir}/logrotate.d/%{name}
%doc %{_defaultdocdir}/%{name}
%dir %{_libexecdir}/mysql
%{_libexecdir}/mysql/rcmysql
%dir %attr(0700, mysql, mysql) %{_localstatedir}/log/mysql
%{_libexecdir}/mysql/mysql-systemd-helper
%{_libexecdir}/systemd/system/mysql.service
%{_libexecdir}/systemd/system/mysql@.service
%{_libexecdir}/systemd/system/mysql@default.service
%{_libexecdir}/systemd/system/mysql.target
%{_sbindir}/rcmysql
%dir %{_datadir}/%{name}
%dir %{_datadir}/mysql
@ -487,6 +655,7 @@ fi
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/mysql
%dir %{_libdir}/mysql/plugin
%{_libdir}/mysql/plugin/[!d]*.so
%ghost %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}
%files errormessages -f errormessages.files
%defattr(-, root, root)
@ -509,7 +678,7 @@ fi
%{_libdir}/libmysqld.a
%{_libdir}/libmysqld.so
%files -n libmysqld18
%files -n libmysqld%{soname}
%defattr(-,root,root)
%{_libdir}/libmysqld.so.*
%endif

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d4b9a9a1f6f6a3f231d3a1e70e8a40226e4a9221f20453a043f3ece8996b9b37
size 16106
oid sha256:6f2c9f60cb22caabaa021816b0359a38e0914779e7d2d405218972ce42dc9f50
size 16496

175
mysql-systemd-helper Normal file
View File

@ -0,0 +1,175 @@
#!/bin/bash
die() {
echo "$1"
exit 1
}
# Read options from config file
read_config() {
# Initial settings
MYSQLVER="$(echo @MYSQLVER@ | sed 's|\.[0-9]\+$||')"
mysql_daemon_user=mysql
mysql_daemon_group=mysql
if [[ -z "$INSTANCE" || "x$INSTANCE" = "xdefault" ]]; then
datadir=/var/lib/mysql
socket="/var/run/mysql/mysql.sock"
else
datadir="/var/lib/mysql-$INSTANCE"
socket="/var/run/mysql/mysql.${INSTANCE}.sock"
fi
# Read options - important for multi setup
if [[ -n "$INSTANCE" && "x$INSTANCE" != "xdefault" ]]; then
opts="$(/usr/bin/my_print_defaults --mysqld mysqld_multi "$INSTANCE")"
tmp_opts="$opts"
else
opts="$(/usr/bin/my_print_defaults --mysqld)"
tmp_opts="$opts"
fi
# Update local variables according to the settings from config
for arg in $tmp_opts; do
case "$arg" in
--basedir=*) basedir="$(echo "$arg" | sed -e 's/^[^=]*=//')" ;;
--socket=*) socket="$(echo "$arg" | sed -e 's/^[^=]*=//')" ;;
--datadir=*) datadir="$(echo "$arg" | sed -e 's/^[^=]*=//')" ;;
--user=*) mysql_daemon_user="$(echo "$arg" | sed -e 's/^[^=]*=//')" ;;
--group=*) mysql_daemon_group="$(echo "$arg" | sed -e 's/^[^=]*=//')" ;;
esac
done
}
# Create new empty database if needed
mysql_install() {
if [[ ! -d "$datadir/mysql" ]]; then
echo "Creating MySQL privilege database... "
mysql_install_db --user="$mysql_daemon_user" --datadir="$datadir" || \
die "Creation of MySQL databse in $datadir failed"
echo -n "$MYSQLVER" > "$datadir"/mysql_upgrade_info
fi
}
# Upgrade database if needed
mysql_upgrade() {
# Run mysql_upgrade on every package install/upgrade. Not always
# necessary, but doesn't do any harm.
if [[ -f "$datadir/.run-mysql_upgrade" ]]; then
echo "Checking MySQL configuration for obsolete options..."
sed -i -e 's|^\([[:blank:]]*\)skip-locking|\1skip-external-locking|' \
-e 's|^\([[:blank:]]*skip-federated\)|#\1|' /etc/my.cnf
# instead of running mysqld --bootstrap, which wouldn't allow
# us to run mysql_upgrade, we start a full-featured server with
# --skip-grant-tables and restict access to it by unix
# permissions of the named socket
echo "Trying to run upgrade of MySQL databases..."
# Check whether upgrade process is not already running
protected="$(cat "/var/run/mysql/protecteddir.$INSTANCE" 2> /dev/null)"
if [[ -n "$protected" && -d "$protected" ]]; then
pid="$(cat "$protected/mysqld.pid" 2> /dev/null)"
if [[ "$pid" && -d "/proc/$pid" ]] &&
[[ $(readlink "/proc/$pid/exe" | grep -q "mysql") ]]; then
die "Another upgrade in already in progress!"
else
echo "Stale files from previous upgrade detected, cleaned them up"
rm -rf "$protected"
rm -f "/var/run/mysql/protecteddir.$INSTANCE"
fi
fi
protected="$(mktemp -d -p /var/tmp mysql-protected.XXXXXX | tee "/var/run/mysql/protecteddir.$INSTANCE")"
[ -n "$protected" ] || die "Can't create a tmp dir '$protected'"
# Create a secure tmp dir
chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$protected" || die "Failed to set group/user to '$protected'"
chmod 0700 "$protected" || die "Failed to set permissions to '$protected'"
# Run protected MySQL accessible only though socket in our directory
echo "Running protected MySQL... "
/usr/sbin/mysqld \
--user="$mysql_daemon_user" --group="$mysql_daemon_group" \
$opts \
--skip-networking \
--skip-grant-tables \
--log-error="$protected/log_upgrade_run" \
--socket="$protected/mysql.sock" \
--pid-file="$protected/mysqld.pid" &
mysql_wait "$protected/mysql.sock" || die "MySQL didn't start, can't continue"
# Run upgrade itself
echo "Running upgrade itself..."
echo "It will do some chek first and report all errors and tries to correct them"
echo
if /usr/bin/mysql_upgrade --no-defaults --force --socket="$protected/mysql.sock"; then
echo "Everything upgraded successfully"
up_ok=""
rm -f "$datadir/.run-mysql_upgrade"
[[ $(grep -q "^$MYSQLVER" "$datadir/mysql_upgrade_info" 2> /dev/null) ]] || \
echo -n "$MYSQLVER" > "$datadir/mysql_upgrade_info"
else
echo "Upgrade failed"
up_ok="false"
fi
# Shut down MySQL
echo "Shuting down protected MySQL"
kill "$(cat "$protected/mysqld.pid")"
for i in {1..30}; do
/usr/bin/mysqladmin --socket="$protected/mysql.sock" ping > /dev/null 2>&1 || break
done
/usr/bin/mysqladmin --socket="$protected/mysql.sock" ping > /dev/null 2>&1 && kill -9 "$(cat "$protected/mysqld.pid")"
# Cleanup
echo "Final cleanup"
rm -rf "$protected" "/var/run/mysql/protecteddir.$INSTANCE"
[[ -z "$up_ok" ]] || die "Something failed during upgrade, please check logs"
fi
}
mysql_wait() {
[[ -z "$1" ]] || socket="$1"
echo "Waiting for MySQL to start"
for i in {1..60}; do
/usr/bin/mysqladmin --socket="$socket" ping > /dev/null 2>&1 && break
sleep 1
done
if /usr/bin/mysqladmin --socket="$socket" ping > /dev/null 2>&1; then
echo "MySQL is alive"
return 0
else
echo "MySQL is still dead"
return 1
fi
}
mysql_start() {
/usr/sbin/mysqld --user="$mysql_daemon_user" --group="$mysql_daemon_group" $opts
}
# We rely on output in english at some points
LC_ALL=C
INSTANCE="$2"
read_config
mkdir -p /var/run/mysql
chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" /var/run/mysql
case "$1" in
install)
mysql_install ;;
upgrade)
mysql_upgrade ;;
start)
mysql_start ;;
wait)
mysql_wait ;;
*)
echo "Supported commands are:"
echo " install - creates empty database if needed"
echo " upgrade - tries to migrate data to newer version if needed"
echo " start - tries to start instance"
echo " wait - waits till instance is pingable"
echo "All commands can take extra argument which is group from 'mysqld_multi' you want to work with"
;;
esac

View File

@ -1,12 +1,16 @@
[Unit]
Description=MySQL server
Wants=basic.target
After=basic.target network.target
Conflicts=mysql.target mysql@default.service
After=basic.target network.target syslog.target
[Service]
Type=forking
ExecStart=/usr/lib/mysql/rcmysql start
ExecStop=/usr/lib/mysql/rcmysql stop
Restart=on-abnormal
Type=simple
ExecStartPre=/usr/lib/mysql/mysql-systemd-helper install default
ExecStartPre=/usr/lib/mysql/mysql-systemd-helper upgrade default
ExecStart=/usr/lib/mysql/mysql-systemd-helper start default
ExecStartPost=/usr/lib/mysql/mysql-systemd-helper wait default
[Install]
WantedBy=multi-user.target

2
mysql.target Normal file
View File

@ -0,0 +1,2 @@
[Unit]
Description=MySQL target allowing to control multi setup

16
mysql@.service Normal file
View File

@ -0,0 +1,16 @@
[Unit]
Description=MySQL server - %I instance
Wants=basic.target
PartOf=mysql.target
After=basic.target network.target syslog.target
[Service]
Restart=on-abnormal
Type=simple
ExecStartPre=/usr/lib/mysql/mysql-systemd-helper install %i
ExecStartPre=/usr/lib/mysql/mysql-systemd-helper upgrade %i
ExecStart=/usr/lib/mysql/mysql-systemd-helper start %i
ExecStartPost=/usr/lib/mysql/mysql-systemd-helper wait %i
[Install]
WantedBy=multi-user.target

View File

@ -1,668 +0,0 @@
#!/bin/bash
# Copyright (c) 1995-2014 SuSE Linux AG Nuernberg, Germany.
#
# Author: Lenz Grimmer
# Maintainer: Michal Hrusecky <mhrusecky@suse.cz>
#
# mysqld_multi extension added by Richard Bos, 2008
#
# /etc/init.d/mysql
#
# and its symbolic link
#
# /usr/sbin/rcmysql
#
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 3 5
# Default-Stop:
# Short-Description: Start the MySQL database server
# Description: Start the MySQL database server
### END INIT INFO
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
_rc_status_ret=0
_rc_status=$_rc_status_ret
_rc_status_all=$_rc_status
rc_check ()
{
_rc_status_ret=$?
test "$_rc_status_ret" || _rc_status_ret=0
test 0$_rc_status_ret -eq 0 || _rc_status=$_rc_status_ret
test 0$_rc_status -eq 0 || _rc_status_all=$_rc_status
return 0$_rc_status_ret
}
rc_status ()
{
rc_check
_rc_status_ret=$_rc_status
if [ "$1" ]; then
case "$1" in
-v|-v[1-9]|-v[1-9][0-9])
case "$_rc_status" in
0) echo "Everything is Ok" ;; # success
*) echo "Something went wrong" ;; # failed
esac
# reset _rc_status to 0 after verbose case
_rc_status=0 ;;
-r) rc_reset ;;
*) echo "rc_status: Usage: [-v[<num>] [-r]]" 1>&2 ; return 0 ;;
esac
fi
return $_rc_status_ret
}
rc_failed ()
{
rc_reset
case "$1" in
[0-7]) _rc_status=$1 ;;
"") _rc_status=1
esac
rc_check
return $_rc_status
}
rc_exit ()
{
exit $_rc_status_all
}
rc_reset ()
{
_rc_status=0
_rc_status_all=0
rc_check
return 0
}
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
# Check for the location of initscript
if [ "`echo "$0" | grep "^\."`" ] || [ "`echo "$0" | grep "^[^/].*/"`" ]; then
MYSELF="`pwd`/$0"
else
MYSELF="$0"
fi
parse_arguments() {
for arg do
case "$arg" in
--basedir=*) basedir="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--datadir=*) datadir="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--pid-file=*) pid_file="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--socket=*) socket="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--log-error=*) log_error="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--user=*) mysql_daemon_user="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--group=*) mysql_daemon_group="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
esac
done
}
wait_for_socket()
{
local i
for((i=0; i<150; i++)); do
sleep 0.2
test -S $1 && i='' && break
done
test -z "$i" || return 1
return 0
}
# Don't run killproc -TERM, as it could send a SIGKILL as well, possibly
# resulting in database corruption. Run kill -TERM manually instead, wait
# approximately 300 seconds and fail if mysql doesn't respond. This will at
# least prevent the SIGKILL when doing 'rcmysql stop' manually. During system
# shutdown, we are out of luck...
# See https://bugzilla.novell.com/show_bug.cgi?id=223209
kill_mysql ()
{
local pid exe test_pid_file
if [ "$1" ]; then
test_pid_file="$1"
else
test_pid_file="$pid_file"
fi
test -e "$test_pid_file" || return 7 # not running
pid=`cat "$test_pid_file"` || return 4 # insufficient privileges
if ! test -e /proc/version; then
mount -n -t proc proc /proc
test -e /proc/version || return 100
fi
test -L "/proc/$pid/exe" || return 7
exe=`readlink "/proc/$pid/exe"` || return 4
test "`echo "$exe" | grep "^$MYSQLD"`" || return 7
kill -STOP "$pid"
kill -TERM "$pid" || return 4 # suboptimal
kill -CONT "$pid"
for i in `seq 3000`; do
# mysqld removes its pid file
test -e "$test_pid_file" || return 0
LC_ALL=C sleep 0.1
done
test -e "$test_pid_file" || return 0
return 1
}
# Helper function which can end with any status
set_return_value() {
return $1
}
# Checks for obsolete database
check_obsolete() {
# check for ISAM tables
tables="`find "$datadir" -name '*.ISM' 2> /dev/null | sed "s@$datadir/*@@; s@.ISM@@; s@/@.@;"`"
if test "$tables" ; then
echo
echo "Some tables still use ISAM format, which is NO LONGER SUPPORTED"
echo "since mysql 5.0. To use these tables, you would need to open them"
echo "from an older mysql server and convert to something better (eg. MyISAM)."
echo
echo "Tables using ISAM are: "
echo " $tables "
echo
fi
# check for bdb tables
tables="`find "$datadir" -name '*.db' 2> /dev/null | sed "s@$datadir/*@@; s@.db@@; s@/@.@;"`"
if test -n "$tables" ; then
echo
echo "Some tables still use BerkeleyDB format, which is NO LONGER SUPPORTED"
echo "since mysql 5.1. To use these tables, you would need to open them"
echo "from an older mysql server and convert to something better (eg. MyISAM)."
echo
echo "Tables using BerkeleyDB are: "
echo " $tables "
echo
fi
}
# Check if we want to run multiple instances.
[[ "`cat /etc/my.cnf | sed -n 's|^[[:blank:]]*\[mysqld[0-9]\+\]|yes|p'`" ]] && MYSQLD_MULTI=yes
# This was old way how to specify this, left for backward compatibility.
[[ -f /etc/sysconfig/mysql ]] && . /etc/sysconfig/mysql
if [[ "$MYSQLD_MULTI" == "yes" ]]; then
[[ -x /usr/bin/mysqld_multi ]] || {
echo -n "MySQL: /usr/bin/mysqld_multi not found"
rc_failed 5; rc_status -v; rc_exit;
}
case "$1" in
start)
# FIXME:
# We assume a fresh install if the directory $datadir/mysql
# does not exist and create the privilege database
# if ! test -d $datadir/mysql; then
# echo -n "Creating MySQL privilege database... "
# mysql_install_db --user=$mysql_daemon_user --datadir=$datadir || {
# rc_failed; rc_status -v; rc_exit
# }
# fi
echo -n "Starting service multi MySQL "
mysqld_multi start
for((i=0; i<150; i++)); do
sleep 0.2
[ "`mysqld_multi report | grep 'is not running'`" ] || break
done
if [ "`mysqld_multi report | grep 'is not running'`" ]; then
echo "Failed to start all instances"
mysqld_multi report
rc_failed; rc_status -v; rc_exit
fi
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down service multi MySQL "
mysqld_multi stop
for((i=0; i<150; i++)); do
sleep 0.2
[ "`mysqld_multi report | grep 'is running'`" ] || break
done
if [ "`mysqld_multi report | grep 'is running'`" ]; then
echo "Failed to stop all instances"
mysqld_multi report
rc_failed; rc_status -v; rc_exit
fi
# Remember status and be verbose
rc_status -v
;;
try-restart)
## Stop the service and if this succeeds (i.e. the
## service was running before), start it again.
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
"$MYSELF" status >/dev/null && "$MYSELF" restart
# Remember status and be quiet
rc_status
;;
restart|force-reload)
echo "Restarting service multi MySQL "
"$MYSELF" stop
"$MYSELF" start
rc_status
;;
reload)
echo -n "Reloading service multi MySQL "
mysqld_multi reload
rc_status -v
;;
status)
STATUS=$(mysqld_multi report)
echo -n "$STATUS"
# Set the status for rc_status
echo "$STATUS" | grep -q "is running"
rc_status -v
;;
*)
echo "Usage: $MYSELF {start|stop|status|reload|restart|try-restart|force-reload}"
exit 1
;;
esac
else
# Test, if mysqld or mysql-max actually exist
unset MYSQLD
# use mysqld-debug only if explicitly requested (TODO: sysconfig variable?)
if test "$MYSQLD_DEBUG" = yes -a -x /usr/sbin/mysqld
then
MYSQLD=/usr/sbin/mysqld
elif test -x /usr/sbin/mysqld-max
then
MYSQLD=/usr/sbin/mysqld-max
elif test -x /usr/sbin/mysqld
then
MYSQLD=/usr/sbin/mysqld
fi
test "$MYSQLD" || {
echo -n "Nor /usr/sbin/mysqld nor /usr/sbin/mysqld-max exists";
rc_failed 5; rc_status -v; rc_exit;
}
# The following section has been taken from
# the original MySQL init script
# Note: If you want to change these variables, you'll make your life easier
# if you do so in /etc/my.cnf, which is preserved during upgrades
basedir=/usr
datadir=/var/lib/mysql
mysql_daemon_user=mysql
mysql_daemon_group=mysql
pid_file=/var/run/mysql/mysqld.pid
socket=/var/run/mysql/mysql.sock
print_defaults=/usr/bin/my_print_defaults
log_error=/var/log/mysql/mysqld.log
mode=$1 # start or stop
log_base="`echo "$log_error" | sed 's|\.log$||'`"
[ "$log_base" \!= "$log_error" ] || log_base="/var/log/mysql/mysql"
log_upgrade="${log_base}-upgrade.log"
log_upgrade_run="${log_base}-upgrade-run.log"
log_query="${log_base}-query.log"
parse_arguments `$print_defaults $defaults mysqld mysql_server`
mkdir -m 755 -p /var/run/mysql
chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" /var/run/mysql
export TEMPDIR="`cat /var/run/mysql/tmpdir 2> /dev/null`"
# Safeguard (relative paths, core dumps..)
cd "$basedir"
case "$1" in
start)
# exit gracefully, if we are already running
"$MYSELF" status >/dev/null && echo -n "Starting service MySQL " && \
rc_status -v && rc_exit
# prepare tmp dir
unset TMPDIR
if [ "$TEMPDIR" ] && [ -d "$TEMPDIR" ] && \
[ "`ls -ld "$TEMPDIR" | grep "^drwx------[\\.\+]\?[[:blank:]]\+[0-9]\+[[:blank:]]\+$mysql_daemon_user[[:blank:]]\+$mysql_daemon_group[[:blank:]]\+.*"`" ]; then
rm -rf "$TEMPDIR"
fi
TEMPDIR="`mktemp -d -p /var/tmp mysql.XXXXXX | tee /var/run/mysql/tmpdir`"
[ -z "$TEMPDIR" ] || chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$TEMPDIR"
[ "`ls -ld "$TEMPDIR" | grep "^drwx------[\\.\+]\?[[:blank:]]\+[0-9]\+[[:blank:]]\+$mysql_daemon_user[[:blank:]]\+$mysql_daemon_group[[:blank:]]\+.*"`" ] || {
echo "Can't create secure $TEMPDIR"
rc_failed; rc_status -v; rc_exit;
}
# Test, if safe_mysqld actually exists
SAFE_MYSQLD=/usr/bin/mysqld_safe
test -x $SAFE_MYSQLD || {
echo "$SAFE_MYSQLD does not exist ";
rc_failed 5; rc_status -v; rc_exit;
}
debug_flags=""
if test "$MYSQLD_DEBUG" = yes; then
# add --log, --core-file and --debug
# but only if not already set in my.cnf
if ! $print_defaults mysqld | \
grep -q -e '--log$' -e '--log[[:blank:]=]'
then
debug_flags="--log=${log_query}"
fi
if ! $print_defaults mysqld | grep -q -e '^--debug\>' &&
test "$MYSQLD" = /usr/sbin/mysqld-debug
then
debug_flags="$debug_flags --debug=d:t:F:L:o,$datadir/mysqld.trace"
fi
if ! $print_defaults mysqld | grep -q -e '^--core-file\>'
then
debug_flags="$debug_flags --core-file"
fi
fi
# Creating parent directories for logs
for i in "$log_upgrade" "$log_query" "$log_error"; do
if [ "${i:0:1}" == "/" ]; then
log_dir="`dirname "$i"`"
if [ \! -d "$log_dir" ]; then
mkdir -p "$log_dir"
fi
chmod 770 "$log_dir"
chown -R --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$log_dir"
else
echo "Relative path \"$i\" for log found, skipping handling."
echo "Trusting sysadmin that he prepared everything and knows what to do."
echo "You've been warned, you are on your own with logs!"
fi
done
MYSQLVER="`echo @MYSQLVER@ | sed 's|\.[0-9]\+$||'`"
# We assume a fresh install if the directory $datadir/mysql
# does not exist and create the privilege database
if ! test -d "$datadir/mysql"; then
echo "Creating MySQL privilege database... "
mysql_install_db --user="$mysql_daemon_user" --datadir="$datadir" ||{
rc_failed; rc_status -v; rc_exit
}
echo -n "$MYSQLVER" > "$datadir"/mysql_upgrade_info
fi
check_obsolete
# Run mysql_upgrade on every package install/upgrade. Not always
# necessary, but doesn't do any harm. On big upgrade, require
# user confirmation.
if [ -f "$datadir/.run-mysql_upgrade" ]; then
echo > "$log_upgrade"
echo "`LANG="" date` - upgrading MySQL..." >> "$log_upgrade"
echo >> "$log_upgrade"
echo "Will update MySQL now, if you encounter any problems, please read following file:" | tee -a "$log_upgrade"
echo " /usr/share/doc/packages/mysql/README.SUSE" | tee -a "$log_upgrade"
sed -i -e 's|^\([[:blank:]]*\)skip-locking|\1skip-external-locking|' \
-e 's|^\([[:blank:]]*skip-federated\)|#\1|' /etc/my.cnf
[ -d /etc/mysql ] || \
sed -i 's|^\([[:blank:]]*!includedir\ /etc/mysql[[:blank:]]*\)$|#\1|' /etc/my.cnf
# Check logs for inconsistencies
SRCLOGS=""
ALL_SRCLOGS=""
for i in "$log_error" /var/lib/mysql/mysqld.log \
/var/log/mysqld.log ; do
if test -f "$i"; then
SRCLOGS="$i"
ALL_SRCLOGS="${ALL_SRCLOGS} ${i}"
fi
done
if [ "${ALL_SRCLOGS}" \!= " ${SRCLOGS}" ]; then
echo "Log files inconsistency, please merge following files manually:"
echo $ALL_SRCLOGS | sed 's|[[:blank:]]\+|\n|' | sed 's|^|\t|'
else
if [ "$SRCLOGS" ]; then
[ "$SRCLOGS" = "$log_error" ] || mv "$SRCLOGS" "$log_error"
fi
fi
check_obsolete >> "$log_upgrade"
# instead of running mysqld --bootstrap, which wouldn't allow
# us to run mysql_upgrade, we start a full-featured server with
# --skip-grant-tables and restict access to it by unix
# permissions of the named socket
protected="`cat /var/run/mysql/protecteddir 2> /dev/null`"
if [ -d "$protected" ]; then
pid="`cat "$protected/mysqld.pid" 2> /dev/null`"
if [ "$pid" ] && [ -d "/proc/$pid" ] &&
[ "`readlink "/proc/$pid/exe" | grep "mysql"`" ]; then
echo "Can't update as another updating process is currently running" | tee -a "$log_upgrade"
echo "Please check process $pid and terminate it before restarting MySQL" | tee -a "$log_upgrade"
touch /var/lib/mysql/.run-mysql_upgrade
rc_failed; rc_status -v; rc_exit;
else
rm -rf "$protected"
fi
fi
protected="`mktemp -d -p /var/tmp mysql-protected.XXXXXX | tee /var/run/mysql/protecteddir`"
export TMPDIR="$TEMPDIR"
# Run upgrade, double check
# We need to restart mysql every time as programs
# reloads privileges tables, so we can get lock out
for cmd in "/usr/bin/mysql_upgrade" \
"/usr/bin/mysql_upgrade"; do
[ -z "$protected" ] || chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$protected"
[ "`ls -ld "$protected" | grep "^drwx------[\\.\+]\?[[:blank:]]\+[0-9]\+[[:blank:]]\+$mysql_daemon_user[[:blank:]]\+$mysql_daemon_group[[:blank:]]\+.*"`" ] || {
echo "Can't create secure $protected" | tee -a "$log_upgrade"
touch /var/lib/mysql/.run-mysql_upgrade
rc_failed; rc_status -v; rc_exit;
}
echo "Running protected MySQL... " | tee -a "$log_upgrade"
$MYSQLD \
$debug_flags \
--skip-networking \
--skip-grant-tables \
--datadir="$datadir" \
--user="$mysql_daemon_user" \
--log-error="$log_upgrade_run" \
--socket="$protected/mysql.sock" \
--pid-file="$protected/mysqld.pid" \
--group="$mysql_daemon_group" &>/dev/null &
wait_for_socket "$protected/mysql.sock" || {
echo "error: $protected/mysql.sock file didn't appeared... " | tee -a "$log_upgrade"
echo " Try checking \"$log_upgrade_run\"... " | tee -a "$log_upgrade"
touch /var/lib/mysql/.run-mysql_upgrade
rc_failed; rc_status -v; rc_exit;
}
if [ "`grep "Upgrading MySQL..." "$log_upgrade"`" ]; then
echo "Problems should be fixed now."
echo "Rechecking whether everything is Ok... " | tee -a "$log_upgrade"
LANG=C $cmd --no-defaults --force \
--socket="$protected/mysql.sock" | \
sed -e 's|^|\ \ \ |' | \
tee -a "$log_upgrade"
else
echo "Upgrading MySQL... " | tee -a "$log_upgrade"
LANG=C $cmd --no-defaults --force \
--socket="$protected/mysql.sock" | \
sed -e 's|^|\ \ \ |' \
-e 's|error|info|' \
-e 's|\(Table\ upgrade\ required.\).*|\1|' | \
tee -a "$log_upgrade"
fi
[ "$PIPESTATUS" -ne 0 ] && {
rc_failed; rc_status -v;
kill_mysql "$protected/mysqld.pid"
rc_exit; }
kill_mysql "$protected/mysqld.pid" || {
echo "error: Can't stop protected MySQL... " | tee -a "$log_upgrade"
rc_failed; rc_status -v;
kill_mysql "$protected/mysqld.pid"
rc_exit; }
# Everything went fine
if [ -z "`grep REPAIR "$log_upgrade"`" ] && \
[ -z "`grep "Table\ upgrade\ required" "$log_upgrade"`" ]; then
break
fi
done # end of upgrade
rm -rf "$protected"
# Fix ownerships and permissions for $datadir
chmod 750 "$datadir"
chown -R --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$datadir"
rm -f /var/adm/update-messages/mysql-*
[ "`grep "^$MYSQLVER" "$datadir/mysql_upgrade_info" 2> /dev/null`" ] || \
echo -n "@MYSQLVER@" > "$datadir/mysql_upgrade_info"
rm -f /var/lib/mysql/.run-mysql_upgrade
rm -f /var/lib/mysql/.force_upgrade
rm -f "$datadir"/{update-stamp-*,mysql/stamp-4.1} # used in the past
MYSQLVERSION="`mysqld --version 2> /dev/null | sed -n 's|mysqld[[:blank:]]\+Ver[[:blank:]]\+\([^[:blank:]]\+\)[[:blank:]].*|\1|p'`"
[ -z "$MYSQLVERSION" ] || echo "$MYSQLVERSION" > "$datadir"/mysql_upgrade_info
chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$log_upgrade"
chmod 640 "$log_upgrade"
fi
export TMPDIR="$TEMPDIR"
echo -n "Starting service MySQL "
$SAFE_MYSQLD \
--mysqld=${MYSQLD#/usr/sbin/} \
$debug_flags \
--user="$mysql_daemon_user" \
--pid-file="$pid_file" \
--socket="$socket" \
--datadir="$datadir" &>/dev/null &
wait_for_socket "$socket" || {
# let's not treat this as a fatal error
echo "warning: $socket didn't appear within 30 seconds"
}
chmod a+r "$pid_file"
# Rmember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down service MySQL "
kill_mysql
if [ "$TEMPDIR" ] && [ -d "$TEMPDIR" ] && \
[ "`ls -ld "$TEMPDIR" | grep "^drwx------[\\.\+]\?[[:blank:]]\+[0-9]\+[[:blank:]]\+$mysql_daemon_user[[:blank:]]\+$mysql_daemon_group[[:blank:]]\+.*"`" ]; then
rm -rf "$TEMPDIR"
fi
# Remember status and be verbose
rc_status -v
;;
try-restart)
## Stop the service and if this succeeds (i.e. the
## service was running before), start it again.
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
"$MYSELF" status >/dev/null && "$MYSELF" restart
# Remember status and be quiet
rc_status
;;
restart|force-reload)
echo "Restarting service MySQL "
"$MYSELF" stop
"$MYSELF" start
rc_status
;;
reload)
echo -n "Reloading service MySQL "
kill -HUP "`cat "$pid_file"`"
touch "$pid_file"
rc_status -v
;;
check|status)
echo -n "Checking for service MySQL: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values,
# but it checks for running binary first and only
# if it doesn't find running process with proper
# name it checks pidfile. So we can't use it because
# akonadi runs it's own database.
# checkproc -p $pid_file $MYSQLD
if [ -f "$pid_file" ]; then
if ! [ -e /proc/version ]; then
mount -n -t proc proc /proc
test -e /proc/version || set_return_value 100
fi
pid="`cat "$pid_file"`"
if [ "$pid" ] && [ -d "/proc/$pid" ]; then
cmd=`cat "/proc/$pid/cmdline" 2> /dev/null`
exe=`readlink "/proc/$pid/exe" 2> /dev/null`
if [ "`echo "$exe" | grep "^$MYSQLD"`" ] || [ "`echo "$cmd" | grep "^$MYSQLD"`" ]; then
set_return_value 0
else
set_return_value 1
fi
else
set_return_value 1
fi
else
set_return_value 3
fi
rc_status -v
;;
*)
echo "Usage: $MYSELF {start|stop|status|reload|restart|try-restart|force-reload}"
exit 1
;;
esac
fi
rc_exit
# vim: ft=sh

View File

@ -1,614 +0,0 @@
#!/bin/bash
# Copyright (c) 1995-2014 SuSE Linux AG Nuernberg, Germany.
#
# Author: Lenz Grimmer
# Maintainer: Michal Hrusecky <mhrusecky@suse.cz>
#
# mysqld_multi extension added by Richard Bos, 2008
#
# /etc/init.d/mysql
#
# and its symbolic link
#
# /usr/sbin/rcmysql
#
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 3 5
# Default-Stop:
# Short-Description: Start the MySQL database server
# Description: Start the MySQL database server
### END INIT INFO
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
# Check for the location of initscript
if [ "`echo "$0" | grep "^\."`" ] || [ "`echo "$0" | grep "^[^/].*/"`" ]; then
MYSELF="`pwd`/$0"
else
MYSELF="$0"
fi
parse_arguments() {
for arg do
case "$arg" in
--basedir=*) basedir="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--datadir=*) datadir="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--pid-file=*) pid_file="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--socket=*) socket="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--log-error=*) log_error="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--user=*) mysql_daemon_user="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
--group=*) mysql_daemon_group="`echo "$arg" | sed -e 's/^[^=]*=//'`" ;;
esac
done
}
wait_for_socket()
{
local i
for((i=0; i<150; i++)); do
sleep 0.2
test -S $1 && i='' && break
done
test -z "$i" || return 1
return 0
}
# Don't run killproc -TERM, as it could send a SIGKILL as well, possibly
# resulting in database corruption. Run kill -TERM manually instead, wait
# approximately 300 seconds and fail if mysql doesn't respond. This will at
# least prevent the SIGKILL when doing 'rcmysql stop' manually. During system
# shutdown, we are out of luck...
# See https://bugzilla.novell.com/show_bug.cgi?id=223209
kill_mysql ()
{
local pid exe test_pid_file
if [ "$1" ]; then
test_pid_file="$1"
else
test_pid_file="$pid_file"
fi
test -e "$test_pid_file" || return 7 # not running
pid=`cat "$test_pid_file"` || return 4 # insufficient privileges
if ! test -e /proc/version; then
mount -n -t proc proc /proc
test -e /proc/version || return 100
fi
test -L "/proc/$pid/exe" || return 7
exe=`readlink "/proc/$pid/exe"` || return 4
test "`echo "$exe" | grep "^$MYSQLD"`" || return 7
kill -STOP "$pid"
kill -TERM "$pid" || return 4 # suboptimal
kill -CONT "$pid"
for i in `seq 3000`; do
# mysqld removes its pid file
test -e "$test_pid_file" || return 0
LC_ALL=C sleep 0.1
done
test -e "$test_pid_file" || return 0
return 1
}
# Helper function which can end with any status
set_return_value() {
return $1
}
# Checks for obsolete database
check_obsolete() {
# check for ISAM tables
tables="`find "$datadir" -name '*.ISM' 2> /dev/null | sed "s@$datadir/*@@; s@.ISM@@; s@/@.@;"`"
if test "$tables" ; then
echo
echo "Some tables still use ISAM format, which is NO LONGER SUPPORTED"
echo "since mysql 5.0. To use these tables, you would need to open them"
echo "from an older mysql server and convert to something better (eg. MyISAM)."
echo
echo "Tables using ISAM are: "
echo " $tables "
echo
fi
# check for bdb tables
tables="`find "$datadir" -name '*.db' 2> /dev/null | sed "s@$datadir/*@@; s@.db@@; s@/@.@;"`"
if test -n "$tables" ; then
echo
echo "Some tables still use BerkeleyDB format, which is NO LONGER SUPPORTED"
echo "since mysql 5.1. To use these tables, you would need to open them"
echo "from an older mysql server and convert to something better (eg. MyISAM)."
echo
echo "Tables using BerkeleyDB are: "
echo " $tables "
echo
fi
}
# Check if we want to run multiple instances.
[[ "`cat /etc/my.cnf | sed -n 's|^[[:blank:]]*\[mysqld[0-9]\+\]|yes|p'`" ]] && MYSQLD_MULTI=yes
# This was old way how to specify this, left for backward compatibility.
[[ -f /etc/sysconfig/mysql ]] && . /etc/sysconfig/mysql
if [[ "$MYSQLD_MULTI" == "yes" ]]; then
[[ -x /usr/bin/mysqld_multi ]] || {
echo -n "MySQL: /usr/bin/mysqld_multi not found"
rc_failed 5; rc_status -v; rc_exit;
}
case "$1" in
start)
# FIXME:
# We assume a fresh install if the directory $datadir/mysql
# does not exist and create the privilege database
# if ! test -d $datadir/mysql; then
# echo -n "Creating MySQL privilege database... "
# mysql_install_db --user=$mysql_daemon_user --datadir=$datadir || {
# rc_failed; rc_status -v; rc_exit
# }
# fi
echo -n "Starting service multi MySQL "
mysqld_multi start
for((i=0; i<150; i++)); do
sleep 0.2
[ "`mysqld_multi report | grep 'is not running'`" ] || break
done
if [ "`mysqld_multi report | grep 'is not running'`" ]; then
echo "Failed to start all instances"
mysqld_multi report
rc_failed; rc_status -v; rc_exit
fi
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down service multi MySQL "
mysqld_multi stop
for((i=0; i<150; i++)); do
sleep 0.2
[ "`mysqld_multi report | grep 'is running'`" ] || break
done
if [ "`mysqld_multi report | grep 'is running'`" ]; then
echo "Failed to stop all instances"
mysqld_multi report
rc_failed; rc_status -v; rc_exit
fi
# Remember status and be verbose
rc_status -v
;;
try-restart)
## Stop the service and if this succeeds (i.e. the
## service was running before), start it again.
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
"$MYSELF" status >/dev/null && "$MYSELF" restart
# Remember status and be quiet
rc_status
;;
restart|force-reload)
echo "Restarting service multi MySQL "
"$MYSELF" stop
"$MYSELF" start
rc_status
;;
reload)
echo -n "Reloading service multi MySQL "
mysqld_multi reload
rc_status -v
;;
status)
STATUS=$(mysqld_multi report)
echo -n "$STATUS"
# Set the status for rc_status
echo "$STATUS" | grep -q "is running"
rc_status -v
;;
*)
echo "Usage: $MYSELF {start|stop|status|reload|restart|try-restart|force-reload}"
exit 1
;;
esac
else
# Test, if mysqld or mysql-max actually exist
unset MYSQLD
# use mysqld-debug only if explicitly requested (TODO: sysconfig variable?)
if test "$MYSQLD_DEBUG" = yes -a -x /usr/sbin/mysqld
then
MYSQLD=/usr/sbin/mysqld
elif test -x /usr/sbin/mysqld-max
then
MYSQLD=/usr/sbin/mysqld-max
elif test -x /usr/sbin/mysqld
then
MYSQLD=/usr/sbin/mysqld
fi
test "$MYSQLD" || {
echo -n "Nor /usr/sbin/mysqld nor /usr/sbin/mysqld-max exists";
rc_failed 5; rc_status -v; rc_exit;
}
# The following section has been taken from
# the original MySQL init script
# Note: If you want to change these variables, you'll make your life easier
# if you do so in /etc/my.cnf, which is preserved during upgrades
basedir=/usr
datadir=/var/lib/mysql
mysql_daemon_user=mysql
mysql_daemon_group=mysql
pid_file=/var/run/mysql/mysqld.pid
socket=/var/run/mysql/mysql.sock
print_defaults=/usr/bin/my_print_defaults
log_error=/var/log/mysql/mysqld.log
mode=$1 # start or stop
log_base="`echo "$log_error" | sed 's|\.log$||'`"
[ "$log_base" \!= "$log_error" ] || log_base="/var/log/mysql/mysql"
log_upgrade="${log_base}-upgrade.log"
log_upgrade_run="${log_base}-upgrade-run.log"
log_query="${log_base}-query.log"
parse_arguments `$print_defaults $defaults mysqld mysql_server`
mkdir -m 755 -p /var/run/mysql
chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" /var/run/mysql
export TEMPDIR="`cat /var/run/mysql/tmpdir 2> /dev/null`"
# Safeguard (relative paths, core dumps..)
cd "$basedir"
case "$1" in
start)
# exit gracefully, if we are already running
"$MYSELF" status >/dev/null && echo -n "Starting service MySQL " && \
rc_status -v && rc_exit
# prepare tmp dir
unset TMPDIR
if [ "$TEMPDIR" ] && [ -d "$TEMPDIR" ] && \
[ "`ls -ld "$TEMPDIR" | grep "^drwx------[\\.\+]\?[[:blank:]]\+[0-9]\+[[:blank:]]\+$mysql_daemon_user[[:blank:]]\+$mysql_daemon_group[[:blank:]]\+.*"`" ]; then
rm -rf "$TEMPDIR"
fi
TEMPDIR="`mktemp -d -p /var/tmp mysql.XXXXXX | tee /var/run/mysql/tmpdir`"
[ -z "$TEMPDIR" ] || chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$TEMPDIR"
[ "`ls -ld "$TEMPDIR" | grep "^drwx------[\\.\+]\?[[:blank:]]\+[0-9]\+[[:blank:]]\+$mysql_daemon_user[[:blank:]]\+$mysql_daemon_group[[:blank:]]\+.*"`" ] || {
echo "Can't create secure $TEMPDIR"
rc_failed; rc_status -v; rc_exit;
}
# Test, if safe_mysqld actually exists
SAFE_MYSQLD=/usr/bin/mysqld_safe
test -x $SAFE_MYSQLD || {
echo "$SAFE_MYSQLD does not exist ";
rc_failed 5; rc_status -v; rc_exit;
}
debug_flags=""
if test "$MYSQLD_DEBUG" = yes; then
# add --log, --core-file and --debug
# but only if not already set in my.cnf
if ! $print_defaults mysqld | \
grep -q -e '--log$' -e '--log[[:blank:]=]'
then
debug_flags="--log=${log_query}"
fi
if ! $print_defaults mysqld | grep -q -e '^--debug\>' &&
test "$MYSQLD" = /usr/sbin/mysqld-debug
then
debug_flags="$debug_flags --debug=d:t:F:L:o,$datadir/mysqld.trace"
fi
if ! $print_defaults mysqld | grep -q -e '^--core-file\>'
then
debug_flags="$debug_flags --core-file"
fi
fi
# Creating parent directories for logs
for i in "$log_upgrade" "$log_query" "$log_error"; do
if [ "${i:0:1}" == "/" ]; then
log_dir="`dirname "$i"`"
if [ \! -d "$log_dir" ]; then
mkdir -p "$log_dir"
fi
chmod 770 "$log_dir"
chown -R --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$log_dir"
else
echo "Relative path \"$i\" for log found, skipping handling."
echo "Trusting sysadmin that he prepared everything and knows what to do."
echo "You've been warned, you are on your own with logs!"
fi
done
MYSQLVER="`echo @MYSQLVER@ | sed 's|\.[0-9]\+$||'`"
# We assume a fresh install if the directory $datadir/mysql
# does not exist and create the privilege database
if ! test -d "$datadir/mysql"; then
echo "Creating MySQL privilege database... "
mysql_install_db --user="$mysql_daemon_user" --datadir="$datadir" ||{
rc_failed; rc_status -v; rc_exit
}
echo -n "$MYSQLVER" > "$datadir"/mysql_upgrade_info
fi
check_obsolete
# Run mysql_upgrade on every package install/upgrade. Not always
# necessary, but doesn't do any harm. On big upgrade, require
# user confirmation.
if [ -f "$datadir/.run-mysql_upgrade" ]; then
echo > "$log_upgrade"
echo "`LANG="" date` - upgrading MySQL..." >> "$log_upgrade"
echo >> "$log_upgrade"
echo "Will update MySQL now, if you encounter any problems, please read following file:" | tee -a "$log_upgrade"
echo " /usr/share/doc/packages/mysql/README.SUSE" | tee -a "$log_upgrade"
sed -i -e 's|^\([[:blank:]]*\)skip-locking|\1skip-external-locking|' \
-e 's|^\([[:blank:]]*skip-federated\)|#\1|' /etc/my.cnf
[ -d /etc/mysql ] || \
sed -i 's|^\([[:blank:]]*!includedir\ /etc/mysql[[:blank:]]*\)$|#\1|' /etc/my.cnf
# Check logs for inconsistencies
SRCLOGS=""
ALL_SRCLOGS=""
for i in "$log_error" /var/lib/mysql/mysqld.log \
/var/log/mysqld.log ; do
if test -f "$i"; then
SRCLOGS="$i"
ALL_SRCLOGS="${ALL_SRCLOGS} ${i}"
fi
done
if [ "${ALL_SRCLOGS}" \!= " ${SRCLOGS}" ]; then
echo "Log files inconsistency, please merge following files manually:"
echo $ALL_SRCLOGS | sed 's|[[:blank:]]\+|\n|' | sed 's|^|\t|'
else
if [ "$SRCLOGS" ]; then
[ "$SRCLOGS" = "$log_error" ] || mv "$SRCLOGS" "$log_error"
fi
fi
check_obsolete >> "$log_upgrade"
# instead of running mysqld --bootstrap, which wouldn't allow
# us to run mysql_upgrade, we start a full-featured server with
# --skip-grant-tables and restict access to it by unix
# permissions of the named socket
protected="`cat /var/run/mysql/protecteddir 2> /dev/null`"
if [ -d "$protected" ]; then
pid="`cat "$protected/mysqld.pid" 2> /dev/null`"
if [ "$pid" ] && [ -d "/proc/$pid" ] &&
[ "`readlink "/proc/$pid/exe" | grep "mysql"`" ]; then
echo "Can't update as another updating process is currently running" | tee -a "$log_upgrade"
echo "Please check process $pid and terminate it before restarting MySQL" | tee -a "$log_upgrade"
touch /var/lib/mysql/.run-mysql_upgrade
rc_failed; rc_status -v; rc_exit;
else
rm -rf "$protected"
fi
fi
protected="`mktemp -d -p /var/tmp mysql-protected.XXXXXX | tee /var/run/mysql/protecteddir`"
export TMPDIR="$TEMPDIR"
# Run upgrade, double check
# We need to restart mysql every time as programs
# reloads privileges tables, so we can get lock out
for cmd in "/usr/bin/mysql_upgrade" \
"/usr/bin/mysql_upgrade"; do
[ -z "$protected" ] || chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$protected"
[ "`ls -ld "$protected" | grep "^drwx------[\\.\+]\?[[:blank:]]\+[0-9]\+[[:blank:]]\+$mysql_daemon_user[[:blank:]]\+$mysql_daemon_group[[:blank:]]\+.*"`" ] || {
echo "Can't create secure $protected" | tee -a "$log_upgrade"
touch /var/lib/mysql/.run-mysql_upgrade
rc_failed; rc_status -v; rc_exit;
}
echo "Running protected MySQL... " | tee -a "$log_upgrade"
$MYSQLD \
$debug_flags \
--skip-networking \
--skip-grant-tables \
--datadir="$datadir" \
--user="$mysql_daemon_user" \
--log-error="$log_upgrade_run" \
--socket="$protected/mysql.sock" \
--pid-file="$protected/mysqld.pid" \
--group="$mysql_daemon_group" &>/dev/null &
wait_for_socket "$protected/mysql.sock" || {
echo "error: $protected/mysql.sock file didn't appeared... " | tee -a "$log_upgrade"
echo " Try checking \"$log_upgrade_run\"... " | tee -a "$log_upgrade"
touch /var/lib/mysql/.run-mysql_upgrade
rc_failed; rc_status -v; rc_exit;
}
if [ "`grep "Upgrading MySQL..." "$log_upgrade"`" ]; then
echo "Problems should be fixed now."
echo "Rechecking whether everything is Ok... " | tee -a "$log_upgrade"
LANG=C $cmd --no-defaults --force \
--socket="$protected/mysql.sock" | \
sed -e 's|^|\ \ \ |' | \
tee -a "$log_upgrade"
else
echo "Upgrading MySQL... " | tee -a "$log_upgrade"
LANG=C $cmd --no-defaults --force \
--socket="$protected/mysql.sock" | \
sed -e 's|^|\ \ \ |' \
-e 's|error|info|' \
-e 's|\(Table\ upgrade\ required.\).*|\1|' | \
tee -a "$log_upgrade"
fi
[ "$PIPESTATUS" -ne 0 ] && {
rc_failed; rc_status -v;
kill_mysql "$protected/mysqld.pid"
rc_exit; }
kill_mysql "$protected/mysqld.pid" || {
echo "error: Can't stop protected MySQL... " | tee -a "$log_upgrade"
rc_failed; rc_status -v;
kill_mysql "$protected/mysqld.pid"
rc_exit; }
# Everything went fine
if [ -z "`grep REPAIR "$log_upgrade"`" ] && \
[ -z "`grep "Table\ upgrade\ required" "$log_upgrade"`" ]; then
break
fi
done # end of upgrade
rm -rf "$protected"
# Fix ownerships and permissions for $datadir
chmod 750 "$datadir"
chown -R --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$datadir"
rm -f /var/adm/update-messages/mysql-*
[ "`grep "^$MYSQLVER" "$datadir/mysql_upgrade_info" 2> /dev/null`" ] || \
echo -n "@MYSQLVER@" > "$datadir/mysql_upgrade_info"
rm -f /var/lib/mysql/.run-mysql_upgrade
rm -f /var/lib/mysql/.force_upgrade
rm -f "$datadir"/{update-stamp-*,mysql/stamp-4.1} # used in the past
MYSQLVERSION="`mysqld --version 2> /dev/null | sed -n 's|mysqld[[:blank:]]\+Ver[[:blank:]]\+\([^[:blank:]]\+\)[[:blank:]].*|\1|p'`"
[ -z "$MYSQLVERSION" ] || echo "$MYSQLVERSION" > "$datadir"/mysql_upgrade_info
chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$log_upgrade"
chmod 640 "$log_upgrade"
fi
export TMPDIR="$TEMPDIR"
echo -n "Starting service MySQL "
$SAFE_MYSQLD \
--mysqld=${MYSQLD#/usr/sbin/} \
$debug_flags \
--user="$mysql_daemon_user" \
--pid-file="$pid_file" \
--socket="$socket" \
--datadir="$datadir" &>/dev/null &
wait_for_socket "$socket" || {
# let's not treat this as a fatal error
echo "warning: $socket didn't appear within 30 seconds"
}
chmod a+r "$pid_file"
# Rmember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down service MySQL "
kill_mysql
if [ "$TEMPDIR" ] && [ -d "$TEMPDIR" ] && \
[ "`ls -ld "$TEMPDIR" | grep "^drwx------[\\.\+]\?[[:blank:]]\+[0-9]\+[[:blank:]]\+$mysql_daemon_user[[:blank:]]\+$mysql_daemon_group[[:blank:]]\+.*"`" ]; then
rm -rf "$TEMPDIR"
fi
# Remember status and be verbose
rc_status -v
;;
try-restart)
## Stop the service and if this succeeds (i.e. the
## service was running before), start it again.
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
"$MYSELF" status >/dev/null && "$MYSELF" restart
# Remember status and be quiet
rc_status
;;
restart|force-reload)
echo "Restarting service MySQL "
"$MYSELF" stop
"$MYSELF" start
rc_status
;;
reload)
echo -n "Reloading service MySQL "
kill -HUP "`cat "$pid_file"`"
touch "$pid_file"
rc_status -v
;;
check|status)
echo -n "Checking for service MySQL: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values,
# but it checks for running binary first and only
# if it doesn't find running process with proper
# name it checks pidfile. So we can't use it because
# akonadi runs it's own database.
# checkproc -p $pid_file $MYSQLD
if [ -f "$pid_file" ]; then
if ! [ -e /proc/version ]; then
mount -n -t proc proc /proc
test -e /proc/version || set_return_value 100
fi
pid="`cat "$pid_file"`"
if [ "$pid" ] && [ -d "/proc/$pid" ]; then
cmd=`cat "/proc/$pid/cmdline" 2> /dev/null`
exe=`readlink "/proc/$pid/exe" 2> /dev/null`
if [ "`echo "$exe" | grep "^$MYSQLD"`" ] || [ "`echo "$cmd" | grep "^$MYSQLD"`" ]; then
set_return_value 0
else
set_return_value 1
fi
else
set_return_value 1
fi
else
set_return_value 3
fi
rc_status -v
;;
*)
echo "Usage: $MYSELF {start|stop|status|reload|restart|try-restart|force-reload}"
exit 1
;;
esac
fi
rc_exit
# vim: ft=sh

1
series
View File

@ -17,3 +17,4 @@ mariadb-10.0.15-logrotate-su.patch
mariadb-5.5.41-mariadb-admincrash.patch
mariadb-10.0.15-covscan-signexpr.patch
mariadb-10.0.10-string-overflow.patch
mariadb-10.0.20-tabxml-bufferoverflowstrncat.patch

View File

@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# Test the SUSE mysql(-Max) package using the MySQL testsuite
# Test the SUSE mysql package using the MySQL testsuite
my $id = getpwnam("mysql") or die "can't find user \"mysql\": $!";
my $dir = "/usr/share/mysql-test/";