* [gentoo-commits] proj/mysql:master commit in: dev-db/mysql-init-scripts/files/, dev-db/mysql-init-scripts/
@ 2014-08-06 3:20 Brian Evans
0 siblings, 0 replies; 5+ messages in thread
From: Brian Evans @ 2014-08-06 3:20 UTC (permalink / raw
To: gentoo-commits
commit: f85060dac7a6324a42aebf41bacbf2365f14b6ac
Author: Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 6 03:18:15 2014 +0000
Commit: Brian Evans <grknight <AT> tuffmail <DOT> com>
CommitDate: Wed Aug 6 03:19:19 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/mysql.git;a=commit;h=f85060da
[mysql-init-scripts] Retire the v1 series to the overlay since all tree versions can no longer use
Package-Manager: portage-2.2.8-r1
RepoMan-Options: --force
Manifest-Sign-Key: 67C78E1D
---
dev-db/mysql-init-scripts/ChangeLog | 11 +-
dev-db/mysql-init-scripts/files/mysql.conf.d | 80 +++++
dev-db/mysql-init-scripts/files/mysql.rc6 | 358 +++++++++++++++++++++
.../mysql-init-scripts/files/mysqlmanager.conf.d | 28 ++
dev-db/mysql-init-scripts/files/mysqlmanager.rc6 | 230 +++++++++++++
.../mysql-init-scripts-1.2.ebuild | 26 ++
6 files changed, 731 insertions(+), 2 deletions(-)
diff --git a/dev-db/mysql-init-scripts/ChangeLog b/dev-db/mysql-init-scripts/ChangeLog
index 8363a18..99b0317 100644
--- a/dev-db/mysql-init-scripts/ChangeLog
+++ b/dev-db/mysql-init-scripts/ChangeLog
@@ -1,7 +1,15 @@
# ChangeLog for dev-db/mysql-init-scripts
-# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
+# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
+*mysql-init-scripts-1.2 (06 Aug 2014)
+
+ 06 Aug 2014; Brian Evans <grknight@gentoo.org> +files/mysql.conf.d,
+ +files/mysql.rc6, +files/mysqlmanager.conf.d, +files/mysqlmanager.rc6,
+ +mysql-init-scripts-1.2.ebuild:
+ [mysql-init-scripts] Retire the v1 series to the overlay since all tree
+ versions can no longer use
+
06 Dec 2010; Robin H. Johnson <robbat2@gentoo.org> files/mysql-5.1.53-conf.d,
files/mysql-5.1.53-init.d:
Add stop timeout.
@@ -16,4 +24,3 @@
+files/mysql-5.1.53-init.d, +files/logrotate.mysql, +metadata.xml:
Finally revamp init scripts, based on bug #175783 submission from Davide
Pesavento <davidepesa@gmail.com>.
-
diff --git a/dev-db/mysql-init-scripts/files/mysql.conf.d b/dev-db/mysql-init-scripts/files/mysql.conf.d
new file mode 100644
index 0000000..15ff170
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysql.conf.d
@@ -0,0 +1,80 @@
+# Here is where we define which server(s) to start.
+# Additional parameters to be passed to mysqld at startup may be added here,
+# which will override the ones in "my.cnf".
+#
+# Below are described some suggested parameters to use.
+# The parameters not recognized will be passed through to the mysqld daemon
+# directly!
+# To avoid starting a server just comment it's definition.
+#
+# Last but not least, SPACES are NOT allowed inside the parameters!
+#
+# Parameter : description
+# ----------------+-----------------------------------------------------------
+# nice : integer [-20 .. 19 ] default 0
+# : change the priority of the server -20 (high) to 19 (low)
+# : see "man nice 1" for description
+# ----------------+-----------------------------------------------------------
+# mycnf : string [full path to my.cnf]
+# : specify the path to my.cnf file to be used
+# ----------------+-----------------------------------------------------------
+# startup_timeout : integer [seconds] default 15
+# : time to wait for mysqld up and running, after this it's
+# : marked as failed
+# ----------------+-----------------------------------------------------------
+#
+# Additional parameters
+# Parameter : description
+# ----------------+-----------------------------------------------------------
+# server-id : integer [1 .. 255]
+# : Uniquely identifies the server instance in the community
+# : of replication partners.
+# ----------------+-----------------------------------------------------------
+# port : integer [1025 .. 65535] default 3306
+# : Port number to use for connection.
+# : Looses any meaning if skip-networking is set.
+# ----------------+-----------------------------------------------------------
+# skip-networking : NULL
+# : Don't allow connection through TCP/IP.
+# ----------------+-----------------------------------------------------------
+# log-bin : string [name of the binlog files]
+# : Log update queries in binary format. Optional (but
+# : strongly recommended to avoid replication problems if
+# : server's hostname changes) argument should be the chosen
+# : location for the binary log files.
+# ----------------+-----------------------------------------------------------
+# Additionally the following variables are recognized:
+#
+# Be more verbose, accepts values from 1 to 4
+#DEBUG=4
+#
+# The default location for the "master" pid file
+#MYSQL_GLOB_PID_FILE="/var/run/svc-started-mysqld"
+#
+# The timeout for a failed attempt to stop a server
+#STOPTIMEOUT=120
+#
+
+# The parameters are passed in a bash array variable,
+# the variable name is mysql_slot_0_[server-num]
+# "server-num" is an optional number used to start multiple servers
+#
+# Examples:
+#
+# start a default server with default options:
+#mysql_slot_0=()
+#
+# start MySQL reniced, overriding some start parameters
+#mysql_slot_0=(
+# "nice=-5"
+# "server-id=123"
+# "log-bin="myhost"
+# "port=3307"
+#)
+#
+# start another server, different my.cnf
+#mysql_slot_0_1=(
+# "mycnf=/home/test/my.cnf"
+# "server-id=124"
+#)
+#
diff --git a/dev-db/mysql-init-scripts/files/mysql.rc6 b/dev-db/mysql-init-scripts/files/mysql.rc6
new file mode 100644
index 0000000..6578902
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysql.rc6
@@ -0,0 +1,358 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/mysql.rc6,v 1.2 2007/03/04 15:47:03 vivo Exp $
+
+# external binaries used: which, sed, tac
+
+# int in_list(char * elem, char * list)
+function in_list() {
+ local elem=${1:-"none"}
+ local list=${2:-","}
+
+ [[ "${list}" == "${list/,${elem},/}" ]] \
+ && return 1 \
+ || return 0
+}
+
+function wdebug() {
+ if [[ "${DEBUG}" -ge "${1}" ]] ; then
+ shift
+ echo "dbg: ${@}"
+ fi
+}
+
+depend() {
+ use dns net localmount netmount nfsmount
+}
+
+do_escape() {
+ # Ihatethisreallyverymuch
+ #echo "$1" | sed -e "s|'| |" -e "s|=|='|" -e "s|$|'|"
+ echo "$1"
+}
+
+# int get_slot_config(srv_slot=0, srv_num)
+get_slot_config() {
+ wdebug 4 ">>> get_slot_config()"
+
+ local srv srv_slot srv_num
+ srv_slot="${1:-"0"}"
+ srv_num="${2}"
+ MY_SUFFIX="-${srv_slot}"
+ # srv=array(0 => [srv_slot], 1 => [srv_num] )
+ srv=( ${srv_slot} ${srv_num} )
+
+ local tmp_eval="mysql_slot_${srv_slot}${srv_num:+"_"}${srv_num}[@]"
+ local conf_d_parameters="${!tmp_eval}"
+ if [[ "${srv_slot}" == "0" ]] ; then
+ MY_SUFFIX=''
+ # try some other default for the default server
+ [[ -z "${conf_d_parameters[@]}" ]] && conf_d_parameters=${mysql_slot[@]}
+ fi
+ [[ -z "${conf_d_parameters[@]}" ]] && conf_d_parameters=( )
+ basedir="" datadir="" pidfile="" socket=""
+ CHROOT="" NICE="" STARTUPTIMEOUT=5 STOPTIMEOUT=120
+
+ wdebug 3 "srv ${srv[@]}"
+ wdebug 3 "srv_slot ${srv_slot}"
+ wdebug 3 "srv_num ${srv_num}"
+ wdebug 3 "tmp_eval ${tmp_eval}"
+ wdebug 3 "conf_d_parameters ${conf_d_parameters[@]}"
+ wdebug 3 "MY_SUFFIX ${MY_SUFFIX}"
+
+ local tmp_eval="mysql_slot_${srv_slot}${srv_num:+"_"}${srv_num}[@]"
+ local conf_d_parameters="${!tmp_eval}"
+ # collations need to be defined *after* the character sets,
+ # so we will duplicate them
+ local collations=""
+ [[ ${conf_d_parameters[*]} == '()' ]] && conf_d_parameters=''
+
+ MY_CNF="/etc/mysql${MY_SUFFIX}/my.cnf"
+ # summa of unmanaged parameters
+ # some parameters may be present multiple times
+ unmanagedparams=""
+
+ # grab the parameters from conf.d/mysql definition
+ for my_default in ${conf_d_parameters[*]} ; do
+ case "${my_default}" in
+ nice=*)
+ NICE="${my_default#nice=}"
+ nice -n $NICE ls /tmp &>/dev/null || NICE=""
+ ;;
+ mycnf=*) MY_CNF="${my_default#mycnf=}" ;;
+ startup_timeout=*)
+ STARTUPTIMEOUT="${my_default#startup_timeout=}" ;;
+ basedir=*) basedir="${my_default#basedir=}" ;;
+ datadir=*) datadir="${my_default#datadir=}" ;;
+ pid-file=*) pidfile="${my_default#pid-file=}" ;;
+ socket=*) socket="${my_default#socket=}" ;;
+ *collation*=)
+ collations="${collations} --$( do_escape "${my_default}" )"
+ ;;
+ *=*)
+ # list of parameters we already have
+ # prepend "--" because my_print_defaults do it
+ unmanagedparams="${unmanagedparams} --$( do_escape "${my_default}" )"
+ ;;
+ *)
+ unmanagedparams="${unmanagedparams} --${my_default}"
+ ;;
+ esac
+ done
+
+ if [[ ! -r "${MY_CNF}" ]] ; then
+ ewarn "Cannot access ${MY_CNF} !"
+ MY_CNF=""
+ my_defaults=""
+ else
+ local my_print_defaults="$(which my_print_defaults${MY_SUFFIX} 2>/dev/null)"
+ if [[ ! -x "${my_print_defaults}" ]] ; then
+ eerror "my_print_defaults NOT found or not executable"
+ my_defaults=""
+ else
+ my_defaults=$( ${my_print_defaults} \
+ --loose-verbose \
+ --config-file="${MY_CNF}" \
+ mysqld server )
+ fi
+ fi
+
+ # grab needed parameters from my.cnf, don't override the ones from
+ # conf.d/mysql
+ for my_default in ${my_defaults} ; do
+ case "${my_default}" in
+ --basedir=*)
+ [[ -z "${basedir}" ]] && basedir="${my_default#--basedir=}" ;;
+ --datadir=*)
+ [[ -z "${datadir}" ]] && datadir="${my_default#--datadir=}" ;;
+ --pid-file=*)
+ [[ -z "${pidfile}" ]] && pidfile="${my_default#--pid-file=}" ;;
+ --socket=*)
+ [[ -z "${socket}" ]] && socket="${my_default#--socket=}" ;;
+ --*collation*=)
+ # the order is inversed because we want the conf.d ones overriden
+ collations="$( do_escape "${my_default}" ) ${collations}"
+ ;;
+ esac
+ done
+
+ # some parameters
+ basedir="${basedir:-"/usr"}"
+ datadir="${datadir:-"/var/lib/mysql${MY_SUFFIX}"}"
+ pidfile="${pidfile:-"/var/run/mysqld/mysqld${MY_SUFFIX}.pid"}"
+ socket="${socket:-"/var/run/mysqld/mysqld${MY_SUFFIX}.sock"}"
+ unmanagedparams="${unmanagedparams} ${collations}"
+
+ wdebug 3 "chroot dir => ${CHROOT}"
+ wdebug 3 "niceness => ${NICE}"
+ wdebug 3 "basedir => ${basedir}"
+ wdebug 3 "datadir => ${datadir}"
+ wdebug 3 "pidfile => ${pidfile}"
+ wdebug 3 "socket => ${socket}"
+ wdebug 3 "Unamanged => ${unmanagedparams}"
+
+ # extension for sleep tenth of seconds, not very portable so check it before
+ if sleep 0.01 ; then
+ STARTUPTIMEOUT=$(( STARTUPTIMEOUT * 10 ))
+ STOPTIMEOUT=$(( STOPTIMEOUT * 10 ))
+ TIMEUNIT=0.1
+ else
+ TIMEUNIT=1
+ fi
+
+ # push these out to the script
+ export MY_SUFFIX NICE MY_CNF pidfile datadir basedir socket CHROOT
+ export unmanagedparams STARTUPTIMEOUT STOPTIMEOUT TIMEUNIT
+ wdebug 4 "<<< get_slot_config() ok"
+ return 0
+}
+
+checkconfig() {
+ wdebug 4 ">>> checkconfig(\"${1}\")"
+ local datadir="${1}" pidfile="${2}" socket="${3}"
+
+ if [[ -n "${NOCHECK}" ]] ; then
+ rm -f "${pidfile}" "${socket}"
+ return 0
+ fi
+
+ if [[ ! -d "${datadir}" ]] ; then
+ eerror "MySQL datadir is empty or invalid"
+ eerror "Please check your my.cnf : ${MY_CNF}"
+ wdebug 4 "<<< checkconfig() KO"
+ return 1
+ fi
+
+ if [[ ! -d "${datadir}/mysql" ]] ; then
+ eerror "You don't appear to have the mysql database installed yet."
+ eerror "Please run /usr/bin/mysql_install_db to have this done..."
+ wdebug 4 "<<< checkconfig() KO"
+ return 1
+ fi
+
+ if [[ -f "${pidfile}" ]] ; then
+ kill -15 $(< ${pidfile}) 2>/dev/null
+ if [[ $? -eq 0 ]] ; then
+ # the process exist, we have a problem
+ eerror "\"${pidfile}\" is still present and the process is running."
+ eerror "Please stop it \"kill $(< ${pidfile})\" maybe ?"
+ wdebug 4 "<<< checkconfig() KO"
+ return 1
+ else
+ rm -f "${pidfile}"
+ fi
+ fi
+
+ if [[ -S "${socket}" ]] ; then
+ ewarn "Strange, the socket file already exist in \"${socket}\""
+ ewarn "it will be removed now and re-created by the MySQL server"
+ ewarn "BUT please make your checks."
+ rm -f "${socket}"
+ fi
+
+ wdebug 4 "<<< checkconfig() ok"
+ return 0
+}
+
+start() {
+ wdebug 4 ">>> start()"
+
+ MYSQL_GLOB_PID_FILE=${MYSQL_GLOB_PID_FILE:-"/var/run/svc-started-${SVCNAME/mysql/mysqld}"}
+ # servers are defined in /etc/conf.d/mysql
+ local serverlist=${!mysql_slot_*}
+ # provide default for empty conf.d/mysql
+ if [[ -z "${serverlist}" ]] ; then
+ serverlist=0
+ export mysql_slot_0=( )
+ fi
+ local retstatus timeout
+ local globretstatus=1
+ local srv_slot srv_num
+ # server MUST NOT share same location for these
+ local pidfilelist=',' datadirlist=',' socketlist=','
+ local ssd_thing=1
+ local mysqld_thing tmpnice
+
+ ebegin "Starting ${myservice}"
+ # try to start each server
+ for srv in ${serverlist[*]} ; do
+
+ srv_slot="${srv#mysql_slot_}"
+ if [[ "${srv_slot}" == "${srv_slot#*_}" ]] ; then
+ srv_num=''
+ else
+ srv_num="${srv_slot#*_}"
+ fi
+ srv_slot="${srv_slot%%_*}"
+
+ retstatus=0
+ get_slot_config "${srv_slot}" "${srv_num}" || retstatus=1
+
+ # checks
+ if ! checkconfig "${datadir}" "${pidfile}" "${socket}" ; then
+ retstatus=2 ; continue
+ fi
+ if in_list "${pidfile}" "${pidfilelist}" ; then
+ eerror "Sorry, won't start with same pid-file: ${pidfile}"
+ retstatus=3 ; continue
+ fi
+ if in_list "${datadir}" "${datadirlist}" ; then
+ eerror "Sorry, won't start with same datadir: ${datadir}"
+ retstatus=4 ; continue
+ fi
+ if in_list "${socket}" "${socketlist}" ; then
+ eerror "Sorry, won't start with same socket: ${socket}"
+ retstatus=5 ; continue
+ fi
+
+ einfo "Starting ${myservice} (${MY_CNF})"
+
+ mysqld_thing="${MY_CNF:+"--defaults-file="}${MY_CNF}"
+ mysqld_thing="${mysqld_thing} ${unmanagedparams}"
+ mysqld_thing="${mysqld_thing} --basedir=${basedir}"
+ mysqld_thing="${mysqld_thing} --datadir=${datadir}"
+ mysqld_thing="${mysqld_thing} --pid-file=${pidfile}"
+ mysqld_thing="${mysqld_thing} --socket=${socket}"
+
+ wdebug 2 "starting mysqld with: ${mysqld_thing}"
+
+ if [[ ${ssd_thing} -eq 1 ]] ; then
+ tmpnice="${NICE:+"--nicelevel "}${NICE}"
+ start-stop-daemon --quiet ${DEBUG/*/"--verbose"} --start \
+ --background ${tmpnice} --pidfile ${pidfile} \
+ --exec ${basedir}/sbin/mysqld${MY_SUFFIX} -- ${mysqld_thing} \
+ && sleep ${TIMEUNIT}
+ retstatus=$?
+ else
+ tmpnice="${NICE:+"nice -n "}${NICE}"
+ ${tmpnice} ${basedir}/sbin/mysqld${MY_SUFFIX} ${mysqld_thing} &
+ retstatus=0
+ fi
+
+ # only the first run is done by start-stop-daemon
+ ssd_thing=""
+
+ # wait for socket creation
+ wdebug 1
+ while ! [[ -S "${socket}" || "${STARTUPTIMEOUT}" -lt 1 || "${retstatus}" -ne 0 ]] ; do
+ STARTUPTIMEOUT=$(( STARTUPTIMEOUT - 1 ))
+ [[ ${DEBUG} -ge 1 ]] && echo -n "${STARTUPTIMEOUT},"
+ sleep ${TIMEUNIT}
+ done
+ wdebug 1 ""
+ if [[ ! -S "${socket}" ]] ; then
+ eerror "MySQL${MY_SUFFIX} NOT started (${retstatus})"
+ retstatus=1
+ else
+ globretstatus=0
+ pidfilelist="${pidfilelist}${pidfile},"
+ datadirlist="${datadirlist}${datadir},"
+ socketlist="${socketlist}${socket},"
+ echo "${srv_slot}${srv_num:+"_"}${srv_num}=${pidfile}" >> "${MYSQL_GLOB_PID_FILE}"
+ fi
+ done
+ # successfull if at least one mysqld started
+ wdebug 4 "<<< start()"
+ eend $globretstatus
+}
+
+stop() {
+ get_slot_config &> /dev/null
+ MYSQL_GLOB_PID_FILE=${MYSQL_GLOB_PID_FILE:-"/var/run/svc-started-${SVCNAME/mysql/mysqld}"}
+ local runwhat pidfile shutdown_elem
+ local PID cnt timeout=${STOPTIMEOUT:-"120"}
+ local retstatus=0
+ local shutdown_list="$(< "${MYSQL_GLOB_PID_FILE}" )"
+
+ ebegin "Stopping ${myservice}"
+ wdebug 5 "MYSQL_GLOB_PID_FILE: ${MYSQL_GLOB_PID_FILE}"
+ wdebug 5 "shutdown_list: ${shutdown_list}"
+ for shutdown_elem in ${shutdown_list} ; do
+ runwhat=${shutdown_elem%%=*}
+ pidfile=${shutdown_elem#*=}
+ timeout=${STOPTIMEOUT:-"120"}
+ PID=$(< "${pidfile}" )
+ wdebug 3 "runwhat ${runwhat}"
+ wdebug 3 "pidfile ${pidfile}"
+ wdebug 3 "timeout ${timeout}"
+ wdebug 3 "PID ${PID}"
+
+ einfo "Stopping mysqld (${runwhat})"
+
+ start-stop-daemon --quiet ${DEBUG/*/"--verbose"} --stop --pidfile "${pidfile}" &
+ wdebug 1 ""
+ while [[ -n "$PID" ]] \
+ && $( ps -Ao pid | grep -q "^ *$PID$" ) \
+ && [[ "${timeout}" -ge 1 ]]
+ do
+ timeout=$(($timeout - 1))
+ [[ ${DEBUG} -ge 1 ]] && echo -n "$(( $STOPTIMEOUT - $timeout )),"
+ sleep ${TIMEUNIT}
+ done
+ [[ "${timeout}" -lt 1 ]] && retstatus=1
+ done
+ sleep ${TIMEUNIT}
+ [[ "$retstatus" -eq 0 ]] && rm -f "$MYSQL_GLOB_PID_FILE"
+ eend ${retstatus}
+}
diff --git a/dev-db/mysql-init-scripts/files/mysqlmanager.conf.d b/dev-db/mysql-init-scripts/files/mysqlmanager.conf.d
new file mode 100644
index 0000000..8666f71
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysqlmanager.conf.d
@@ -0,0 +1,28 @@
+# Here is where we define which server(s) to start.
+# Additional parameters to be passed to mysqlmanager at startup may be added here,
+# which will override the ones in "my.cnf".
+#
+# To avoid starting a server just comment it's definition
+# here or it will rant (no default start).
+# Last but not least, spaces are NOT allowed inside the parameters!
+#
+# Below are described some suggested parameters to use.
+# The parameters not recognized will be passed through to the mysqlmanager directly.
+#
+# Parameter : description
+
+# ----------------+-----------------------------------------------------------
+# mycnf : string [full path to my.cnf]
+# : specify the path to my.cnf file to be used
+# : may contain a [manager] section
+# ----------------+-----------------------------------------------------------
+#
+# Basic default
+#
+#mysqlmanager_slot_0=()
+#
+# Start MySQL 5.0.X overriding the my.cnf path
+#mysqlmanager_slot_500=(
+# "mycnf=/home/test/my.cnf"
+#)
+#
diff --git a/dev-db/mysql-init-scripts/files/mysqlmanager.rc6 b/dev-db/mysql-init-scripts/files/mysqlmanager.rc6
new file mode 100644
index 0000000..9c16826
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysqlmanager.rc6
@@ -0,0 +1,230 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/mysqlmanager.rc6,v 1.1 2007/01/12 16:54:20 chtekk Exp $
+
+# external binaries used: which, sed, tac
+
+depend() {
+ use dns net localmount netmount nfsmount
+ #provide mysql
+}
+
+# int in_list(char * elem, char * list)
+function in_list() {
+ local elem=${1:-"none"}
+ local list=${2:-","}
+
+ [[ "${list}" == "${list/,${elem},/}" ]] \
+ && return 1 \
+ || return 0
+}
+
+do_escape() {
+ # Ihatethisreallyverymuch
+ #echo "$1" | sed -e "s|'| |" -e "s|=|='|" -e "s|$|'|"
+ echo "$1"
+}
+
+# int get_slot_config(srv_slot=0, srv_num)
+get_slot_config() {
+ [[ ${DEBUG} -ge 4 ]] && einfo ">>> get_slot_config(\"${1}\", \"${2}\")"
+
+ srv_slot="${1:-"0"}"
+ srv_num="${2}"
+ MY_SUFFIX="-${srv_slot}"
+ [[ "${MY_SUFFIX}" == '-0' ]] && MY_SUFFIX=''
+
+ basedir="" pidfile="" socket=""
+
+ local tmp_eval="mysqlmanager_slot_${srv_slot}${srv_num:+"_"}${srv_num}[@]"
+ local conf_d_parameters="${!tmp_eval}"
+ [[ ${conf_d_parameters[*]} == '()' ]] && conf_d_parameters=''
+
+ MY_CNF="/etc/mysql${MY_SUFFIX}/my.cnf"
+ # summa of unmanaged parameters
+ # some parameters may be present multiple times
+ unmanagedparams=""
+
+ # grab the parameters from conf.d/mysql definition
+ for my_default in ${conf_d_parameters[*]} ; do
+ case "${my_default}" in
+ mycnf=*) MY_CNF="${my_default#mycnf=}" ;;
+ basedir=*) basedir="${my_default#basedir=}" ;;
+ pid-file=*) pidfile="${my_default#pid-file=}" ;;
+ socket=*) socket="${my_default#socket=}" ;;
+ *=*)
+ # list of parameters we already have
+ # prepend "--" because my_print_defaults do it
+ unmanagedparams="${unmanagedparams} --$( do_escape "${my_default}" )"
+ ;;
+ *)
+ unmanagedparams="${unmanagedparams} --${my_default}"
+ ;;
+ esac
+ done
+
+ if [[ ! -r "${MY_CNF}" ]] ; then
+ ewarn "Cannot access ${MY_CNF} !"
+ MY_CNF=""
+ my_defaults=""
+ else
+ local my_print_defaults="$(which my_print_defaults${MY_SUFFIX} 2>/dev/null)"
+ if [[ ! -x "${my_print_defaults}" ]] ; then
+ eerror "my_print_defaults NOT found or not executable"
+ my_defaults=""
+ else
+ my_defaults=$( ${my_print_defaults} \
+ --loose-verbose \
+ --config-file="${MY_CNF}" \
+ manager )
+ fi
+ fi
+
+ # grab needed parameters from my.cnf, don't override the ones from
+ # conf.d/mysql
+ for my_default in ${my_defaults} ; do
+ case "${my_default}" in
+ --pid-file=*)
+ [[ -z "${pidfile}" ]] && pidfile="${my_default#--pid-file=}" ;;
+ --socket=*)
+ [[ -z "${socket}" ]] && socket="${my_default#--socket=}" ;;
+ esac
+ done
+
+ # still empty, I'm in doubt if assign a default or break, will see
+ basedir="${basedir:-"/usr"}"
+ pidfile="${pidfile:-"/var/run/mysqld/mysqlmanager${MY_SUFFIX}.pid"}"
+ socket="${socket:-"/var/run/mysqld/mysqlmanager${MY_SUFFIX}.sock"}"
+
+ if [[ ${DEBUG} -ge 3 ]] ; then
+ einfo "basedir => ${basedir}"
+ einfo "pidfile => ${pidfile}"
+ einfo "socket => ${socket}"
+ einfo "Unamanged => ${unmanagedparams}"
+ fi
+
+ # push these out to the script
+ export MY_SUFFIX MY_CNF pidfile basedir socket
+ export unmanagedparams
+ [[ ${DEBUG} -ge 4 ]] && einfo "<<< get_slot_config() ok"
+ return 0
+}
+
+start() {
+ [[ ${DEBUG} -ge 4 ]] && einfo ">>> start()"
+ MYSQL_GLOB_PID_FILE=${MYSQL_GLOB_PID_FILE:-"/var/run/svc-started-${SVCNAME}"}
+ # servers are defined in /etc/conf.d/mysql
+ local serverlist=${!mysqlmanager_slot_*}
+ # provide default for empty conf.d/mysql
+ if [[ -z "${serverlist}" ]] ; then
+ serverlist=0
+ export mysqlmanager_slot_0=()
+ fi
+ local retstatus timeout
+ local globretstatus=1
+ local srv_slot srv_num
+ # server MUST NOT share same location for these
+ local pidfilelist=',' socketlist=','
+
+ # additional security
+ rm -f "${MYSQL_GLOB_PID_FILE}" ; touch "${MYSQL_GLOB_PID_FILE}"
+ if [[ $? -ne 0 ]] ; then
+ eerror "cannot create MYSQL_GLOB_PID_FILE: ${MYSQL_GLOB_PID_FILE}"
+ [[ ${DEBUG} -ge 4 ]] && einfo "<<< start() KO"
+ return 1
+ fi
+
+ ebegin
+ # try to start each server
+ for srv in ${serverlist[*]} ; do
+ einfo "working on ${srv}"
+
+ srv_slot="${srv#mysqlmanager_slot_}"
+ if [[ "${srv_slot}" == "${srv_slot#*_}" ]] ; then
+ srv_num=''
+ else
+ srv_num="${srv_slot#*_}"
+ fi
+ srv_slot="${srv_slot%%_*}"
+
+ retstatus=0
+ get_slot_config "${srv_slot}" "${srv_num}" || retstatus=1
+
+ # timeout (seconds) before declaring the startup failed
+
+ # pre_run checks
+ if [[ "$retstatus" -eq 0 ]] ; then
+ if in_list "${pidfile}" "${pidfilelist}" ; then
+ retstatus=3
+ eerror "Sorry, won't start with same pid-file: ${pidfile}"
+ fi
+ if in_list "${socket}" "${socketlist}" ; then
+ retstatus=5
+ eerror "Sorry, won't start with same socket: ${socket}"
+ fi
+ fi
+
+ if [[ $retstatus -eq 0 ]] ; then
+ # additional security
+ rm -f ${pidfile} ${socket}
+ einfo "Starting mysqlmanager${MY_SUFFIX:+"_"}${srv_slot}${srv_num:+"_"}${srv_num} (${MY_CNF})"
+
+ [[ ${DEBUG} -ge 2 ]] && echo "starting mysqlmanager with: "${basedir}/sbin/mysqlmanager${MY_SUFFIX} ${unmanagedparams} --pid-file=${pidfile} --socket=${socket}
+
+ start-stop-daemon --quiet --start --background \
+ --pidfile "${pidfile}" \
+ --exec ${basedir}/sbin/mysqlmanager${MY_SUFFIX} \
+ -- \
+ ${MY_CNF:+"--defaults-file="}${MY_CNF} \
+ ${unmanagedparams} \
+ --pid-file=${pidfile} \
+ --socket=${socket}
+
+ retstatus=$?
+
+ if [[ "${retstatus}" -eq 0 ]] ; then
+ pidfilelist="${pidfilelist}${pidfile},"
+ socketlist="${socketlist}${socket},"
+ globretstatus=0
+ echo "${srv_slot}${srv_num:+"_"}${srv_num}=${pidfile}" >> "${MYSQL_GLOB_PID_FILE}"
+ fi
+ fi
+ done
+ # successfull if at least one mysqlmanager started
+ [[ ${DEBUG} -ge 4 ]] && einfo "<<< start()"
+ eend $globretstatus
+}
+
+stop () {
+ MYSQL_GLOB_PID_FILE=${MYSQL_GLOB_PID_FILE:-"/var/run/svc-started-${SVCNAME}"}
+ local runwhat pidfile shutdown_elem
+ local PID cnt timeout
+ local retstatus=0
+ local shutdown_list="$(< "${MYSQL_GLOB_PID_FILE}" )"
+
+ # shutdown in reverse order
+ ebegin
+ for shutdown_elem in $shutdown_list; do
+ runwhat=${shutdown_elem%%=*}
+ pidfile=${shutdown_elem#*=}
+ timeout=${STOPTIMEOUT:-"10"}
+
+ einfo "Stopping mysqlmanager (${runwhat})"
+
+ PID=$(cat "${pidfile}" 2>/dev/null)
+ start-stop-daemon --stop --quiet --pidfile="${pidfile}"
+ [[ ${DEBUG} -ge 1 ]] && echo ""
+ while [[ -n "$PID" && $( kill -0 $PID 2>/dev/null ) && "${timeout}" -ge 1 ]] ; do
+ timeout=$(($timeout - 1))
+ [[ ${DEBUG} -ge 1 ]] && echo -n $(( $STOPTIMEOUT - $timeout ))
+ sleep 1
+ done
+ if [[ "${timeout}" -lt 1 ]] ; then
+ retstatus=$(( $retstatus + 1 ))
+ fi
+ done
+
+ [[ "$retstatus" -eq 0 ]] && rm -f "$MYSQL_GLOB_PID_FILE"
+ eend $retstatus
+}
diff --git a/dev-db/mysql-init-scripts/mysql-init-scripts-1.2.ebuild b/dev-db/mysql-init-scripts/mysql-init-scripts-1.2.ebuild
new file mode 100644
index 0000000..a0cb10f
--- /dev/null
+++ b/dev-db/mysql-init-scripts/mysql-init-scripts-1.2.ebuild
@@ -0,0 +1,26 @@
+# Copyright 1999-2014 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-1.2.ebuild,v 1.4 2010/10/19 05:53:42 leio Exp $
+
+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=""
+RDEPEND=""
+
+src_install() {
+ newconfd "${FILESDIR}/mysql.conf.d" "mysql"
+ newconfd "${FILESDIR}/mysqlmanager.conf.d" "mysqlmanager"
+
+ newinitd "${FILESDIR}/mysql.rc6" "mysql"
+ newinitd "${FILESDIR}/mysqlmanager.rc6" "mysqlmanager"
+
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}/logrotate.mysql" "mysql"
+}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/mysql:master commit in: dev-db/mysql-init-scripts/files/, dev-db/mysql-init-scripts/
@ 2014-08-19 0:34 Brian Evans
0 siblings, 0 replies; 5+ messages in thread
From: Brian Evans @ 2014-08-19 0:34 UTC (permalink / raw
To: gentoo-commits
commit: 9b8136f5f1ce8cd7616028da61cb65e354ccda5e
Author: Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 19 00:33:53 2014 +0000
Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Aug 19 00:34:32 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/mysql.git;a=commit;h=9b8136f5
[mysql-init-scripts] Add simple config check and support for chroot. Copy old init scripts here to RIP
---
.../files/{mysql-5.1.53-conf.d => conf.d-2.0} | 13 +-
dev-db/mysql-init-scripts/files/init.d-2.0 | 153 +++++++++++++++++++++
dev-db/mysql-init-scripts/files/logrotate.mysql | 6 +-
.../mysql-init-scripts/files/mysql-5.1.53-conf.d | 13 +-
.../mysql-init-scripts/files/mysql-5.1.67-init.d | 118 ++++++++++++++++
dev-db/mysql-init-scripts/files/mysql.conf | 1 +
dev-db/mysql-init-scripts/files/mysqld-wait-ready | 56 ++++++++
dev-db/mysql-init-scripts/files/mysqld.service | 26 ++++
dev-db/mysql-init-scripts/files/mysqld_at.service | 26 ++++
.../mysql-init-scripts-2.0.ebuild | 68 +++++++++
10 files changed, 465 insertions(+), 15 deletions(-)
diff --git a/dev-db/mysql-init-scripts/files/mysql-5.1.53-conf.d b/dev-db/mysql-init-scripts/files/conf.d-2.0
similarity index 90%
copy from dev-db/mysql-init-scripts/files/mysql-5.1.53-conf.d
copy to dev-db/mysql-init-scripts/files/conf.d-2.0
index 3c79b13..781c8f5 100644
--- a/dev-db/mysql-init-scripts/files/mysql-5.1.53-conf.d
+++ b/dev-db/mysql-init-scripts/files/conf.d-2.0
@@ -1,6 +1,6 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header$
+# $Header: $
# If you want a non-stock location for the config file, uncomment or update
# either of these as needed. If you do use it, you must make sure that none of
@@ -33,7 +33,7 @@ STOP_TIMEOUT=120
# integer [-20 .. 19 ] default 0
# change the priority of the server -20 (high) to 19 (low)
-# see "man nice 1" for description
+# see nice(1) for description
#NICE=0
# See start-stop-daemon(8) for possible settings
@@ -72,7 +72,8 @@ STOP_TIMEOUT=120
# But uncomment this next instead if you think it should.
#rc_provide="mysql"
-# Tell OpenRC about our config file
-[ -n "${MY_CNF}" ] && rc_config="${MY_CNF}"
-
+# The conditional above has a false-positive "failure" return value as a
+# side-effect, and since it's the last statement, without the next line, this
+# script returns failure.
+return 0
# vim: ft=gentoo-conf-d et ts=4 sw=4:
diff --git a/dev-db/mysql-init-scripts/files/init.d-2.0 b/dev-db/mysql-init-scripts/files/init.d-2.0
new file mode 100644
index 0000000..5dc99d2
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/init.d-2.0
@@ -0,0 +1,153 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+extra_commands="checkconfig"
+
+depend() {
+ use net.lo
+ # localmount needed for $basedir
+ need localmount
+}
+
+get_config() {
+ my_print_defaults --config-file="$1" mysqld |
+ sed -n -e "s/^--$2=//p"
+}
+
+mysql_svcname() {
+ local ebextra=
+ case "${SVCNAME}" in
+ mysql*) ;;
+ *) ebextra=" (mysql)" ;;
+ esac
+ echo "${SVCNAME}${ebextra}"
+}
+
+start() {
+ # Check for old conf.d variables that mean migration was not yet done.
+ set | egrep -sq '^(mysql_slot_|MYSQL_BLOG_PID_FILE|STOPTIMEOUT)'
+ rc=$?
+ # Yes, MYSQL_INIT_I_KNOW_WHAT_I_AM_DOING is a hidden variable.
+ # It does have a use in testing, as it is possible to build a config file
+ # that works with both the old and new init scripts simulateously.
+ if [ "${rc}" = 0 -a -z "${MYSQL_INIT_I_KNOW_WHAT_I_AM_DOING}" ]; then
+ eerror "You have not updated your conf.d for the new mysql-init-scripts-2 revamp."
+ eerror "Not proceeding because it may be dangerous."
+ return 1
+ fi
+
+ # Check the config or die
+ checkconfig || return 1
+
+ # Now we can startup
+ ebegin "Starting $(mysql_svcname)"
+
+ MY_CNF="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
+
+ if [ ! -r "${MY_CNF}" ] ; then
+ eerror "Cannot read the configuration file \`${MY_CNF}'"
+ return 1
+ fi
+
+ # tail -n1 is critical as these we only want the last instance of the option
+ local basedir=$(get_config "${MY_CNF}" basedir | tail -n1)
+ local datadir=$(get_config "${MY_CNF}" datadir | tail -n1)
+ local pidfile=$(get_config "${MY_CNF}" pid-file | tail -n1)
+ local socket=$(get_config "${MY_CNF}" socket | tail -n1)
+ local chroot=$(get_config "${MY_CNF}" chroot | tail -n1)
+
+ if [ -n "${chroot}" ] ; then
+ socket="${chroot}/${socket}"
+ pidfile="${chroot}/${pidfile}"
+ fi
+
+ if [ ! -d "${datadir}" ] ; then
+ eerror "MySQL datadir \`${datadir}' is empty or invalid"
+ eerror "Please check your config file \`${MY_CNF}'"
+ return 1
+ fi
+
+ if [ ! -d "${datadir}"/mysql ] ; then
+ # find which package is installed to report an error
+ local EROOT=$(portageq envvar EROOT)
+ local DBPKG_P=$(portageq match ${EROOT} $(portageq expand_virtual ${EROOT} virtual/mysql))
+ if [[ -z ${DBPKG_P} ]] ; then
+ eerror "You don't appear to have a server package installed yet."
+ else
+ eerror "You don't appear to have the mysql database installed yet."
+ eerror "Please run \`emerge --config =${DBPKG_P}\` to have this done..."
+ fi
+ return 1
+ fi
+
+ local piddir="${pidfile%/*}"
+ checkpath -d --owner mysql:mysql --mode 0755 "$piddir"
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ eerror "Directory $piddir for pidfile does not exist and cannot be created"
+ return 1
+ fi
+
+ local startup_timeout=${STARTUP_TIMEOUT:-900}
+ local startup_early_timeout=${STARTUP_EARLY_TIMEOUT:-1000}
+ local tmpnice="${NICE:+"--nicelevel "}${NICE}"
+ local tmpionice="${IONICE:+"--ionice "}${IONICE}"
+ start-stop-daemon \
+ ${DEBUG:+"--verbose"} \
+ --start \
+ --exec "${basedir}"/sbin/mysqld \
+ --pidfile "${pidfile}" \
+ --background \
+ --wait ${startup_early_timeout} \
+ ${tmpnice} \
+ ${tmpionice} \
+ -- --defaults-file="${MY_CNF}" ${MY_ARGS}
+ local ret=$?
+ if [ ${ret} -ne 0 ] ; then
+ eend ${ret}
+ return ${ret}
+ fi
+
+ ewaitfile ${startup_timeout} "${socket}"
+ eend $? || return 1
+
+ save_options pidfile "${pidfile}"
+ save_options basedir "${basedir}"
+}
+
+stop() {
+ ebegin "Stopping $(mysql_svcname)"
+
+ local pidfile="$(get_options pidfile)"
+ local basedir="$(get_options basedir)"
+ local stop_timeout=${STOP_TIMEOUT:-120}
+
+ start-stop-daemon \
+ ${DEBUG:+"--verbose"} \
+ --stop \
+ --exec "${basedir}"/sbin/mysqld \
+ --pidfile "${pidfile}" \
+ --retry ${stop_timeout}
+ eend $?
+}
+
+checkconfig() {
+ local basedir=$(get_config "${MY_CNF}" basedir | tail -n1)
+ ebegin "Checking mysqld configuration"
+
+ # Suppress output to check the return value
+ "${basedir}"/sbin/mysqld --help --verbose &> /dev/null
+
+ # If the above command does not return 0,
+ # then there is an error to echo to the user
+ if [ $? -ne 0 ] ; then
+ "${basedir}"/sbin/mysqld --help --verbose > /dev/null
+ fi
+
+ eend $? "MySQL config check failed"
+}
+
+# vim: filetype=gentoo-init-d sw=2 ts=2 sts=2 noet:
+
diff --git a/dev-db/mysql-init-scripts/files/logrotate.mysql b/dev-db/mysql-init-scripts/files/logrotate.mysql
index b3d50de..3399e30 100644
--- a/dev-db/mysql-init-scripts/files/logrotate.mysql
+++ b/dev-db/mysql-init-scripts/files/logrotate.mysql
@@ -1,6 +1,6 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header$
+# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/logrotate.mysql,v 1.2 2011/01/13 20:06:06 robbat2 Exp $
/var/log/mysql/mysql.err /var/log/mysql/mysql.log /var/log/mysql/mysqld.err {
monthly
@@ -10,6 +10,6 @@ size 5M
sharedscripts
missingok
postrotate
-/bin/kill -HUP `cat /var/run/mysqld/mysqld.pid`
+[ -f /var/run/mysqld/mysqld.pid ] && /bin/kill -HUP `cat /var/run/mysqld/mysqld.pid`
endscript
}
diff --git a/dev-db/mysql-init-scripts/files/mysql-5.1.53-conf.d b/dev-db/mysql-init-scripts/files/mysql-5.1.53-conf.d
index 3c79b13..df4c3a4 100644
--- a/dev-db/mysql-init-scripts/files/mysql-5.1.53-conf.d
+++ b/dev-db/mysql-init-scripts/files/mysql-5.1.53-conf.d
@@ -1,6 +1,6 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header$
+# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/mysql-5.1.53-conf.d,v 1.2 2011/01/15 17:54:31 robbat2 Exp $
# If you want a non-stock location for the config file, uncomment or update
# either of these as needed. If you do use it, you must make sure that none of
@@ -33,7 +33,7 @@ STOP_TIMEOUT=120
# integer [-20 .. 19 ] default 0
# change the priority of the server -20 (high) to 19 (low)
-# see "man nice 1" for description
+# see nice(1) for description
#NICE=0
# See start-stop-daemon(8) for possible settings
@@ -72,7 +72,8 @@ STOP_TIMEOUT=120
# But uncomment this next instead if you think it should.
#rc_provide="mysql"
-# Tell OpenRC about our config file
-[ -n "${MY_CNF}" ] && rc_config="${MY_CNF}"
-
+# The conditional above has a false-positive "failure" return value as a
+# side-effect, and since it's the last statement, without the next line, this
+# script returns failure.
+return 0
# vim: ft=gentoo-conf-d et ts=4 sw=4:
diff --git a/dev-db/mysql-init-scripts/files/mysql-5.1.67-init.d b/dev-db/mysql-init-scripts/files/mysql-5.1.67-init.d
new file mode 100644
index 0000000..511a6bf
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysql-5.1.67-init.d
@@ -0,0 +1,118 @@
+#!/sbin/runscript
+# 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/files/mysql-5.1.67-init.d,v 1.1 2013/01/18 01:51:47 robbat2 Exp $
+
+depend() {
+ use net.lo
+ # localmount needed for $basedir
+ need localmount
+}
+
+get_config() {
+ my_print_defaults --config-file="$1" mysqld |
+ sed -n -e "s/^--$2=//p"
+}
+
+mysql_svcname() {
+ local ebextra=
+ case "${SVCNAME}" in
+ mysql*) ;;
+ *) ebextra=" (mysql)" ;;
+ esac
+ echo "${SVCNAME}${ebextra}"
+}
+
+start() {
+ # Check for old conf.d variables that mean migration was not yet done.
+ set | egrep -sq '^(mysql_slot_|MYSQL_BLOG_PID_FILE|STOPTIMEOUT)'
+ rc=$?
+ # Yes, MYSQL_INIT_I_KNOW_WHAT_I_AM_DOING is a hidden variable.
+ # It does have a use in testing, as it is possible to build a config file
+ # that works with both the old and new init scripts simulateously.
+ if [ "${rc}" = 0 -a -z "${MYSQL_INIT_I_KNOW_WHAT_I_AM_DOING}" ]; then
+ eerror "You have not updated your conf.d for the new mysql-init-scripts-2 revamp."
+ eerror "Not proceeding because it may be dangerous."
+ return 1
+ fi
+
+ # Now we can startup
+ ebegin "Starting $(mysql_svcname)"
+
+ MY_CNF="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
+
+ if [ ! -r "${MY_CNF}" ] ; then
+ eerror "Cannot read the configuration file \`${MY_CNF}'"
+ return 1
+ fi
+
+ # tail -n1 is critical as these we only want the last instance of the option
+ local basedir=$(get_config "${MY_CNF}" basedir | tail -n1)
+ local datadir=$(get_config "${MY_CNF}" datadir | tail -n1)
+ local pidfile=$(get_config "${MY_CNF}" pid-file | tail -n1)
+ local socket=$(get_config "${MY_CNF}" socket | tail -n1)
+
+ if [ ! -d "${datadir}" ] ; then
+ eerror "MySQL datadir \`${datadir}' is empty or invalid"
+ eerror "Please check your config file \`${MY_CNF}'"
+ return 1
+ fi
+
+ if [ ! -d "${datadir}"/mysql ] ; then
+ eerror "You don't appear to have the mysql database installed yet."
+ eerror "Please run /usr/bin/mysql_install_db to have this done..."
+ return 1
+ fi
+
+ local piddir="${pidfile%/*}"
+ checkpath -d --owner mysql:mysql --mode 0755 "$piddir"
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ eerror "Directory $piddir for pidfile does not exist and cannot be created"
+ return 1
+ fi
+
+ local startup_timeout=${STARTUP_TIMEOUT:-900}
+ local startup_early_timeout=${STARTUP_EARLY_TIMEOUT:-1000}
+ local tmpnice="${NICE:+"--nicelevel "}${NICE}"
+ local tmpionice="${IONICE:+"--ionice "}${IONICE}"
+ start-stop-daemon \
+ ${DEBUG:+"--verbose"} \
+ --start \
+ --exec "${basedir}"/sbin/mysqld \
+ --pidfile "${pidfile}" \
+ --background \
+ --wait ${startup_early_timeout} \
+ ${tmpnice} \
+ ${tmpionice} \
+ -- --defaults-file="${MY_CNF}" ${MY_ARGS}
+ local ret=$?
+ if [ ${ret} -ne 0 ] ; then
+ eend ${ret}
+ return ${ret}
+ fi
+
+ ewaitfile ${startup_timeout} "${socket}"
+ eend $? || return 1
+
+ save_options pidfile "${pidfile}"
+ save_options basedir "${basedir}"
+}
+
+stop() {
+ ebegin "Stopping $(mysql_svcname)"
+
+ local pidfile="$(get_options pidfile)"
+ local basedir="$(get_options basedir)"
+ local stop_timeout=${STOP_TIMEOUT:-120}
+
+ start-stop-daemon \
+ ${DEBUG:+"--verbose"} \
+ --stop \
+ --exec "${basedir}"/sbin/mysqld \
+ --pidfile "${pidfile}" \
+ --retry ${stop_timeout}
+ eend $?
+}
+# vim: filetype=gentoo-init-d sw=2 ts=2 sts=2 noet:
+
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 0000000..74cd5f8
--- /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-wait-ready b/dev-db/mysql-init-scripts/files/mysqld-wait-ready
new file mode 100644
index 0000000..9e5d3e4
--- /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 0000000..de9ea2f
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysqld.service
@@ -0,0 +1,26 @@
+[Unit]
+Description=MySQL database server
+After=syslog.target
+After=network.target
+
+[Service]
+Type=simple
+User=mysql
+Group=mysql
+
+# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
+# https://bugzilla.redhat.com/show_bug.cgi?id=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
+
+# We rely on systemd, not mysqld_safe, to restart mysqld if it dies
+Restart=always
+
+# 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 0000000..f46cf9e
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysqld_at.service
@@ -0,0 +1,26 @@
+[Unit]
+Description=MySQL database server
+ConditionPathExists=/etc/mysql/my%I.cnf
+After=network.target
+
+[Service]
+Type=simple
+User=mysql
+Group=mysql
+
+# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
+# https://bugzilla.redhat.com/show_bug.cgi?id=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
+
+# We rely on systemd, not mysqld_safe, to restart mysqld if it dies
+Restart=always
+
+# 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.ebuild b/dev-db/mysql-init-scripts/mysql-init-scripts-2.0.ebuild
new file mode 100644
index 0000000..1baca5e
--- /dev/null
+++ b/dev-db/mysql-init-scripts/mysql-init-scripts-2.0.ebuild
@@ -0,0 +1,68 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+EAPI=5
+
+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"
+# Need to set S due to PMS saying we need it existing, but no SRC_URI
+S=${WORKDIR}
+
+src_install() {
+ newconfd "${FILESDIR}/conf.d-${PV}" "mysql"
+ newinitd "${FILESDIR}/init.d-${PV}" "mysql"
+
+ # systemd unit installation
+ exeinto /usr/libexec
+ doexe "${FILESDIR}"/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
+}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/mysql:master commit in: dev-db/mysql-init-scripts/files/, dev-db/mysql-init-scripts/
@ 2015-05-12 19:39 Brian Evans
0 siblings, 0 replies; 5+ messages in thread
From: Brian Evans @ 2015-05-12 19:39 UTC (permalink / raw
To: gentoo-commits
commit: 61d458966df5cfc46055cd438e314b2416efd63e
Author: layman <layman <AT> localhost>
AuthorDate: Tue May 12 19:39:42 2015 +0000
Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue May 12 19:39:42 2015 +0000
URL: https://gitweb.gentoo.org/proj/mysql.git/commit/?id=61d45896
[mysql-init-scripts] First attempt at s6 integration which OpenRC now supports. Still need to come up with a way to wait until mysql is ready
dev-db/mysql-init-scripts/files/init.d-s6 | 98 ++++++++++++++++++++++
dev-db/mysql-init-scripts/files/run-s6 | 18 ++++
dev-db/mysql-init-scripts/metadata.xml | 3 +
.../mysql-init-scripts-2.1_alpha1.ebuild | 77 +++++++++++++++++
4 files changed, 196 insertions(+)
diff --git a/dev-db/mysql-init-scripts/files/init.d-s6 b/dev-db/mysql-init-scripts/files/init.d-s6
new file mode 100644
index 0000000..4c2424f
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/init.d-s6
@@ -0,0 +1,98 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+depend() {
+ use net.lo
+ # localmount needed for $basedir
+ need localmount s6-svscan
+}
+
+get_config() {
+ my_print_defaults --config-file="$1" mysqld |
+ sed -n -e "s/^--$2=//p"
+}
+
+mysql_svcname() {
+ local ebextra=
+ case "${SVCNAME}" in
+ mysql*) ;;
+ *) ebextra=" (mysql)" ;;
+ esac
+ echo "${SVCNAME}${ebextra}"
+}
+
+extra_commands="checkconfig"
+supervisor=s6
+name=$(mysql_svcname)
+#s6_svwait_options_start="-U -t $((1000*${STARTUP_EARLY_TIMEOUT:-1000}))"
+
+start_pre() {
+ # Check the config or die
+ checkconfig || return 1
+
+ MY_CNF="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
+
+ if [ ! -r "${MY_CNF}" ] ; then
+ eerror "Cannot read the configuration file \`${MY_CNF}'"
+ return 1
+ fi
+
+ # tail -n1 is critical as these we only want the last instance of the option
+ local datadir=$(get_config "${MY_CNF}" datadir | tail -n1)
+ local pidfile=$(get_config "${MY_CNF}" pid-file | tail -n1)
+ local socket=$(get_config "${MY_CNF}" socket | tail -n1)
+ local chroot=$(get_config "${MY_CNF}" chroot | tail -n1)
+
+ if [ -n "${chroot}" ] ; then
+ socket="${chroot}/${socket}"
+ pidfile="${chroot}/${pidfile}"
+ fi
+
+ if [ ! -d "${datadir}" ] ; then
+ eerror "MySQL datadir \`${datadir}' is empty or invalid"
+ eerror "Please check your config file \`${MY_CNF}'"
+ return 1
+ fi
+
+ if [ ! -d "${datadir}"/mysql ] ; then
+ # find which package is installed to report an error
+ local EROOT=$(portageq envvar EROOT)
+ local DBPKG_P=$(portageq match ${EROOT} $(portageq expand_virtual ${EROOT} virtual/mysql))
+ if [[ -z ${DBPKG_P} ]] ; then
+ eerror "You don't appear to have a server package installed yet."
+ else
+ eerror "You don't appear to have the mysql database installed yet."
+ eerror "Please run \`emerge --config =${DBPKG_P}\` to have this done..."
+ fi
+ return 1
+ fi
+
+ local piddir="${pidfile%/*}"
+ checkpath -d --owner mysql:mysql --mode 0755 "$piddir"
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ eerror "Directory $piddir for pidfile does not exist and cannot be created"
+ return 1
+ fi
+}
+
+checkconfig() {
+ local basedir=$(get_config "${MY_CNF}" basedir | tail -n1)
+ ebegin "Checking mysqld configuration"
+
+ # Suppress output to check the return value
+ "${basedir}"/sbin/mysqld --help --verbose &> /dev/null
+
+ # If the above command does not return 0,
+ # then there is an error to echo to the user
+ if [ $? -ne 0 ] ; then
+ "${basedir}"/sbin/mysqld --help --verbose > /dev/null
+ fi
+
+ eend $? "MySQL config check failed"
+}
+
+# vim: filetype=gentoo-init-d sw=2 ts=2 sts=2 noet:
+
diff --git a/dev-db/mysql-init-scripts/files/run-s6 b/dev-db/mysql-init-scripts/files/run-s6
new file mode 100644
index 0000000..64a89c7
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/run-s6
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+get_config() {
+ my_print_defaults --config-file="$1" mysqld |
+ sed -n -e "s/^--$2=//p"
+}
+
+SVCNAME=$(cd `dirname $0` && pwd | awk -F/ '{ print $NF }' )
+
+source "${ROOT:-/}etc/conf.d/${SVCNAME}"
+
+MY_CNF="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
+
+basedir=$(get_config "${MY_CNF}" basedir | tail -n1)
+exec s6-notifywhenup -t ${STARTUP_TIMEOUT:-900} "${basedir}"/sbin/mysqld --defaults-file="${MY_CNF}" ${MY_ARGS}
diff --git a/dev-db/mysql-init-scripts/metadata.xml b/dev-db/mysql-init-scripts/metadata.xml
index abf3529..669c23b 100644
--- a/dev-db/mysql-init-scripts/metadata.xml
+++ b/dev-db/mysql-init-scripts/metadata.xml
@@ -2,4 +2,7 @@
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<herd>mysql</herd>
+ <use>
+ <flag name="s6">Install an OpenRC service that monitors using <package>sys-apps/s6</package> instead of using start-stop-daemon</flag>
+ </use>
</pkgmetadata>
diff --git a/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha1.ebuild b/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha1.ebuild
new file mode 100644
index 0000000..232246d
--- /dev/null
+++ b/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha1.ebuild
@@ -0,0 +1,77 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+EAPI=5
+
+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="s6"
+
+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
+ s6? ( >=sys-apps/openrc-0.16 sys-apps/s6 )
+ "
+# Need to set S due to PMS saying we need it existing, but no SRC_URI
+S=${WORKDIR}
+
+src_install() {
+ newconfd "${FILESDIR}/conf.d-2.0" "mysql"
+ if use s6 ; then
+ newinitd "${FILESDIR}/init.d-s6" "mysql"
+ exeinto /etc/svc.d/mysql
+ newexe "${FILESDIR}/run-s6" "run"
+ else
+ newinitd "${FILESDIR}/init.d-2.0" "mysql"
+ fi
+
+ # systemd unit installation
+ exeinto /usr/libexec
+ doexe "${FILESDIR}"/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
+}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/mysql:master commit in: dev-db/mysql-init-scripts/files/, dev-db/mysql-init-scripts/
@ 2015-05-14 18:23 Brian Evans
0 siblings, 0 replies; 5+ messages in thread
From: Brian Evans @ 2015-05-14 18:23 UTC (permalink / raw
To: gentoo-commits
commit: 3911b4603456960d5fe926cfed2ef44408ef4aab
Author: layman <layman <AT> localhost>
AuthorDate: Thu May 14 18:24:41 2015 +0000
Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Thu May 14 18:24:41 2015 +0000
URL: https://gitweb.gentoo.org/proj/mysql.git/commit/?id=3911b460
Update for changes in latest sys-apps/openrc
dev-db/mysql-init-scripts/files/init.d-s6 | 1 +
dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha2.ebuild | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dev-db/mysql-init-scripts/files/init.d-s6 b/dev-db/mysql-init-scripts/files/init.d-s6
index da97b30..984c831 100644
--- a/dev-db/mysql-init-scripts/files/init.d-s6
+++ b/dev-db/mysql-init-scripts/files/init.d-s6
@@ -26,6 +26,7 @@ mysql_svcname() {
extra_commands="checkconfig"
supervisor=s6
name=$(mysql_svcname)
+s6_service_timeout_stop="$((1000*${STOP_TIMEOUT:-120}))"
#s6_svwait_options_start="-U -t $((1000*${STARTUP_EARLY_TIMEOUT:-1000}))"
start_pre() {
diff --git a/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha2.ebuild b/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha2.ebuild
index b8fcf01..ba6ccfc 100644
--- a/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha2.ebuild
+++ b/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha2.ebuild
@@ -20,7 +20,7 @@ DEPEND=""
# It also NEEDS openrc for the save_options/get_options builtins.
RDEPEND="
!<dev-db/mysql-5.1
- s6? ( >=sys-apps/openrc-0.16.1 sys-apps/s6 )
+ s6? ( >=sys-apps/openrc-0.16.2 sys-apps/s6 )
"
# Need to set S due to PMS saying we need it existing, but no SRC_URI
S=${WORKDIR}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/mysql:master commit in: dev-db/mysql-init-scripts/files/, dev-db/mysql-init-scripts/
@ 2015-06-09 16:17 Brian Evans
0 siblings, 0 replies; 5+ messages in thread
From: Brian Evans @ 2015-06-09 16:17 UTC (permalink / raw
To: gentoo-commits
commit: 0f9b07f83dce8c4008c86746791f088695eaae41
Author: layman <layman <AT> localhost>
AuthorDate: Tue Jun 9 16:19:21 2015 +0000
Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jun 9 16:19:21 2015 +0000
URL: https://gitweb.gentoo.org/proj/mysql.git/commit/?id=0f9b07f8
Version bump
dev-db/mysql-init-scripts/files/init.d-s6 | 23 ++++++++++++----------
...ebuild => mysql-init-scripts-2.1_alpha4.ebuild} | 17 ++++++++--------
2 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/dev-db/mysql-init-scripts/files/init.d-s6 b/dev-db/mysql-init-scripts/files/init.d-s6
index f856e1d..07242d8 100644
--- a/dev-db/mysql-init-scripts/files/init.d-s6
+++ b/dev-db/mysql-init-scripts/files/init.d-s6
@@ -16,11 +16,11 @@ get_config() {
mysql_svcname() {
local ebextra=
- case "${SVCNAME}" in
+ case "${svc_name}" in
mysql*) ;;
*) ebextra=" (mysql)" ;;
esac
- echo "${SVCNAME}${ebextra}"
+ echo "${svc_name}${ebextra}"
}
extra_commands="checkconfig"
@@ -28,12 +28,14 @@ supervisor=s6
name=$(mysql_svcname)
s6_service_timeout_stop="$((1000*${STOP_TIMEOUT:-120}))"
#s6_svwait_options_start="-U -t $((1000*${STARTUP_EARLY_TIMEOUT:-1000}))"
+svc_name=${RC_SVCNAME%-s6}
+s6_service_path=/var/svc.d/${svc_name}
start_pre() {
# Check the config or die
checkconfig || return 1
- MY_CNF="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
+ MY_CNF="${MY_CNF:-/etc/${svc_name}/my.cnf}"
if [ ! -r "${MY_CNF}" ] ; then
eerror "Cannot read the configuration file \`${MY_CNF}'"
@@ -80,12 +82,13 @@ start_pre() {
fi
# Prepare env files to source
- mkdir -p "/var/svc.d/${SVCNAME}"
- echo "MY_CNF=\"${MY_CNF}\"" > "/var/svc.d/${SVCNAME}/env"
- echo "MY_ARGS=\"${MY_ARGS}\"" >> "/var/svc.d/${SVCNAME}/env"
- echo "basedir=\"${basedir}\"" >> "/var/svc.d/${SVCNAME}/env"
- mkdir -p "/var/svc.d/${SVCNAME}/log"
- echo "SVCNAME=\"${SVCNAME}\"" > "/var/svc.d/${SVCNAME}/log/env"
+ mkdir -p "/var/svc.d/${svc_name}"
+ echo "MY_CNF=\"${MY_CNF}\"" > "/var/svc.d/${svc_name}/env"
+ echo "MY_ARGS=\"${MY_ARGS}\"" >> "/var/svc.d/${svc_name}/env"
+ echo "basedir=\"${basedir}\"" >> "/var/svc.d/${svc_name}/env"
+ mkdir -p "/var/svc.d/${svc_name}/log"
+ echo "SVCNAME=\"${SVCNAME}\"" > "/var/svc.d/${svc_name}/log/env"
+ echo "S6_LOG_OPTIONS=\"${S6_LOG_OPTIONS}\"" > "/var/svc.d/${svc_name}/log/env"
}
start_post() {
@@ -100,7 +103,7 @@ start_post() {
}
checkconfig() {
- local my_cnf="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
+ local my_cnf="${MY_CNF:-/etc/${svc_name}/my.cnf}"
local basedir=$(get_config "${my_cnf}" basedir | tail -n1)
local svc_name=$(mysql_svcname)
ebegin "Checking mysqld configuration for ${svc_name}"
diff --git a/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha3.ebuild b/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha4.ebuild
similarity index 77%
rename from dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha3.ebuild
rename to dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha4.ebuild
index 34eae3b..a3e37d3 100644
--- a/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha3.ebuild
+++ b/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha4.ebuild
@@ -1,10 +1,10 @@
# Copyright 1999-2015 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.1_alpha3.ebuild,v 1.1 2015/05/27 21:01:03 grknight Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/mysql-init-scripts-2.1_alpha4.ebuild,v 1.1 2015/06/09 16:16:26 grknight Exp $
EAPI=5
-inherit systemd
+inherit systemd s6
DESCRIPTION="Gentoo MySQL init scripts."
HOMEPAGE="http://www.gentoo.org/"
@@ -33,10 +33,8 @@ src_install() {
if use amd64 || use x86 ; then
newconfd "${FILESDIR}/conf.d-2.0" "mysql-s6"
newinitd "${FILESDIR}/init.d-s6" "mysql-s6"
- exeinto /var/svc.d/mysql-s6
- newexe "${FILESDIR}/run-s6" "run"
- exeinto /var/svc.d/mysql-s6/log
- newexe "${FILESDIR}/log-s6" "run"
+ s6_install_service mysql "${FILESDIR}/run-s6"
+ s6_install_service mysql/log "${FILESDIR}/log-s6"
fi
newinitd "${FILESDIR}/init.d-2.0" "mysql"
@@ -53,7 +51,8 @@ src_install() {
}
pkg_postinst() {
- einfo "To use the mysql-s6 script, you need to install the optional sys-apps/s6 package."
- einfo "If you wish to use s6 logging support, "
- einfo "comment out the log-error setting in your my.cnf"
+ if use amd64 || use x86 ; then
+ elog "To use the mysql-s6 script, you need to install the optional sys-apps/s6 package."
+ elog "If you wish to use s6 logging support, comment out the log-error setting in your my.cnf"
+ fi
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-09 16:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-12 19:39 [gentoo-commits] proj/mysql:master commit in: dev-db/mysql-init-scripts/files/, dev-db/mysql-init-scripts/ Brian Evans
-- strict thread matches above, loose matches on Subject: below --
2015-06-09 16:17 Brian Evans
2015-05-14 18:23 Brian Evans
2014-08-19 0:34 Brian Evans
2014-08-06 3:20 Brian Evans
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox