Include SysV init script if built on older system
This commit is contained in:
parent
1366a527f1
commit
ee2d0857de
@ -5,26 +5,34 @@
|
|||||||
|
|
||||||
source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common"
|
source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common"
|
||||||
|
|
||||||
# Absorb configuration settings from the specified systemd service file,
|
# If two args given first is user, second is group
|
||||||
# or the default "mariadb" service if not specified
|
# otherwise the arg is the systemd service file
|
||||||
SERVICE_NAME="$1"
|
if [ "$#" -eq 2 ]
|
||||||
if [ x"$SERVICE_NAME" = x ]
|
|
||||||
then
|
then
|
||||||
SERVICE_NAME=@RPM_PACKAGE_PREFIX@mariadb.service
|
myuser="$1"
|
||||||
fi
|
mygroup="$2"
|
||||||
|
else
|
||||||
|
# Absorb configuration settings from the specified systemd service file,
|
||||||
|
# or the default "mariadb" service if not specified
|
||||||
|
SERVICE_NAME="$1"
|
||||||
|
if [ x"$SERVICE_NAME" = x ]
|
||||||
|
then
|
||||||
|
SERVICE_NAME=@DAEMON_NAME@.service
|
||||||
|
fi
|
||||||
|
|
||||||
myuser=`systemctl show -p User "${SERVICE_NAME}" |
|
myuser=`systemctl show -p User "${SERVICE_NAME}" |
|
||||||
sed 's/^User=//'`
|
sed 's/^User=//'`
|
||||||
if [ x"$myuser" = x ]
|
if [ x"$myuser" = x ]
|
||||||
then
|
then
|
||||||
myuser=mysql
|
myuser=mysql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mygroup=`systemctl show -p Group "${SERVICE_NAME}" |
|
mygroup=`systemctl show -p Group "${SERVICE_NAME}" |
|
||||||
sed 's/^Group=//'`
|
sed 's/^Group=//'`
|
||||||
if [ x"$mygroup" = x ]
|
if [ x"$mygroup" = x ]
|
||||||
then
|
then
|
||||||
mygroup=mysql
|
mygroup=mysql
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set up the errlogfile with appropriate permissions
|
# Set up the errlogfile with appropriate permissions
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
diff -up mariadb-10.0.12/scripts/CMakeLists.txt.systemd mariadb-10.0.12/scripts/CMakeLists.txt
|
diff -up mariadb-10.0.12/scripts/CMakeLists.txt.systemd mariadb-10.0.12/scripts/CMakeLists.txt
|
||||||
--- mariadb-10.0.12/scripts/CMakeLists.txt.systemd 2014-07-21 10:49:58.491470586 +0200
|
--- mariadb-10.0.12/scripts/CMakeLists.txt.systemd 2014-07-21 10:49:58.491470586 +0200
|
||||||
+++ mariadb-10.0.12/scripts/CMakeLists.txt 2014-07-21 14:21:22.673329708 +0200
|
+++ mariadb-10.0.12/scripts/CMakeLists.txt 2014-07-21 14:21:22.673329708 +0200
|
||||||
@@ -368,6 +368,30 @@ ELSE()
|
@@ -368,6 +368,31 @@ ELSE()
|
||||||
COMPONENT ${${file}_COMPONENT}
|
COMPONENT ${${file}_COMPONENT}
|
||||||
)
|
)
|
||||||
ENDFOREACH()
|
ENDFOREACH()
|
||||||
@ -16,6 +16,7 @@ diff -up mariadb-10.0.12/scripts/CMakeLists.txt.systemd mariadb-10.0.12/scripts/
|
|||||||
+ mariadb.service
|
+ mariadb.service
|
||||||
+ mysqld.service
|
+ mysqld.service
|
||||||
+ mariadb.tmpfiles.d
|
+ mariadb.tmpfiles.d
|
||||||
|
+ mysql.init
|
||||||
+ )
|
+ )
|
||||||
+ FOREACH(file ${SYSTEMD_SCRIPTS})
|
+ FOREACH(file ${SYSTEMD_SCRIPTS})
|
||||||
+ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
|
+ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
|
||||||
|
@ -32,6 +32,7 @@ while /bin/true; do
|
|||||||
# exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
|
# exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
|
||||||
# anything else suggests a configuration error
|
# anything else suggests a configuration error
|
||||||
if [ $mret -ne 1 -a $mret -ne 11 ]; then
|
if [ $mret -ne 1 -a $mret -ne 11 ]; then
|
||||||
|
echo "Cannot check for MySQL Daemon startup because of mysqladmin failure." >&2
|
||||||
ret=$mret
|
ret=$mret
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
Description=MariaDB @MAJOR_VERSION@.@MINOR_VERSION@ database server
|
Description=MariaDB @MAJOR_VERSION@.@MINOR_VERSION@ database server
|
||||||
After=syslog.target
|
After=syslog.target
|
||||||
After=network.target
|
After=network.target
|
||||||
BindsTo=@RPM_PACKAGE_PREFIX@mysqld.service
|
BindsTo=@DAEMON_NAME2@.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
@ -48,4 +48,4 @@ PrivateTmp=true
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
Also=@RPM_PACKAGE_PREFIX@mysqld.service
|
Also=@DAEMON_NAME2@.service
|
||||||
|
138
mariadb.spec
138
mariadb.spec
@ -14,7 +14,11 @@
|
|||||||
# those files may create issues
|
# those files may create issues
|
||||||
# ship_my_cnf=1 means this is the only package in distro which ships
|
# ship_my_cnf=1 means this is the only package in distro which ships
|
||||||
# my.cnf and my.cnf.d
|
# my.cnf and my.cnf.d
|
||||||
|
%if 0%{?fedora} >= 21
|
||||||
%global ship_my_cnf 1
|
%global ship_my_cnf 1
|
||||||
|
%else
|
||||||
|
%global ship_my_cnf 0
|
||||||
|
%endif
|
||||||
|
|
||||||
# TokuDB engine is now part of MariaDB, but it is available only for x86_64;
|
# TokuDB engine is now part of MariaDB, but it is available only for x86_64;
|
||||||
# variable tokudb allows to build with TokuDB storage engine
|
# variable tokudb allows to build with TokuDB storage engine
|
||||||
@ -30,12 +34,19 @@
|
|||||||
# fashion; enabled by default
|
# fashion; enabled by default
|
||||||
%bcond_without oqgraph
|
%bcond_without oqgraph
|
||||||
|
|
||||||
# Name for the systemd unit file
|
# Include files for SysV init or systemd
|
||||||
%global daemon_unit %{name}.service
|
%if 0%{?systemd_requires:1}
|
||||||
|
%bcond_without init_systemd
|
||||||
|
%bcond_with init_sysv
|
||||||
|
%global daemon_name %{name}
|
||||||
# Provide temporary service file name that will be removed after some time
|
# Provide temporary service file name that will be removed after some time
|
||||||
# (Fedora 22?)
|
# (Fedora 22?)
|
||||||
%global mysqld_unit mysqld.service
|
%global mysqld_unit mysqld
|
||||||
|
%else
|
||||||
|
%bcond_with init_systemd
|
||||||
|
%bcond_without init_sysv
|
||||||
|
%global daemon_name mysqld
|
||||||
|
%endif
|
||||||
|
|
||||||
# MariaDB 10.0 and later requires pcre >= 8.35, otherwise we need to use
|
# MariaDB 10.0 and later requires pcre >= 8.35, otherwise we need to use
|
||||||
# the bundled library, since the package cannot be build with older version
|
# the bundled library, since the package cannot be build with older version
|
||||||
@ -45,6 +56,15 @@
|
|||||||
%bcond_with pcre
|
%bcond_with pcre
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
# We define some system's well known locations here so we can use them easily
|
||||||
|
# later when building to another location (like SCL)
|
||||||
|
%global logrotateddir %{_sysconfdir}/logrotate.d
|
||||||
|
%global logfiledir %{_localstatedir}/log/%{name}
|
||||||
|
%global logfile %{logfiledir}/%{name}.log
|
||||||
|
%if 0%{?fedora} >= 20
|
||||||
|
%global old_logfile %{_localstatedir}/log/mysqld.log
|
||||||
|
%endif
|
||||||
|
|
||||||
# The evr of mysql we want to obsolete
|
# The evr of mysql we want to obsolete
|
||||||
%global obsoleted_mysql_evr 5.6-0
|
%global obsoleted_mysql_evr 5.6-0
|
||||||
%global obsoleted_mysql_case_evr 5.5.30-5
|
%global obsoleted_mysql_case_evr 5.5.30-5
|
||||||
@ -87,6 +107,7 @@ Source13: mariadb-wait-ready.sh
|
|||||||
Source14: mariadb-check-socket.sh
|
Source14: mariadb-check-socket.sh
|
||||||
Source15: mariadb-scripts-common.sh
|
Source15: mariadb-scripts-common.sh
|
||||||
Source16: mysqld.service.in
|
Source16: mysqld.service.in
|
||||||
|
Source17: mysql.init.in
|
||||||
Source50: rh-skipped-tests-base.list
|
Source50: rh-skipped-tests-base.list
|
||||||
Source51: rh-skipped-tests-intel.list
|
Source51: rh-skipped-tests-intel.list
|
||||||
Source52: rh-skipped-tests-arm.list
|
Source52: rh-skipped-tests-arm.list
|
||||||
@ -130,7 +151,7 @@ BuildRequires: perl(Data::Dumper)
|
|||||||
BuildRequires: perl(Socket)
|
BuildRequires: perl(Socket)
|
||||||
BuildRequires: perl(Test::More)
|
BuildRequires: perl(Test::More)
|
||||||
BuildRequires: perl(Time::HiRes)
|
BuildRequires: perl(Time::HiRes)
|
||||||
BuildRequires: systemd
|
%{?with_init_systemd:BuildRequires: systemd}
|
||||||
|
|
||||||
Requires: bash
|
Requires: bash
|
||||||
Requires: fileutils
|
Requires: fileutils
|
||||||
@ -223,12 +244,14 @@ Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
|
|||||||
Requires: %{name}-errmsg%{?_isa} = %{epoch}:%{version}-%{release}
|
Requires: %{name}-errmsg%{?_isa} = %{epoch}:%{version}-%{release}
|
||||||
Requires: sh-utils
|
Requires: sh-utils
|
||||||
Requires(pre): /usr/sbin/useradd
|
Requires(pre): /usr/sbin/useradd
|
||||||
|
%if %{with init_systemd}
|
||||||
# We require this to be present for %%{_tmpfilesdir}
|
# We require this to be present for %%{_tmpfilesdir}
|
||||||
Requires: systemd
|
Requires: systemd
|
||||||
# Make sure it's there when scriptlets run, too
|
# Make sure it's there when scriptlets run, too
|
||||||
Requires(pre): systemd
|
Requires(pre): systemd
|
||||||
Requires(posttrans): systemd
|
Requires(posttrans): systemd
|
||||||
%{?systemd_requires: %systemd_requires}
|
%{?systemd_requires: %systemd_requires}
|
||||||
|
%endif
|
||||||
# mysqlhotcopy needs DBI/DBD support
|
# mysqlhotcopy needs DBI/DBD support
|
||||||
Requires: perl-DBI
|
Requires: perl-DBI
|
||||||
Requires: perl-DBD-MySQL
|
Requires: perl-DBD-MySQL
|
||||||
@ -386,6 +409,8 @@ MariaDB is a community developed branch of MySQL.
|
|||||||
%patch15 -p1
|
%patch15 -p1
|
||||||
%patch16 -p1
|
%patch16 -p1
|
||||||
|
|
||||||
|
sed -i -e 's/2.8.7/2.6.4/g' cmake/cpack_rpm.cmake
|
||||||
|
|
||||||
# workaround for upstream bug #56342
|
# workaround for upstream bug #56342
|
||||||
rm -f mysql-test/t/ssl_8k_key-master.opt
|
rm -f mysql-test/t/ssl_8k_key-master.opt
|
||||||
|
|
||||||
@ -410,7 +435,7 @@ cat %{SOURCE54} >> mysql-test/rh-skipped-tests.list
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
cp %{SOURCE2} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} \
|
cp %{SOURCE2} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} \
|
||||||
%{SOURCE15} %{SOURCE16} scripts
|
%{SOURCE15} %{SOURCE16} %{SOURCE17} scripts
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
|
||||||
@ -452,7 +477,10 @@ export LDFLAGS
|
|||||||
cmake . -DBUILD_CONFIG=mysql_release \
|
cmake . -DBUILD_CONFIG=mysql_release \
|
||||||
-DFEATURE_SET="community" \
|
-DFEATURE_SET="community" \
|
||||||
-DINSTALL_LAYOUT=RPM \
|
-DINSTALL_LAYOUT=RPM \
|
||||||
-DRPM_PACKAGE_PREFIX="" \
|
-DDAEMON_NAME="%{daemon_name}" \
|
||||||
|
%if 0%{?mysqld_unit:1}
|
||||||
|
-DDAEMON_NAME2="%{mysqld_unit}" \
|
||||||
|
%endif
|
||||||
-DRPM="%{?rhel:rhel%{rhel}}%{!?rhel:fedora%{fedora}}" \
|
-DRPM="%{?rhel:rhel%{rhel}}%{!?rhel:fedora%{fedora}}" \
|
||||||
-DCMAKE_INSTALL_PREFIX="%{_prefix}" \
|
-DCMAKE_INSTALL_PREFIX="%{_prefix}" \
|
||||||
%if 0%{?fedora} >= 20
|
%if 0%{?fedora} >= 20
|
||||||
@ -531,10 +559,12 @@ mv %{buildroot}%{_pkgdocdir}/MariaDB-server-%{version}/INFO_SRC %{buildroot}%{_l
|
|||||||
mv %{buildroot}%{_pkgdocdir}/MariaDB-server-%{version}/INFO_BIN %{buildroot}%{_libdir}/mysql/
|
mv %{buildroot}%{_pkgdocdir}/MariaDB-server-%{version}/INFO_BIN %{buildroot}%{_libdir}/mysql/
|
||||||
rm -rf %{buildroot}%{_pkgdocdir}/MariaDB-server-%{version}/
|
rm -rf %{buildroot}%{_pkgdocdir}/MariaDB-server-%{version}/
|
||||||
|
|
||||||
mkdir -p %{buildroot}%{_localstatedir}/log/%{name}
|
mkdir -p %{buildroot}%{logfiledir}
|
||||||
chmod 0750 %{buildroot}%{_localstatedir}/log/%{name}
|
chmod 0750 %{buildroot}%{logfiledir}
|
||||||
touch %{buildroot}%{_localstatedir}/log/%{name}/%{name}.log
|
touch %{buildroot}%{logfile}
|
||||||
ln -s %{_localstatedir}/log/%{name}/%{name}.log %{buildroot}%{_localstatedir}/log/mysqld.log
|
%if 0%{?old_logfile:1}
|
||||||
|
ln -s %{logfile} %{buildroot}%{old_logfile}
|
||||||
|
%endif
|
||||||
|
|
||||||
# current setting in my.cnf is to use /var/run/mariadb for creating pid file,
|
# current setting in my.cnf is to use /var/run/mariadb for creating pid file,
|
||||||
# however since my.cnf is not updated by RPM if changed, we need to create mysqld
|
# however since my.cnf is not updated by RPM if changed, we need to create mysqld
|
||||||
@ -545,20 +575,33 @@ install -p -m 0755 -d %{buildroot}%{_localstatedir}/lib/mysql
|
|||||||
|
|
||||||
%if %{ship_my_cnf}
|
%if %{ship_my_cnf}
|
||||||
install -D -p -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/my.cnf
|
install -D -p -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/my.cnf
|
||||||
|
%else
|
||||||
|
rm -f %{buildroot}%{_sysconfdir}/my.cnf.d/mysql-clients.cnf
|
||||||
|
rm -f %{buildroot}%{_sysconfdir}/my.cnf
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# install systemd unit files and scripts for handling server startup
|
# install systemd unit files and scripts for handling server startup
|
||||||
install -D -p -m 644 scripts/mariadb.service %{buildroot}%{_unitdir}/%{daemon_unit}
|
%if %{with init_systemd}
|
||||||
%if 0%{?mysqld_unit:1}
|
install -D -p -m 644 scripts/mariadb.service %{buildroot}%{_unitdir}/%{daemon_name}.service
|
||||||
install -p -m 644 scripts/mysqld.service %{buildroot}%{_unitdir}/%{mysqld_unit}
|
install -D -p -m 0644 scripts/mariadb.tmpfiles.d %{buildroot}%{_tmpfilesdir}/%{name}.conf
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
# install alternative systemd unit file for compatibility reasons
|
||||||
|
%if 0%{?mysqld_unit:1}
|
||||||
|
install -p -m 644 scripts/mysqld.service %{buildroot}%{_unitdir}/%{mysqld_unit}.service
|
||||||
|
%endif
|
||||||
|
|
||||||
|
# install SysV init script
|
||||||
|
%if %{with init_sysv}
|
||||||
|
install -D -p -m 755 scripts/mysql.init %{buildroot}%{_initddir}/%{daemon_name}
|
||||||
|
%endif
|
||||||
|
|
||||||
|
# helper scripts for service starting
|
||||||
install -p -m 755 scripts/mariadb-prepare-db-dir %{buildroot}%{_libexecdir}/mariadb-prepare-db-dir
|
install -p -m 755 scripts/mariadb-prepare-db-dir %{buildroot}%{_libexecdir}/mariadb-prepare-db-dir
|
||||||
install -p -m 755 scripts/mariadb-wait-ready %{buildroot}%{_libexecdir}/mariadb-wait-ready
|
install -p -m 755 scripts/mariadb-wait-ready %{buildroot}%{_libexecdir}/mariadb-wait-ready
|
||||||
install -p -m 755 scripts/mariadb-check-socket %{buildroot}%{_libexecdir}/mariadb-check-socket
|
install -p -m 755 scripts/mariadb-check-socket %{buildroot}%{_libexecdir}/mariadb-check-socket
|
||||||
install -p -m 644 scripts/mariadb-scripts-common %{buildroot}%{_libexecdir}/mariadb-scripts-common
|
install -p -m 644 scripts/mariadb-scripts-common %{buildroot}%{_libexecdir}/mariadb-scripts-common
|
||||||
|
|
||||||
install -D -p -m 0644 scripts/mariadb.tmpfiles.d %{buildroot}%{_tmpfilesdir}/%{name}.conf
|
|
||||||
|
|
||||||
# Remove libmysqld.a
|
# Remove libmysqld.a
|
||||||
rm -f %{buildroot}%{_libdir}/mysql/libmysqld.a
|
rm -f %{buildroot}%{_libdir}/mysql/libmysqld.a
|
||||||
|
|
||||||
@ -587,9 +630,9 @@ rm -f %{buildroot}%{_mandir}/man1/mysql-test-run.pl.1*
|
|||||||
rm -f %{buildroot}%{_bindir}/mytop
|
rm -f %{buildroot}%{_bindir}/mytop
|
||||||
|
|
||||||
# put logrotate script where it needs to be
|
# put logrotate script where it needs to be
|
||||||
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
|
mkdir -p %{buildroot}%{logrotateddir}
|
||||||
mv %{buildroot}%{_datadir}/%{name}/mysql-log-rotate %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
|
mv %{buildroot}%{_datadir}/%{name}/mysql-log-rotate %{buildroot}%{logrotateddir}/%{name}
|
||||||
chmod 644 %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
|
chmod 644 %{buildroot}%{logrotateddir}/%{name}
|
||||||
|
|
||||||
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d
|
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d
|
||||||
echo "%{_libdir}/mysql" > %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf
|
echo "%{_libdir}/mysql" > %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf
|
||||||
@ -610,7 +653,7 @@ rm -rf %{buildroot}%{_datadir}/%{name}/SELinux/
|
|||||||
rm -f %{buildroot}%{_sysconfdir}/init.d/mysql
|
rm -f %{buildroot}%{_sysconfdir}/init.d/mysql
|
||||||
|
|
||||||
# remove duplicate logrotate script
|
# remove duplicate logrotate script
|
||||||
rm -f %{buildroot}%{_sysconfdir}/logrotate.d/mysql
|
rm -f %{buildroot}%{logrotateddir}/mysql
|
||||||
|
|
||||||
# remove solaris files
|
# remove solaris files
|
||||||
rm -rf %{buildroot}%{_datadir}/%{name}/solaris/
|
rm -rf %{buildroot}%{_datadir}/%{name}/solaris/
|
||||||
@ -649,6 +692,7 @@ export MTR_BUILD_THREAD=%{__isa_bits}
|
|||||||
/usr/sbin/useradd -M -N -g mysql -o -r -d %{_localstatedir}/lib/mysql -s /sbin/nologin \
|
/usr/sbin/useradd -M -N -g mysql -o -r -d %{_localstatedir}/lib/mysql -s /sbin/nologin \
|
||||||
-c "MariaDB Server" -u 27 mysql >/dev/null 2>&1 || :
|
-c "MariaDB Server" -u 27 mysql >/dev/null 2>&1 || :
|
||||||
|
|
||||||
|
%if %{with init_systemd}
|
||||||
# Explicitly enable mysqld if it was enabled in the beginning
|
# Explicitly enable mysqld if it was enabled in the beginning
|
||||||
# of the transaction. Otherwise mysqld is disabled always when
|
# of the transaction. Otherwise mysqld is disabled always when
|
||||||
# replacing mysql with mariadb, because it is not recognized
|
# replacing mysql with mariadb, because it is not recognized
|
||||||
@ -667,30 +711,52 @@ fi
|
|||||||
|
|
||||||
%posttrans server
|
%posttrans server
|
||||||
if [ -f %mysqld_enabled_flag_file ] ; then
|
if [ -f %mysqld_enabled_flag_file ] ; then
|
||||||
/bin/systemctl enable %{daemon_unit} >/dev/null 2>&1 || :
|
/bin/systemctl enable %{daemon_name}.service >/dev/null 2>&1 || :
|
||||||
rm -f %mysqld_enabled_flag_file >/dev/null 2>&1 || :
|
rm -f %mysqld_enabled_flag_file >/dev/null 2>&1 || :
|
||||||
fi
|
fi
|
||||||
if [ -f %mysqld_running_flag_file ] ; then
|
if [ -f %mysqld_running_flag_file ] ; then
|
||||||
/bin/systemctl start %{daemon_unit} >/dev/null 2>&1 || :
|
/bin/systemctl start %{daemon_name}.service >/dev/null 2>&1 || :
|
||||||
rm -f %mysqld_running_flag_file >/dev/null 2>&1 || :
|
rm -f %mysqld_running_flag_file >/dev/null 2>&1 || :
|
||||||
fi
|
fi
|
||||||
|
%endif
|
||||||
|
|
||||||
%post libs -p /sbin/ldconfig
|
%post libs -p /sbin/ldconfig
|
||||||
|
|
||||||
%post server
|
%post server
|
||||||
%systemd_post %{daemon_unit}
|
%if %{with init_systemd}
|
||||||
|
%systemd_post %{daemon_name}.service
|
||||||
|
%endif
|
||||||
|
%if %{with init_sysv}
|
||||||
|
if [ $1 = 1 ]; then
|
||||||
|
/sbin/chkconfig --add %{daemon_name}
|
||||||
|
fi
|
||||||
|
%endif
|
||||||
/bin/chmod 0755 %{_localstatedir}/lib/mysql
|
/bin/chmod 0755 %{_localstatedir}/lib/mysql
|
||||||
|
|
||||||
%post embedded -p /sbin/ldconfig
|
%post embedded -p /sbin/ldconfig
|
||||||
|
|
||||||
%preun server
|
%preun server
|
||||||
%systemd_preun %{daemon_unit}
|
%if %{with init_systemd}
|
||||||
|
%systemd_preun %{daemon_name}.service
|
||||||
|
%endif
|
||||||
|
%if %{with init_sysv}
|
||||||
|
if [ $1 = 0 ]; then
|
||||||
|
/sbin/service %{daemon_name} stop >/dev/null 2>&1
|
||||||
|
/sbin/chkconfig --del %{daemon_name}
|
||||||
|
fi
|
||||||
|
%endif
|
||||||
|
|
||||||
%postun libs -p /sbin/ldconfig
|
%postun libs -p /sbin/ldconfig
|
||||||
|
|
||||||
%postun server
|
%postun server
|
||||||
%systemd_postun_with_restart %{daemon_unit}
|
%if %{with init_systemd}
|
||||||
|
%systemd_postun_with_restart %{daemon_name}.service
|
||||||
|
%endif
|
||||||
|
%if %{with init_sysv}
|
||||||
|
if [ $1 -ge 1 ]; then
|
||||||
|
/sbin/service %{daemon_name} condrestart >/dev/null 2>&1 || :
|
||||||
|
fi
|
||||||
|
%endif
|
||||||
|
|
||||||
%postun embedded -p /sbin/ldconfig
|
%postun embedded -p /sbin/ldconfig
|
||||||
|
|
||||||
@ -740,10 +806,10 @@ fi
|
|||||||
%doc storage/innobase/COPYING.Percona storage/innobase/COPYING.Google
|
%doc storage/innobase/COPYING.Percona storage/innobase/COPYING.Google
|
||||||
# although the default my.cnf contains only server settings, we put it in the
|
# although the default my.cnf contains only server settings, we put it in the
|
||||||
# common package because it can be used for client settings too.
|
# common package because it can be used for client settings too.
|
||||||
|
%dir %{_sysconfdir}/my.cnf.d
|
||||||
%if %{ship_my_cnf}
|
%if %{ship_my_cnf}
|
||||||
%config(noreplace) %{_sysconfdir}/my.cnf
|
%config(noreplace) %{_sysconfdir}/my.cnf
|
||||||
%config(noreplace) %{_sysconfdir}/my.cnf.d/mysql-clients.cnf
|
%config(noreplace) %{_sysconfdir}/my.cnf.d/mysql-clients.cnf
|
||||||
%dir %{_sysconfdir}/my.cnf.d
|
|
||||||
%endif
|
%endif
|
||||||
%dir %{_datadir}/%{name}
|
%dir %{_datadir}/%{name}
|
||||||
%{_datadir}/%{name}/charsets
|
%{_datadir}/%{name}/charsets
|
||||||
@ -852,21 +918,24 @@ fi
|
|||||||
%{_datadir}/%{name}/mysql_performance_tables.sql
|
%{_datadir}/%{name}/mysql_performance_tables.sql
|
||||||
%{_datadir}/%{name}/my-*.cnf
|
%{_datadir}/%{name}/my-*.cnf
|
||||||
|
|
||||||
%{?mysqld_unit:%{_unitdir}/%{mysqld_unit}}
|
%{?mysqld_unit:%{_unitdir}/%{mysqld_unit}.service}
|
||||||
%{_unitdir}/%{daemon_unit}
|
%{?with_init_systemd:%{_unitdir}/%{daemon_name}.service}
|
||||||
|
%{?with_init_sysv:%{_initddir}/%{daemon_name}}
|
||||||
%{_libexecdir}/mariadb-prepare-db-dir
|
%{_libexecdir}/mariadb-prepare-db-dir
|
||||||
%{_libexecdir}/mariadb-wait-ready
|
%{_libexecdir}/mariadb-wait-ready
|
||||||
%{_libexecdir}/mariadb-check-socket
|
%{_libexecdir}/mariadb-check-socket
|
||||||
%{_libexecdir}/mariadb-scripts-common
|
%{_libexecdir}/mariadb-scripts-common
|
||||||
|
|
||||||
%{_tmpfilesdir}/%{name}.conf
|
%{?with_init_systemd:%{_tmpfilesdir}/%{name}.conf}
|
||||||
%attr(0755,mysql,mysql) %dir %{_localstatedir}/run/mysqld
|
%attr(0755,mysql,mysql) %dir %{_localstatedir}/run/mysqld
|
||||||
%attr(0755,mysql,mysql) %dir %{_localstatedir}/run/%{name}
|
%attr(0755,mysql,mysql) %dir %{_localstatedir}/run/%{name}
|
||||||
%attr(0755,mysql,mysql) %dir %{_localstatedir}/lib/mysql
|
%attr(0755,mysql,mysql) %dir %{_localstatedir}/lib/mysql
|
||||||
%attr(0750,mysql,mysql) %dir %{_localstatedir}/log/%{name}
|
%attr(0750,mysql,mysql) %dir %{logfiledir}
|
||||||
%attr(0640,mysql,mysql) %config %ghost %verify(not md5 size mtime) %{_localstatedir}/log/%{name}/%{name}.log
|
%attr(0640,mysql,mysql) %config %ghost %verify(not md5 size mtime) %{logfile}
|
||||||
%config %ghost %verify(not md5 size mtime) %{_localstatedir}/log/mysqld.log
|
%if 0%{?old_logfile:1}
|
||||||
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
|
%config %ghost %verify(not md5 size mtime) %{old_logfile}
|
||||||
|
%endif
|
||||||
|
%config(noreplace) %{logrotateddir}/%{name}
|
||||||
|
|
||||||
%if %{with oqgraph}
|
%if %{with oqgraph}
|
||||||
%files oqgraph
|
%files oqgraph
|
||||||
@ -905,6 +974,7 @@ fi
|
|||||||
%changelog
|
%changelog
|
||||||
* Tue Jul 22 2014 Honza Horak <hhorak@redhat.com> - 1:10.0.12-5
|
* Tue Jul 22 2014 Honza Horak <hhorak@redhat.com> - 1:10.0.12-5
|
||||||
- Use variable for daemon unit name
|
- Use variable for daemon unit name
|
||||||
|
- Include SysV init script if built on older system
|
||||||
|
|
||||||
* Mon Jul 21 2014 Honza Horak <hhorak@redhat.com> - 1:10.0.12-4
|
* Mon Jul 21 2014 Honza Horak <hhorak@redhat.com> - 1:10.0.12-4
|
||||||
- Reformating spec and removing unnecessary snippets
|
- Reformating spec and removing unnecessary snippets
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
d /var/run/@RPM_PACKAGE_PREFIX@mysqld 0755 mysql mysql -
|
d /var/run/@DAEMON_NAME2@ 0755 mysql mysql -
|
||||||
d /var/run/@RPM_PACKAGE_PREFIX@mariadb 0755 mysql mysql -
|
d /var/run/@DAEMON_NAME@ 0755 mysql mysql -
|
||||||
|
177
mysql.init.in
Normal file
177
mysql.init.in
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# @DAEMON_NAME@ This shell script takes care of starting and stopping
|
||||||
|
# the MySQL subsystem (mysqld).
|
||||||
|
#
|
||||||
|
# chkconfig: - 64 36
|
||||||
|
# description: MySQL database server.
|
||||||
|
# processname: mysqld
|
||||||
|
# config: @sysconfdir@/my.cnf
|
||||||
|
# pidfile: /var/run/@DAEMON_NAME@/@DAEMON_NAME@.pid
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: mysqld
|
||||||
|
# Required-Start: $local_fs $remote_fs $network $named $syslog $time
|
||||||
|
# Required-Stop: $local_fs $remote_fs $network $named $syslog $time
|
||||||
|
# Short-Description: start and stop MySQL server
|
||||||
|
# Description: MySQL database server
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Source function library.
|
||||||
|
. /etc/rc.d/init.d/functions
|
||||||
|
|
||||||
|
# Source networking configuration.
|
||||||
|
. /etc/sysconfig/network
|
||||||
|
|
||||||
|
|
||||||
|
exec="@bindir@/mysqld_safe"
|
||||||
|
prog="@DAEMON_NAME@"
|
||||||
|
|
||||||
|
# Set timeouts here so they can be overridden from /etc/sysconfig/@DAEMON_NAME@
|
||||||
|
STARTTIMEOUT=300
|
||||||
|
STOPTIMEOUT=60
|
||||||
|
|
||||||
|
# User and group the daemon will run under
|
||||||
|
MYUSER=mysql
|
||||||
|
MYGROUP=mysql
|
||||||
|
|
||||||
|
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
|
||||||
|
|
||||||
|
lockfile=/var/lock/subsys/$prog
|
||||||
|
|
||||||
|
# get options from my.cnf
|
||||||
|
source "@libexecdir@/mariadb-scripts-common"
|
||||||
|
|
||||||
|
start(){
|
||||||
|
[ -x $exec ] || exit 5
|
||||||
|
# check to see if it's already running
|
||||||
|
MYSQLDRUNNING=0
|
||||||
|
if [ -f "$pidfile" ]; then
|
||||||
|
MYSQLPID=`cat "$pidfile" 2>/dev/null`
|
||||||
|
if [ -n "$MYSQLPID" ] && [ -d "/proc/$MYSQLPID" ] ; then
|
||||||
|
MYSQLDRUNNING=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
RESPONSE=`@bindir@/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
|
||||||
|
if [ $MYSQLDRUNNING = 1 ] && [ $? = 0 ]; then
|
||||||
|
# already running, do nothing
|
||||||
|
action $"Starting $prog: " /bin/true
|
||||||
|
ret=0
|
||||||
|
elif [ $MYSQLDRUNNING = 1 ] && echo "$RESPONSE" | grep -q "Access denied for user"
|
||||||
|
then
|
||||||
|
# already running, do nothing
|
||||||
|
action $"Starting $prog: " /bin/true
|
||||||
|
ret=0
|
||||||
|
else
|
||||||
|
@libexecdir@/mariadb-prepare-db-dir $MYUSER $MYGROUP || return 4
|
||||||
|
@libexecdir@/mariadb-check-socket || return 1
|
||||||
|
|
||||||
|
# Pass all the options determined above, to ensure consistent behavior.
|
||||||
|
# In many cases mysqld_safe would arrive at the same conclusions anyway
|
||||||
|
# but we need to be sure. (An exception is that we don't force the
|
||||||
|
# log-error setting, since this script doesn't really depend on that,
|
||||||
|
# and some users might prefer to configure logging to syslog.)
|
||||||
|
# Note: set --basedir to prevent probes that might trigger SELinux
|
||||||
|
# alarms, per bug #547485
|
||||||
|
$exec --datadir="$datadir" --socket="$socketfile" \
|
||||||
|
--pid-file="$pidfile" \
|
||||||
|
--basedir=@prefix@ --user=$MYUSER >/dev/null 2>&1 &
|
||||||
|
safe_pid=$!
|
||||||
|
|
||||||
|
# Wait until the daemon is up
|
||||||
|
@libexecdir@/mariadb-wait-ready "$safe_pid"
|
||||||
|
ret=$?
|
||||||
|
|
||||||
|
if [ $ret -eq 0 ]; then
|
||||||
|
action $"Starting $prog: " /bin/true
|
||||||
|
chmod o+r $pidfile >/dev/null 2>&1
|
||||||
|
touch $lockfile
|
||||||
|
else
|
||||||
|
action $"Starting $prog: " /bin/false
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return $ret
|
||||||
|
}
|
||||||
|
|
||||||
|
stop(){
|
||||||
|
if [ ! -f "$pidfile" ]; then
|
||||||
|
# not running; per LSB standards this is "ok"
|
||||||
|
action $"Stopping $prog: " /bin/true
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
MYSQLPID=`cat "$pidfile" 2>/dev/null`
|
||||||
|
if [ -n "$MYSQLPID" ]; then
|
||||||
|
if ! [ -d "/proc/$MYSQLPID" ] ; then
|
||||||
|
# process doesn't run anymore
|
||||||
|
action $"Stopping $prog: " /bin/true
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
/bin/kill "$MYSQLPID" >/dev/null 2>&1
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -eq 0 ]; then
|
||||||
|
TIMEOUT="$STOPTIMEOUT"
|
||||||
|
while [ $TIMEOUT -gt 0 ]; do
|
||||||
|
/bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break
|
||||||
|
sleep 1
|
||||||
|
let TIMEOUT=${TIMEOUT}-1
|
||||||
|
done
|
||||||
|
if [ $TIMEOUT -eq 0 ]; then
|
||||||
|
echo "Timeout error occurred trying to stop MySQL Daemon."
|
||||||
|
ret=1
|
||||||
|
action $"Stopping $prog: " /bin/false
|
||||||
|
else
|
||||||
|
rm -f $lockfile
|
||||||
|
rm -f "$socketfile"
|
||||||
|
action $"Stopping $prog: " /bin/true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# kill command failed, probably insufficient permissions
|
||||||
|
action $"Stopping $prog: " /bin/false
|
||||||
|
ret=4
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# failed to read pidfile, probably insufficient permissions
|
||||||
|
action $"Stopping $prog: " /bin/false
|
||||||
|
ret=4
|
||||||
|
fi
|
||||||
|
return $ret
|
||||||
|
}
|
||||||
|
|
||||||
|
restart(){
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
condrestart(){
|
||||||
|
[ -e $lockfile ] && restart || :
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# See how we were called.
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status -p "$pidfile" $prog
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
restart
|
||||||
|
;;
|
||||||
|
condrestart|try-restart)
|
||||||
|
condrestart
|
||||||
|
;;
|
||||||
|
reload)
|
||||||
|
exit 3
|
||||||
|
;;
|
||||||
|
force-reload)
|
||||||
|
restart
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
||||||
|
exit 2
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit $?
|
@ -1,6 +1,6 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=MySQL compatibility service (another name for @RPM_PACKAGE_PREFIX@mariadb.service; you should use @RPM_PACKAGE_PREFIX@mariadb.service instead)
|
Description=MySQL compatibility service (another name for @DAEMON_NAME@.service; you should use @DAEMON_NAME@.service instead)
|
||||||
BindsTo=@RPM_PACKAGE_PREFIX@mariadb.service
|
BindsTo=@DAEMON_NAME@.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
@ -9,4 +9,4 @@ RemainAfterExit=yes
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
Also=@RPM_PACKAGE_PREFIX@mariadb.service
|
Also=@DAEMON_NAME@.service
|
||||||
|
Loading…
Reference in New Issue
Block a user