summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Longinotti <chtekk@gentoo.org>2007-01-12 16:54:20 +0000
committerLuca Longinotti <chtekk@gentoo.org>2007-01-12 16:54:20 +0000
commitb29bd87ad27bc1aac9241989a016ba3193ceef0e (patch)
tree27facd8e4e5512cb8f847d3f9afde9b81cb6234c /dev-db/mysql-init-scripts
parentVersion bump. (diff)
downloadhistorical-b29bd87ad27bc1aac9241989a016ba3193ceef0e.tar.gz
historical-b29bd87ad27bc1aac9241989a016ba3193ceef0e.tar.bz2
historical-b29bd87ad27bc1aac9241989a016ba3193ceef0e.zip
Prepare for sys-apps/mysql move.
Package-Manager: portage-2.1.2_rc4-r5
Diffstat (limited to 'dev-db/mysql-init-scripts')
-rw-r--r--dev-db/mysql-init-scripts/ChangeLog7
-rw-r--r--dev-db/mysql-init-scripts/Manifest35
-rw-r--r--dev-db/mysql-init-scripts/files/digest-mysql-init-scripts-1.10
-rw-r--r--dev-db/mysql-init-scripts/files/logrotate.mysql15
-rw-r--r--dev-db/mysql-init-scripts/files/mysql.conf.d80
-rw-r--r--dev-db/mysql-init-scripts/files/mysql.rc6357
-rw-r--r--dev-db/mysql-init-scripts/files/mysqlmanager.conf.d28
-rw-r--r--dev-db/mysql-init-scripts/files/mysqlmanager.rc6230
-rw-r--r--dev-db/mysql-init-scripts/metadata.xml5
-rw-r--r--dev-db/mysql-init-scripts/mysql-init-scripts-1.1.ebuild28
10 files changed, 785 insertions, 0 deletions
diff --git a/dev-db/mysql-init-scripts/ChangeLog b/dev-db/mysql-init-scripts/ChangeLog
new file mode 100644
index 000000000000..38be4a31d143
--- /dev/null
+++ b/dev-db/mysql-init-scripts/ChangeLog
@@ -0,0 +1,7 @@
+# ChangeLog for dev-db/mysql-init-scripts
+# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/ChangeLog,v 1.1 2007/01/12 16:54:20 chtekk Exp $
+
+ 12 Jan 2007; Luca Longinotti <chtekk@gentoo.org> ChangeLog:
+ Move from sys-apps/mysql.
+
diff --git a/dev-db/mysql-init-scripts/Manifest b/dev-db/mysql-init-scripts/Manifest
new file mode 100644
index 000000000000..8b2edd4cf791
--- /dev/null
+++ b/dev-db/mysql-init-scripts/Manifest
@@ -0,0 +1,35 @@
+AUX logrotate.mysql 453 RMD160 d1fd681cea5073b662d521c7473eb121d15f50e4 SHA1 1e52a9df3a42c8705f4c22bb6758674fdfb04135 SHA256 d873c55e0fe4ba545fc40f6724a9415db9e9a2da3e80c00b3443b7ab73bc7a8b
+MD5 ae83955f73e9abd4b0add5dda9db8da2 files/logrotate.mysql 453
+RMD160 d1fd681cea5073b662d521c7473eb121d15f50e4 files/logrotate.mysql 453
+SHA256 d873c55e0fe4ba545fc40f6724a9415db9e9a2da3e80c00b3443b7ab73bc7a8b files/logrotate.mysql 453
+AUX mysql.conf.d 3273 RMD160 a2661c832c1091b2d05e599fc58cce6f686c7f31 SHA1 64e9bb80099bf6e14a07764fcb69bb02682aee0b SHA256 ee049781a3885305ce9999371198ff54f97fee4d2ad0814ba3aa3a03abc2724c
+MD5 092bb6cad90a875da8899e104304c969 files/mysql.conf.d 3273
+RMD160 a2661c832c1091b2d05e599fc58cce6f686c7f31 files/mysql.conf.d 3273
+SHA256 ee049781a3885305ce9999371198ff54f97fee4d2ad0814ba3aa3a03abc2724c files/mysql.conf.d 3273
+AUX mysql.rc6 10655 RMD160 37ca10afa120766244ff38beb3437319d6989569 SHA1 7184363e424d5d2f29a14083b55b3d00c8e568ad SHA256 945a6963368d1da9fdb9edf470cd4e177e2513bbbcc2028b944e391b3e6eebad
+MD5 55571d41f7d19a77c3a4c29a7e234463 files/mysql.rc6 10655
+RMD160 37ca10afa120766244ff38beb3437319d6989569 files/mysql.rc6 10655
+SHA256 945a6963368d1da9fdb9edf470cd4e177e2513bbbcc2028b944e391b3e6eebad files/mysql.rc6 10655
+AUX mysqlmanager.conf.d 1009 RMD160 b443dc0cd1cb7fb054fe7229a52b8d093e634652 SHA1 0d82531df24ba4f0d957176b6fa0076a1cae0356 SHA256 35353f585cc9d3f97bbcfe77224d183e0fedcf4134377b8bff4c278462577cc7
+MD5 c94178cadec3be56c4e6c7ec9812cfcf files/mysqlmanager.conf.d 1009
+RMD160 b443dc0cd1cb7fb054fe7229a52b8d093e634652 files/mysqlmanager.conf.d 1009
+SHA256 35353f585cc9d3f97bbcfe77224d183e0fedcf4134377b8bff4c278462577cc7 files/mysqlmanager.conf.d 1009
+AUX mysqlmanager.rc6 6632 RMD160 17fd2bdfcad0ca6e32e6ee91e1e0db7ce3263fef SHA1 18c6fc53a65a4f92dacd229585199b94f1c888cc SHA256 0d37cb3199a2752604a105d54340a61b9ee062e6c1d977a863628b694d93e96d
+MD5 9bd0a4e431bda8249ae96273209715e2 files/mysqlmanager.rc6 6632
+RMD160 17fd2bdfcad0ca6e32e6ee91e1e0db7ce3263fef files/mysqlmanager.rc6 6632
+SHA256 0d37cb3199a2752604a105d54340a61b9ee062e6c1d977a863628b694d93e96d files/mysqlmanager.rc6 6632
+EBUILD mysql-init-scripts-1.1.ebuild 803 RMD160 9ab1dc057eec472359750a1a99ef932f76f62d65 SHA1 c9b27f179cfc50339ec294086517404ccf7ae248 SHA256 db3386e84994d633b6fa5c012a438b37736c0f41de0592d7bcb7dde23d21b897
+MD5 9b8b7d1a7e6a51a65968c7dce2ce51e4 mysql-init-scripts-1.1.ebuild 803
+RMD160 9ab1dc057eec472359750a1a99ef932f76f62d65 mysql-init-scripts-1.1.ebuild 803
+SHA256 db3386e84994d633b6fa5c012a438b37736c0f41de0592d7bcb7dde23d21b897 mysql-init-scripts-1.1.ebuild 803
+MISC ChangeLog 314 RMD160 0a4ba1ab015dfa270386738e381fc3051a080a4b SHA1 dcd42b14fdc1628276f87885db633972bf3e3baa SHA256 b32a5612c88a0086be9a15686d40bf75407158c606647a77bfa394e8541e6e0e
+MD5 decefd99806de9b0ed1b36c25d3d91ee ChangeLog 314
+RMD160 0a4ba1ab015dfa270386738e381fc3051a080a4b ChangeLog 314
+SHA256 b32a5612c88a0086be9a15686d40bf75407158c606647a77bfa394e8541e6e0e ChangeLog 314
+MISC metadata.xml 159 RMD160 a50a94af7706288c46f81d6c3da9b5f888050eee SHA1 5eb253a678d6faa0f1c6b3c5720a804ed8923566 SHA256 5cfd5aa0e8104c0326b5f4c9205a6449a94e0f6f6abfd2626f1e7a8fe77b98b7
+MD5 f1c86d989c7ea2451931e7e2c3530f8c metadata.xml 159
+RMD160 a50a94af7706288c46f81d6c3da9b5f888050eee metadata.xml 159
+SHA256 5cfd5aa0e8104c0326b5f4c9205a6449a94e0f6f6abfd2626f1e7a8fe77b98b7 metadata.xml 159
+MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-mysql-init-scripts-1.1 0
+RMD160 9c1185a5c5e9fc54612808977ee8f548b2258d31 files/digest-mysql-init-scripts-1.1 0
+SHA256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 files/digest-mysql-init-scripts-1.1 0
diff --git a/dev-db/mysql-init-scripts/files/digest-mysql-init-scripts-1.1 b/dev-db/mysql-init-scripts/files/digest-mysql-init-scripts-1.1
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/digest-mysql-init-scripts-1.1
diff --git a/dev-db/mysql-init-scripts/files/logrotate.mysql b/dev-db/mysql-init-scripts/files/logrotate.mysql
new file mode 100644
index 000000000000..90024705a422
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/logrotate.mysql
@@ -0,0 +1,15 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/logrotate.mysql,v 1.1 2007/01/12 16:54:20 chtekk Exp $
+
+/var/log/mysql/mysql.err /var/log/mysql/mysql.log /var/log/mysql/mysqld.err {
+monthly
+create 660 mysql mysql
+notifempty
+size 5M
+sharedscripts
+missingok
+postrotate
+/bin/kill -HUP `cat /var/run/mysqld/mysqld.pid`
+endscript
+}
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 000000000000..15ff170cc98a
--- /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 000000000000..68ced6e5aeb2
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysql.rc6
@@ -0,0 +1,357 @@
+#!/sbin/runscript
+# Copyright 1999-2006 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.1 2007/01/12 16:54:20 chtekk 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}"
+ #see bug #158769 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}
+ 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 000000000000..8666f71596cc
--- /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 000000000000..dd8b703cd7d6
--- /dev/null
+++ b/dev-db/mysql-init-scripts/files/mysqlmanager.rc6
@@ -0,0 +1,230 @@
+#!/sbin/runscript
+# Copyright 1999-2006 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/metadata.xml b/dev-db/mysql-init-scripts/metadata.xml
new file mode 100644
index 000000000000..abf3529deac0
--- /dev/null
+++ b/dev-db/mysql-init-scripts/metadata.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>mysql</herd>
+</pkgmetadata>
diff --git a/dev-db/mysql-init-scripts/mysql-init-scripts-1.1.ebuild b/dev-db/mysql-init-scripts/mysql-init-scripts-1.1.ebuild
new file mode 100644
index 000000000000..a3f1e769a8b9
--- /dev/null
+++ b/dev-db/mysql-init-scripts/mysql-init-scripts-1.1.ebuild
@@ -0,0 +1,28 @@
+# Copyright 1999-2007 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.1.ebuild,v 1.1 2007/01/12 16:54:20 chtekk 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 ~sparc-fbsd x86 ~x86-fbsd"
+IUSE=""
+
+DEPEND=""
+RDEPEND=""
+
+src_install() {
+ insinto "/etc/conf.d"
+ newins "${FILESDIR}/mysql.conf.d" "mysql"
+ newins "${FILESDIR}/mysqlmanager.conf.d" "mysqlmanager"
+
+ exeinto /etc/init.d
+ newexe "${FILESDIR}/mysql.rc6" "mysql"
+ newexe "${FILESDIR}/mysqlmanager.rc6" "mysqlmanager"
+
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}/logrotate.mysql" "mysql"
+}