/[ports]/head/databases/mysql57-server/files/mysql-server.in
ViewVC logotype

Contents of /head/databases/mysql57-server/files/mysql-server.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 466507 - (show annotations) (download)
Wed Apr 4 20:57:11 2018 UTC (6 years, 3 months ago) by mmokhi
File MIME type: text/plain
File size: 2691 byte(s)
databases/mysql57-server: Adapt ${name}_limits to the new mechanism
Regarding to the changes to rc.subr(8) it is no longer necessary to
define a resource limiting logic in service scripts.
limits(1) is now run by default and its configuration is handled
via the "${name}_limits" variable.
This however causes collision of variable names and also is not
compatible with the old mechanism.
This fixes the rc-script of mysql57 for the bases with both
old and new mechanism.
(This is port of the r466505 [and r466506])

PR:		227230
Submitted by:	0mp
Reported by:	0mp
Differential Revision:	Netzkommune GmbH

1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: mysql
7 # REQUIRE: LOGIN
8 # KEYWORD: shutdown
9
10 #
11 # Add the following line to /etc/rc.conf to enable mysql:
12 # mysql_enable (bool): Set to "NO" by default.
13 # Set it to "YES" to enable MySQL.
14 %%LEGACY_LIMITS%%# mysql_limits (bool): Set to "NO" by default.
15 %%LEGACY_LIMITS%%# Set it to yes to run `limits -e -U mysql`
16 %%LEGACY_LIMITS%%# just before mysql starts.
17 # mysql_dbdir (str): Default to "%%MY_DBDIR%%"
18 # Base database directory.
19 # mysql_confdir (str): Default to "%%ETCDIR%%"
20 # Base configuration directory.
21 # mysql_optfile (str): Server-specific option file.
22 # Set it in the rc.conf or default behaviour of
23 # `mysqld_safe` itself, will be picking
24 # ${mysql_confdir}/my.cnf if it exists.
25 # mysql_pidfile (str): Custum PID file path and name.
26 # Default to "${mysql_dbdir}/${hostname}.pid".
27 # mysql_args (str): Custom additional arguments to be passed
28 # to mysqld_safe (default empty).
29 #
30
31 . /etc/rc.subr
32
33 name="mysql"
34 rcvar=mysql_enable
35
36 load_rc_config $name
37
38 : ${mysql_enable="NO"}
39 %%LEGACY_LIMITS%%: ${mysql_limits="NO"}
40 : ${mysql_dbdir="%%MY_DBDIR%%"}
41 : ${mysql_confdir="%%ETCDIR%%"}
42 if [ -f "${mysql_confdir}/my.cnf" ]; then
43 : ${mysql_optfile="${mysql_confdir}/my.cnf"}
44 elif [ -f "${mysql_dbdir}/my.cnf" ]; then
45 : ${mysql_optfile="${mysql_dbdir}/my.cnf"}
46 fi
47 if [ ! -z "${mysql_optfile}" ]; then
48 mysql_extra="--defaults-extra-file=${mysql_optfile}"
49 fi
50
51
52 mysql_user="mysql"
53 %%LEGACY_LIMITS%%mysql_limits_args="-e -U ${mysql_user}"
54 : ${hostname:=`/bin/hostname`}
55 pidfile=${mysql_pidfile:-"${mysql_dbdir}/${hostname}.pid"}
56 command="/usr/sbin/daemon"
57 command_args="-c -f %%PREFIX%%/bin/mysqld_safe ${mysql_extra} --basedir=%%PREFIX%% --datadir=${mysql_dbdir} --pid-file=${pidfile} --user=${mysql_user} ${mysql_args} %%FEDER%% %%PERFSCHEMRC%%"
58 procname="%%PREFIX%%/libexec/mysqld"
59 start_precmd="${name}_prestart"
60 start_postcmd="${name}_poststart"
61 mysql_install_db="%%PREFIX%%/bin/mysql_install_db"
62 mysql_install_db_args="${mysql_extra} --basedir=%%PREFIX%% --datadir=${mysql_dbdir} --mysqld-file=${procname} --user=${mysql_user}"
63
64 mysql_create_auth_tables()
65 {
66 eval $mysql_install_db $mysql_install_db_args >/dev/null 2>/dev/null
67 }
68
69 mysql_prestart()
70 {
71 if [ ! -d "${mysql_dbdir}/mysql/." ]; then
72 mysql_create_auth_tables || return 1
73 fi
74 %%LEGACY_LIMITS%% if checkyesno mysql_limits; then
75 %%LEGACY_LIMITS%% eval `/usr/bin/limits ${mysql_limits_args}` 2>/dev/null
76 %%LEGACY_LIMITS%% else
77 %%LEGACY_LIMITS%% return 0
78 %%LEGACY_LIMITS%% fi
79 %%MODERN_LIMITS%% return 0
80 }
81
82 mysql_poststart()
83 {
84 local timeout=15
85 while [ ! -f "${pidfile}" -a ${timeout} -gt 0 ]; do
86 timeout=$(( timeout - 1 ))
87 sleep 1
88 done
89 return 0
90 }
91
92 run_rc_command "$1"

Properties

Name Value
svn:eol-style native
svn:keywords FreeBSD=%H
svn:mime-type text/plain

  ViewVC Help
Powered by ViewVC 1.1.27