blob: 960dc1ea191ae605ea1dc5c9cba423a7c2f6267f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: mysqld.sh,v 1.7 2009/02/05 13:46:36 he Exp $
#
# PROVIDE: mysqld
# REQUIRE: DAEMON LOGIN mountall
# KEYWORD: shutdown
#
# You will need to set some variables in /etc/rc.conf to start MySQL:
#
# mysqld=YES
#
# The following variables are optional:
#
# mysqld_user="mysql" # user to run mysqld as
# mysqld_datadir="/path/to/home" # path to MySQL database directory
#
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
fi
name="mysqld"
rcvar=${name}
command="@PREFIX@/bin/mysqld_safe"
procname="@PREFIX@/libexec/${name}"
: ${mysqld_user:=@MYSQL_USER@}
: ${mysqld_group:=@MYSQL_GROUP@}
: ${mysqld_datadir:=@MYSQL_DATADIR@}
extra_commands="initdb"
initdb_cmd="mysqld_initdb"
start_precmd="mysqld_precmd"
start_cmd="mysqld_start"
mysqld_precmd()
{
if [ ! -d ${mysqld_datadir} ]; then
mysqld_initdb
fi
}
mysqld_initdb()
{
initdb="@PREFIX@/bin/mysql_install_db"
if [ ! -x ${initdb} ]; then
return 1
fi
if [ -f ${mysqld_datadir}/mysql/host.frm ]; then
@ECHO@ "The MySQL database has already been initialized."
@ECHO@ "Skipping database initialization."
else
@ECHO@ "Initializing MySQL database system tables."
${initdb} --force --user=${mysqld_user} \
--datadir=${mysqld_datadir} || return 1
if [ -d ${mysqld_datadir} ]; then
@CHOWN@ -R ${mysqld_user}:${mysqld_group} \
${mysqld_datadir}
fi
fi
}
mysqld_start()
{
for f in $required_files; do
if [ ! -r "$f" ]; then
@ECHO@ 1>&2 "$0: WARNING: $f is not readable"
if [ -z $rc_force ]; then
return 1
fi
fi
done
@ECHO@ "Starting ${name}."
ulimit -n 4096
cd @PREFIX@
${command} --user=${mysqld_user} --datadir=${mysqld_datadir} \
--pid-file=${pidfile} ${mysqld_flags} &
}
if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
load_rc_config $name
pidfile="${mysqld_datadir}/`@HOSTNAME_CMD@`.pid"
run_rc_command "$1"
else
if [ -f /etc/rc.conf ]; then
. /etc/rc.conf
fi
pidfile="${mysqld_datadir}/`@HOSTNAME_CMD@`.pid"
case "$1" in
initdb)
eval ${initdb_cmd}
;;
stop)
if [ -r "${pidfile}" ]; then
@ECHO@ "Stopping ${name}."
kill `@CAT@ ${pidfile}`
fi
;;
*)
eval ${start_precmd}
eval ${start_cmd}
;;
esac
fi
|