summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dev-db/mysql-init-scripts/ChangeLog9
-rw-r--r--dev-db/mysql-init-scripts/files/mysql.conf1
-rw-r--r--dev-db/mysql-init-scripts/files/mysqld-prepare-db-dir83
-rw-r--r--dev-db/mysql-init-scripts/files/mysqld-wait-ready56
-rw-r--r--dev-db/mysql-init-scripts/files/mysqld.service43
-rw-r--r--dev-db/mysql-init-scripts/files/mysqld_at.service43
-rw-r--r--dev-db/mysql-init-scripts/mysql-init-scripts-2.0_pre1-r4.ebuild64
7 files changed, 298 insertions, 1 deletions
diff --git a/dev-db/mysql-init-scripts/ChangeLog b/dev-db/mysql-init-scripts/ChangeLog
index 397d3743e94d..3600061de8df 100644
--- a/dev-db/mysql-init-scripts/ChangeLog
+++ b/dev-db/mysql-init-scripts/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for dev-db/mysql-init-scripts
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/ChangeLog,v 1.27 2013/05/20 17:59:08 ago Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/ChangeLog,v 1.28 2013/09/03 18:49:48 pacho Exp $
+
+*mysql-init-scripts-2.0_pre1-r4 (03 Sep 2013)
+
+ 03 Sep 2013; Pacho Ramos <pacho@gentoo.org> +files/mysql.conf,
+ +files/mysqld-prepare-db-dir, +files/mysqld-wait-ready, +files/mysqld.service,
+ +files/mysqld_at.service, +mysql-init-scripts-2.0_pre1-r4.ebuild:
+ Add systemd support (#466084)
20 May 2013; Agostino Sarubbo <ago@gentoo.org>
mysql-init-scripts-2.0_pre1-r3.ebuild:
diff --git a/dev-db/mysql-init-scripts/files/mysql.conf b/dev-db/mysql-init-scripts/files/mysql.conf
new file mode 100644
index 000000000000..74cd5f836e76
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysql.conf
@@ -0,0 +1 @@
+d /var/run/mysqld 0755 mysql mysql -
diff --git a/dev-db/mysql-init-scripts/files/mysqld-prepare-db-dir b/dev-db/mysql-init-scripts/files/mysqld-prepare-db-dir
new file mode 100644
index 000000000000..80df2206680b
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysqld-prepare-db-dir
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+# This script creates the mysql data directory during first service start.
+# In subsequent starts, it does nothing much.
+
+# extract value of a MySQL option from config files
+# Usage: get_mysql_option SECTION VARNAME DEFAULT
+# result is returned in $result
+# We use my_print_defaults which prints all options from multiple files,
+# with the more specific ones later; hence take the last match.
+get_mysql_option(){
+ result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
+ if [ -z "$result" ]; then
+ # not found, use default
+ result="$3"
+ fi
+}
+
+# Defaults here had better match what mysqld_safe will default to
+get_mysql_option mysqld datadir "/var/lib/mysql"
+datadir="$result"
+get_mysql_option mysqld_safe log-error "/var/log/mysql/mysql.log"
+errlogfile="$result"
+
+# Absorb configuration settings from the specified systemd service file,
+# or the default "mysqld" service if not specified
+SERVICE_NAME="$1"
+if [ x"$SERVICE_NAME" = x ]
+then
+ SERVICE_NAME=mysqld.service
+fi
+
+myuser=`systemctl show -p User "${SERVICE_NAME}" |
+ sed 's/^User=//'`
+if [ x"$myuser" = x ]
+then
+ myuser=mysql
+fi
+
+mygroup=`systemctl show -p Group "${SERVICE_NAME}" |
+ sed 's/^Group=//'`
+if [ x"$mygroup" = x ]
+then
+ mygroup=mysql
+fi
+
+# Set up the errlogfile with appropriate permissions
+touch "$errlogfile"
+chown "$myuser:$mygroup" "$errlogfile"
+chmod 0640 "$errlogfile"
+[ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile"
+
+# Make the data directory
+if [ ! -d "$datadir/mysql" ] ; then
+ # First, make sure $datadir is there with correct permissions
+ # (note: if it's not, and we're not root, this'll fail ...)
+ if [ ! -e "$datadir" -a ! -h "$datadir" ]
+ then
+ mkdir -p "$datadir" || exit 1
+ fi
+ chown "$myuser:$mygroup" "$datadir"
+ chmod 0755 "$datadir"
+ [ -x /sbin/restorecon ] && /sbin/restorecon "$datadir"
+
+ # Now create the database
+ echo "Initializing MySQL database"
+ /usr/share/mysql/scripts/mysql_install_db \
+ --datadir="$datadir" --user="$myuser" --basedir="/usr"
+ ret=$?
+ if [ $ret -ne 0 ] ; then
+ echo "Initialization of MySQL database failed." >&2
+ echo "Perhaps /etc/mysql/my.cnf is misconfigured." >&2
+ # Clean up any partially-created database files
+ if [ ! -e "$datadir/mysql/user.frm" ] ; then
+ rm -rf "$datadir"/*
+ fi
+ exit $ret
+ fi
+ # In case we're running as root, make sure files are owned properly
+ chown -R "$myuser:$mygroup" "$datadir"
+fi
+
+exit 0
diff --git a/dev-db/mysql-init-scripts/files/mysqld-wait-ready b/dev-db/mysql-init-scripts/files/mysqld-wait-ready
new file mode 100644
index 000000000000..9e5d3e4d85e0
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysqld-wait-ready
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# This script waits for mysqld to be ready to accept connections
+# (which can be many seconds or even minutes after launch, if there's
+# a lot of crash-recovery work to do).
+# Running this as ExecStartPost is useful so that services declared as
+# "After mysqld" won't be started until the database is really ready.
+
+# Service file passes us the daemon's PID (actually, mysqld_safe's PID)
+daemon_pid="$1"
+
+# extract value of a MySQL option from config files
+# Usage: get_mysql_option SECTION VARNAME DEFAULT
+# result is returned in $result
+# We use my_print_defaults which prints all options from multiple files,
+# with the more specific ones later; hence take the last match.
+get_mysql_option(){
+ result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
+ if [ -z "$result" ]; then
+ # not found, use default
+ result="$3"
+ fi
+}
+
+# Defaults here had better match what mysqld_safe will default to
+get_mysql_option mysqld datadir "/var/lib/mysql"
+datadir="$result"
+get_mysql_option mysqld socket "/var/lib/mysql/mysql.sock"
+socketfile="$result"
+
+# Wait for the server to come up or for the mysqld process to disappear
+ret=0
+while /bin/true; do
+ RESPONSE=`/usr/bin/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
+ mret=$?
+ if [ $mret -eq 0 ]; then
+ break
+ fi
+ # exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
+ # anything else suggests a configuration error
+ if [ $mret -ne 1 -a $mret -ne 11 ]; then
+ ret=1
+ break
+ fi
+ # "Access denied" also means the server is alive
+ echo "$RESPONSE" | grep -q "Access denied for user" && break
+
+ # Check process still exists
+ if ! /bin/kill -0 $daemon_pid 2>/dev/null; then
+ ret=1
+ break
+ fi
+ sleep 1
+done
+
+exit $ret
diff --git a/dev-db/mysql-init-scripts/files/mysqld.service b/dev-db/mysql-init-scripts/files/mysqld.service
new file mode 100644
index 000000000000..3193ce2f0864
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysqld.service
@@ -0,0 +1,43 @@
+# It's not recommended to modify this file in-place, because it will be
+# overwritten during package upgrades. If you want to customize, the
+# best way is to create a file "/etc/systemd/system/mysqld.service",
+# containing
+# .include /lib/systemd/system/mysqld.service
+# ...make your changes here...
+# For more info about custom unit files, see
+# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
+
+# For example, if you want to increase mysql's open-files-limit to 10000,
+# you need to increase systemd's LimitNOFILE setting, so create a file named
+# "/etc/systemd/system/mysqld.service" containing:
+# .include /lib/systemd/system/mysqld.service
+# [Service]
+# LimitNOFILE=10000
+
+# Note: in F-17 and beyond, /usr/lib/... is recommended in the .include line
+# though /lib/... will still work.
+
+[Unit]
+Description=MySQL database server
+After=syslog.target
+After=network.target
+
+[Service]
+Type=simple
+User=mysql
+Group=mysql
+
+ExecStartPre=/usr/libexec/mysqld-prepare-db-dir %n
+# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
+# per bug #547485
+ExecStart=/usr/bin/mysqld_safe --basedir=/usr
+ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID
+
+# Give a reasonable amount of time for the server to start up/shut down
+TimeoutSec=300
+
+# Place temp files in a secure directory, not /tmp
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dev-db/mysql-init-scripts/files/mysqld_at.service b/dev-db/mysql-init-scripts/files/mysqld_at.service
new file mode 100644
index 000000000000..afcec18ba8cb
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysqld_at.service
@@ -0,0 +1,43 @@
+# It's not recommended to modify this file in-place, because it will be
+# overwritten during package upgrades. If you want to customize, the
+# best way is to create a file "/etc/systemd/system/mysqld.service",
+# containing
+# .include /lib/systemd/system/mysqld.service
+# ...make your changes here...
+# For more info about custom unit files, see
+# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
+
+# For example, if you want to increase mysql's open-files-limit to 10000,
+# you need to increase systemd's LimitNOFILE setting, so create a file named
+# "/etc/systemd/system/mysqld.service" containing:
+# .include /lib/systemd/system/mysqld.service
+# [Service]
+# LimitNOFILE=10000
+
+# Note: in F-17 and beyond, /usr/lib/... is recommended in the .include line
+# though /lib/... will still work.
+
+[Unit]
+Description=MySQL database server
+ConditionPathExists=/etc/mysql/my%I.cnf
+After=network.target
+
+[Service]
+Type=simple
+User=mysql
+Group=mysql
+
+ExecStartPre=/usr/libexec/mysqld-prepare-db-dir %n
+# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
+# per bug #547485
+ExecStart=/usr/bin/mysqld_safe --defaults-file=/etc/mysql/my%I.cnf --basedir=/usr
+ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID
+
+# Give a reasonable amount of time for the server to start up/shut down
+TimeoutSec=300
+
+# Place temp files in a secure directory, not /tmp
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dev-db/mysql-init-scripts/mysql-init-scripts-2.0_pre1-r4.ebuild b/dev-db/mysql-init-scripts/mysql-init-scripts-2.0_pre1-r4.ebuild
new file mode 100644
index 000000000000..560e8da31129
--- /dev/null
+++ b/dev-db/mysql-init-scripts/mysql-init-scripts-2.0_pre1-r4.ebuild
@@ -0,0 +1,64 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/mysql-init-scripts-2.0_pre1-r4.ebuild,v 1.1 2013/09/03 18:49:48 pacho Exp $
+
+inherit systemd
+
+DESCRIPTION="Gentoo MySQL init scripts."
+HOMEPAGE="http://www.gentoo.org/"
+SRC_URI=""
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
+IUSE=""
+
+DEPEND=""
+# This _will_ break with MySQL 5.0, 4.x, 3.x
+# It also NEEDS openrc for the save_options/get_options builtins.
+RDEPEND="!<dev-db/mysql-5.1"
+
+src_install() {
+ newconfd "${FILESDIR}/mysql-5.1.53-conf.d" "mysql"
+ newinitd "${FILESDIR}/mysql-5.1.67-init.d" "mysql"
+
+ # systemd unit installation
+ exeinto /usr/libexec
+ doexe "${FILESDIR}"/{mysqld-prepare-db-dir,mysqld-wait-ready}
+ systemd_dounit "${FILESDIR}/mysqld.service"
+ systemd_newunit "${FILESDIR}/mysqld_at.service" "mysqld@.service"
+ systemd_dotmpfilesd "${FILESDIR}/mysql.conf"
+
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}/logrotate.mysql" "mysql"
+}
+
+pkg_postinst() {
+ grep -sq mysql_slot "${ROOT}"/etc/conf.d/mysql
+ old_conf_present=$?
+ grep -sq get_slot_config "${ROOT}"/etc/init.d/mysql
+ old_init_present=$?
+
+ egrep -sq 'MY_CNF|MY_ARGS|(STARTUP|STOP)_TIMEOUT' "${ROOT}"/etc/conf.d/mysql
+ new_conf_present=$?
+ egrep -sq 'MY_ARGS|STOP_TIMEOUT' "${ROOT}"/etc/init.d/mysql
+ new_init_present=$?
+
+ einfo "Please note that if you are using multiple internal 'slots' in the"
+ einfo "old conf.d file, you should use multiple init files now."
+ echo old $old_conf_present $old_init_present
+ echo new $new_conf_present $new_init_present
+
+ # new scripts present
+ if [ $new_conf_present -eq 0 -a $new_init_present -eq 0 -a \
+ $old_conf_present -eq 1 -a $old_init_present -eq 1 ]; then
+ :
+ elif [ $old_conf_present -eq 0 -a $old_init_present -eq 0 -a \
+ $new_conf_present -eq 1 -a $new_init_present -eq 1 ]; then
+ ewarn "Old /etc/init.d/mysql and /etc/conf.d/mysql still present!"
+ ewarn "Update both of those files to the new versions!"
+ else
+ eerror "DANGER, mixed update of /etc/init.d/mysql and /etc/conf.d/mysql"
+ eerror "detected! You must update BOTH to the new versions"
+ fi
+}