aboutsummaryrefslogtreecommitdiffstats
path: root/main/mariadb/mariadb.initd
blob: 8409bad26d404328c72439a0bb32cc81e5354b15 (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
#!/sbin/openrc-run
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql/files/mysql.init,v 1.7 2004/07/14 21:41:15 agriffis Exp $

extra_stopped_commands="setup"
pidfile=/var/run/mysqld/mysqld.pid

depend() {
	need net
	after firewall
	use dns
}

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

checkconfig() {
	if [ ! -f /etc/mysql/my.cnf ] ; then
		eerror "No /etc/mysql/my.cnf file exists!"
	fi

	dir=`my_print_defaults mysqld | grep -- --datadir | sed -e "s|^.*=\(.*\)|\1|"`

	dir=${dir:-/var/lib/mysql}
	[ -d ${dir}/mysql ] && return 0

	if [ -z "$AUTO_SETUP" ] ; then
		eerror "Database not found in $dir"
		eerror "You can run '/etc/init.d/mariadb setup' to setup a new database."
		return 1
	fi
	setup
}

start() {
	checkconfig || return 1
	ebegin "Starting mysqld"
	if start-stop-daemon --pidfile $pidfile \
		--start \
		--background \
		--stdout /dev/null \
		--stderr /dev/null \
		-- \
		/usr/bin/mysqld_safe --pid-file=$pidfile; then

		ewaitfile 10 /run/mysqld/mysqld.sock
		eend 0
	else
		eend $?
	fi
}

stop () {
	ebegin "Stopping mysqld"
	start-stop-daemon --stop --quiet \
		--pidfile $pidfile --retry 20
	eend $?
}