diff options
Diffstat (limited to 'main/mariadb/mariadb.initd')
-rw-r--r-- | main/mariadb/mariadb.initd | 63 |
1 files changed, 18 insertions, 45 deletions
diff --git a/main/mariadb/mariadb.initd b/main/mariadb/mariadb.initd index 8409bad26d..cb2a388b96 100644 --- a/main/mariadb/mariadb.initd +++ b/main/mariadb/mariadb.initd @@ -1,15 +1,19 @@ #!/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 $ +getconf() { + v=$(my_print_defaults --mysqld | grep ^--$1) + [ -z $v ] && echo $2 || echo ${v#*=} +} + +retry="60" +pidfile=$(getconf pid-file "/run/mysqld/mysqld.pid") extra_stopped_commands="setup" -pidfile=/var/run/mysqld/mysqld.pid +command="/usr/bin/mysqld_safe" +command_args="--pid-file=$pidfile --syslog --nowatch" depend() { - need net - after firewall - use dns + use net + need localmount } setup() { @@ -18,45 +22,14 @@ setup() { 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 +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 - 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 $? +start_post() { + ewaitfile 10 $(getconf socket "/run/mysqld/mysqld.sock") } |