aboutsummaryrefslogtreecommitdiffstats
path: root/main/mariadb/mariadb.initd
blob: ebb7053e0baf1585f661c93ad84a53a0f4cb3dc9 (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
#!/sbin/openrc-run

getconf() {
	v=$(my_print_defaults --mysqld | grep ^--$1)
	[ -z $v ] && echo $2 || echo ${v#*=}
}

retry="60"
extra_stopped_commands="setup"
pidfile="/run/mysqld/$RC_SVCNAME.pid"
command="/usr/bin/mysqld_safe"
command_args="--syslog --nowatch --pid-file=$pidfile"

depend() {
	use net
	need localmount
}

setup() {
	ebegin "Creating a new MySQL database"
	mysql_install_db --user=mysql --rpm
	eend $?
}

start_pre() {
	required_dirs=$(getconf datadir "/var/lib/mysql")
	if [ ! -d $required_dirs/mysql ]; then
		eerror "Datadir '$required_dirs' is empty or invalid."
		eerror "Run '/etc/init.d/mariadb setup' to create new database."
	fi
}

start_post() {
	ewaitfile 10 $(getconf socket "/run/mysqld/mysqld.sock")
}