| @@ -1,49 +1,55 @@ | | | @@ -1,49 +1,55 @@ |
1 | #!@RCD_SCRIPTS_SHELL@ | | 1 | #!@RCD_SCRIPTS_SHELL@ |
2 | # | | 2 | # |
3 | # $NetBSD: mysqld.sh,v 1.2 2007/06/13 13:24:07 xtraeme Exp $ | | 3 | # $NetBSD: mysqld.sh,v 1.2.18.1 2009/02/07 19:49:37 tron Exp $ |
4 | # | | 4 | # |
5 | # PROVIDE: mysqld | | 5 | # PROVIDE: mysqld |
6 | # REQUIRE: DAEMON LOGIN mountall | | 6 | # REQUIRE: DAEMON LOGIN mountall |
7 | # KEYWORD: shutdown | | 7 | # KEYWORD: shutdown |
8 | # | | 8 | # |
9 | # You will need to set some variables in /etc/rc.conf to start MySQL: | | 9 | # You will need to set some variables in /etc/rc.conf to start MySQL: |
10 | # | | 10 | # |
11 | # mysqld=YES | | 11 | # mysqld=YES |
12 | # | | 12 | # |
13 | # The following variables are optional: | | 13 | # The following variables are optional: |
14 | # | | 14 | # |
15 | # mysqld_user="mysql" # user to run mysqld as | | 15 | # mysqld_user="mysql" # user to run mysqld as |
16 | # mysqld_datadir="/path/to/home" # path to MySQL database directory | | 16 | # mysqld_datadir="/path/to/home" # path to MySQL database directory |
17 | # | | 17 | # |
18 | | | 18 | |
19 | if [ -f /etc/rc.subr ]; then | | 19 | if [ -f /etc/rc.subr ]; then |
20 | . /etc/rc.subr | | 20 | . /etc/rc.subr |
21 | fi | | 21 | fi |
22 | | | 22 | |
23 | name="mysqld" | | 23 | name="mysqld" |
24 | rcvar=${name} | | 24 | rcvar=${name} |
25 | command="@PREFIX@/bin/mysqld_safe" | | 25 | command="@PREFIX@/bin/mysqld_safe" |
26 | procname="@PREFIX@/libexec/${name}" | | 26 | procname="@PREFIX@/libexec/${name}" |
27 | : ${mysqld_user:=@MYSQL_USER@} | | 27 | : ${mysqld_user:=@MYSQL_USER@} |
28 | : ${mysqld_group:=@MYSQL_GROUP@} | | 28 | : ${mysqld_group:=@MYSQL_GROUP@} |
29 | : ${mysqld_datadir:=@MYSQL_DATADIR@} | | 29 | : ${mysqld_datadir:=@MYSQL_DATADIR@} |
30 | pidfile="${mysqld_datadir}/`@HOSTNAME_CMD@`.pid" | | | |
31 | | | 30 | |
32 | extra_commands="initdb" | | 31 | extra_commands="initdb" |
33 | initdb_cmd="mysqld_initdb" | | 32 | initdb_cmd="mysqld_initdb" |
34 | start_precmd="mysqld_precmd" | | 33 | start_precmd="mysqld_precmd" |
35 | start_cmd="mysqld_start" | | 34 | start_cmd="mysqld_start" |
36 | | | 35 | |
| | | 36 | # Don't drop thread priority unless on Linux or SunOS |
| | | 37 | # ref. http://bugs.mysql.com/bug.php?id=18526 |
| | | 38 | case $(uname -s) in |
| | | 39 | Linux|SunOS) thread_flags="";; |
| | | 40 | *) thread_flags="--skip-thread-priority" |
| | | 41 | esac |
| | | 42 | |
37 | mysqld_precmd() | | 43 | mysqld_precmd() |
38 | { | | 44 | { |
39 | if [ ! -d ${mysqld_datadir}/mysql ]; then | | 45 | if [ ! -d ${mysqld_datadir}/mysql ]; then |
40 | mysqld_initdb | | 46 | mysqld_initdb |
41 | fi | | 47 | fi |
42 | } | | 48 | } |
43 | | | 49 | |
44 | mysqld_initdb() | | 50 | mysqld_initdb() |
45 | { | | 51 | { |
46 | initdb="@PREFIX@/bin/mysql_install_db" | | 52 | initdb="@PREFIX@/bin/mysql_install_db" |
47 | if [ ! -x ${initdb} ]; then | | 53 | if [ ! -x ${initdb} ]; then |
48 | return 1 | | 54 | return 1 |
49 | fi | | 55 | fi |
| @@ -65,36 +71,39 @@ mysqld_start() | | | @@ -65,36 +71,39 @@ mysqld_start() |
65 | { | | 71 | { |
66 | for f in $required_files; do | | 72 | for f in $required_files; do |
67 | if [ ! -r "$f" ]; then | | 73 | if [ ! -r "$f" ]; then |
68 | @ECHO@ 1>&2 "$0: WARNING: $f is not readable" | | 74 | @ECHO@ 1>&2 "$0: WARNING: $f is not readable" |
69 | if [ -z $rc_force ]; then | | 75 | if [ -z $rc_force ]; then |
70 | return 1 | | 76 | return 1 |
71 | fi | | 77 | fi |
72 | fi | | 78 | fi |
73 | done | | 79 | done |
74 | @ECHO@ "Starting ${name}." | | 80 | @ECHO@ "Starting ${name}." |
75 | ulimit -n 4096 | | 81 | ulimit -n 4096 |
76 | cd @PREFIX@ | | 82 | cd @PREFIX@ |
77 | ${command} --user=${mysqld_user} --datadir=${mysqld_datadir} \ | | 83 | ${command} --user=${mysqld_user} --datadir=${mysqld_datadir} \ |
78 | --pid-file=${pidfile} ${mysqld_flags} & | | 84 | --pid-file=${pidfile} ${mysqld_flags} \ |
| | | 85 | ${thread_flags} & |
79 | } | | 86 | } |
80 | | | 87 | |
81 | if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then | | 88 | if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then |
82 | load_rc_config $name | | 89 | load_rc_config $name |
| | | 90 | pidfile="${mysqld_datadir}/`@HOSTNAME_CMD@`.pid" |
83 | run_rc_command "$1" | | 91 | run_rc_command "$1" |
84 | else | | 92 | else |
85 | if [ -f /etc/rc.conf ]; then | | 93 | if [ -f /etc/rc.conf ]; then |
86 | . /etc/rc.conf | | 94 | . /etc/rc.conf |
87 | fi | | 95 | fi |
| | | 96 | pidfile="${mysqld_datadir}/`@HOSTNAME_CMD@`.pid" |
88 | case "$1" in | | 97 | case "$1" in |
89 | initdb) | | 98 | initdb) |
90 | eval ${initdb_cmd} | | 99 | eval ${initdb_cmd} |
91 | ;; | | 100 | ;; |
92 | stop) | | 101 | stop) |
93 | if [ -r "${pidfile}" ]; then | | 102 | if [ -r "${pidfile}" ]; then |
94 | @ECHO@ "Stopping ${name}." | | 103 | @ECHO@ "Stopping ${name}." |
95 | kill `@CAT@ ${pidfile}` | | 104 | kill `@CAT@ ${pidfile}` |
96 | fi | | 105 | fi |
97 | ;; | | 106 | ;; |
98 | *) | | 107 | *) |
99 | eval ${start_precmd} | | 108 | eval ${start_precmd} |
100 | eval ${start_cmd} | | 109 | eval ${start_cmd} |