ports/178726: [PATCH] databases/mariadb55-server: multi-instances startup script
geoffroy desvernay
dgeo at centrale-marseille.fr
Thu Nov 21 21:40:01 UTC 2013
The following reply was made to PR ports/178726; it has been noted by GNATS.
From: geoffroy desvernay <dgeo at centrale-marseille.fr>
To: bug-followup at FreeBSD.org, dgeo at centrale-marseille.fr
Cc: Alexandr Kovalenko <never at nevermind.kiev.ua>
Subject: Re: ports/178726: [PATCH] databases/mariadb55-server: multi-instances
startup script
Date: Thu, 21 Nov 2013 22:32:38 +0100
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
------enig2VJHBHOHMCJIIDPLIDDNH
Content-Type: multipart/mixed;
boundary="------------010109080708020905090400"
This is a multi-part message in MIME format.
--------------010109080708020905090400
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Please could you have a look to this pr ?
Here is an "up-to-date" patch to startup script to allow multiple server
instances.
Thank you for maintaining mariadb55 !
--=20
geoffroy desvernay
C.R.I - Administration syst=E8mes et r=E9seaux
Ecole Centrale de Marseille
Tel: (+33|0)4 91 05 45 24
Fax: (+33|0)4 91 05 45 98
dgeo at centrale-marseille.fr
--------------010109080708020905090400
Content-Type: text/x-patch;
name="mariadb55-server.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="mariadb55-server.diff"
Index: files/mysql-server.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- files/mysql-server.in (revision 334526)
+++ files/mysql-server.in (working copy)
@@ -10,17 +10,23 @@
#
# Add the following line to /etc/rc.conf to enable mysql:
# mysql_enable (bool): Set to "NO" by default.
+# mysql_(instance_)?enable (bool): Set to "NO" by default.
# Set it to "YES" to enable MySQL.
-# mysql_limits (bool): Set to "NO" by default.
+# mysql_(instance_)?limits (bool): Set to "NO" by default.
# Set it to yes to run `limits -e -U mysql`
# just before mysql starts.
-# mysql_dbdir (str): Default to "/var/db/mysql"
+# mysql_(instance_)?dbdir (str): Default to "/var/db/mysql"
# Base database directory.
-# mysql_pidfile (str): Custum PID file path and name.
+# mysql_(instance_)?pidfile (str): Custum PID file path and name.
# Default to "${mysql_dbdir}/${hostname}.pid".
-# mysql_args (str): Custom additional arguments to be passed
+# mysql_(instance_)?args (str): Custom additional arguments to be passed=
# to mysqld_safe (default empty).
-#
+# mysql_(instance_)?user (str): User to run mysqld as
+# Default to "mysql" created by the port
+# mysql_(instance_)?optfile (str): Server-specific option file.
+# Default to "${mysql_dbdir}/my.cnf".
+# mysql_instances (str): Set to "" by default.
+# If defined, list of instances to start
=20
. /etc/rc.subr
=20
@@ -31,23 +37,77 @@
=20
: ${mysql_enable=3D"NO"}
: ${mysql_limits=3D"NO"}
+: ${mysql_user=3D"mysql"}
+: ${mysql_limits_args=3D"-e -U $mysql_user"}
: ${mysql_dbdir=3D"/var/db/mysql"}
+: ${mysql_optfile=3D"${mysql_dbdir}/my.cnf"}
=20
-mysql_user=3D"mysql"
-mysql_limits_args=3D"-e -U ${mysql_user}"
-pidfile=3D${mysql_pidfile:-"${mysql_dbdir}/`/bin/hostname`.pid"}
command=3D"/usr/sbin/daemon"
-command_args=3D"-c -f %%PREFIX%%/bin/mysqld_safe --defaults-extra-file=3D=
${mysql_dbdir}/my.cnf --user=3D${mysql_user} --datadir=3D${mysql_dbdir} -=
-pid-file=3D${pidfile} ${mysql_args}"
procname=3D"%%PREFIX%%/libexec/mysqld"
start_precmd=3D"${name}_prestart"
start_postcmd=3D"${name}_poststart"
+
+if [ -n "$2" ]; then
+ instance=3D"$2"
+ load_rc_config ${name}_${instance}
+ case "$mysql_instances" in
+ "$2 "*|*" $2 "*|*" $2"|"$2")
+ eval mysql_args=3D"\${mysql_${instance}_args:-\"${mysql_args}\"}"
+ eval mysql_dbdir=3D"\${mysql_${instance}_dbdir:-\"/var/db/mysql_${inst=
ance}\"}"
+ eval mysql_limits=3D"\${mysql_${instance}_limits:-\"${mysql_limits}\"}=
"
+ eval mysql_user=3D"\${mysql_${instance}_user:-\"${mysql_user}\"}"
+ eval mysql_limits_args=3D"\${mysql_${instance}_limits_args:-\"-e -U $m=
ysql_user\"}"
+ eval mysql_optfile=3D"\${mysql_${instance}_optfile:-\"${mysql_dbdir}/m=
y.cnf\"}"
+ eval mysql_pidfile=3D"\${mysql_${instance}_pidfile:-\"${mysql_dbdir}/`=
/bin/hostname`.pid\"}"
+ ;;
+ *)
+ err 1 "$2 not found in mysql_instances" ;;
+ esac
+else
+ if [ -n "${mysql_instances}" -a -n "$1" ]; then
+ for instance in ${mysql_instances}; do
+ eval _enable=3D"\${mysql_${instance}_enable}"
+ case "${_enable:-${mysql_enable}}" in
+ [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
+ continue
+ ;;
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ ;;
+ *)
+ if [ -z "$_enable" ]; then
+ _var=3Dmysql_enable
+ else
+ _var=3Dmysql_${instance}_enable
+ fi
+ warn "Bad value" \
+ "'${_enable:-${mysql_enable}}'" \
+ "for ${_var}. " \
+ "Instance ${instance} skipped."
+ continue
+ ;;
+ esac
+ echo "=3D=3D=3D> mysql instance: ${instance}"
+ if %%PREFIX%%/etc/rc.d/mysql-server $1 ${instance}; then
+ success=3D"${instance} ${success}"
+ else
+ failed=3D"${instance} (${retcode}) ${failed}"
+ fi
+ done
+ exit 0
+ else
+ mysql_pidfile=3D${mysql_pidfile:-"${mysql_dbdir}/`/bin/hostname`.pid"}=
+ fi
+fi
+
+pidfile=3D$mysql_pidfile
mysql_install_db=3D"%%PREFIX%%/bin/mysql_install_db"
mysql_install_db_args=3D"--basedir=3D%%PREFIX%% --datadir=3D${mysql_dbdi=
r} --force"
+command_args=3D"-c -f %%PREFIX%%/bin/mysqld_safe --defaults-extra-file=3D=
${mysql_optfile} --user=3D${mysql_user} --datadir=3D${mysql_dbdir} --pid-=
file=3D${pidfile} ${mysql_args}"
=20
mysql_create_auth_tables()
{
- eval $mysql_install_db $mysql_install_db_args >/dev/null 2>/dev/null
- [ $? -eq 0 ] && chown -R ${mysql_user}:${mysql_user} ${mysql_dbd=
ir}
+ eval $mysql_install_db $mysql_install_db_args
+ [ $? -eq 0 ] && chown -R ${mysql_user}:$(id -gn $mysql_user) ${m=
ysql_dbdir}
}
=20
mysql_prestart()
@@ -56,7 +116,7 @@
mysql_create_auth_tables || return 1
fi
if checkyesno mysql_limits; then
- eval `/usr/bin/limits ${mysql_limits_args}` 2>/dev/null
+ eval `/usr/bin/limits ${mysql_limits_args:-"-e -U $mysql_user"}` 2>/de=
v/null
else
return 0
fi
--------------010109080708020905090400--
------enig2VJHBHOHMCJIIDPLIDDNH
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/
iQEcBAEBCAAGBQJSjnv2AAoJEC0NWrh8JT1SFdAH/3p8WC+CFB7+5PYt3Xof3Eyk
bewxLRFaMfKXihxOMPLXJKjJv5ihFz/qWTXnp0Tz9ic6XEOyRGqRHZctOTzLCrS2
CTavk1505wRw1kdyN5l1vfWxapu0nVKgZzk09nf9CQOSoNgsd5/Xl+2e+cd79ueK
L6j66YrjMqh7isHEihnRqastRsTRZx61kkEVKV6JojMCCCysyxPfzYwkm3TDHlz+
xMpwWv0/TOLgu2FEzxHWqqf/mvXxlpXHyM/ofpPpJkZGsw9yLnzUB2+VE9MW1aAH
tOn/r4JYrQtqNfWJpd2ZwAYLxQ8pxMEyGZuaObIRH5lIE2xArcASpdRdZoIL8zg=
=MyzD
-----END PGP SIGNATURE-----
------enig2VJHBHOHMCJIIDPLIDDNH--
More information about the freebsd-ports-bugs
mailing list