summaryrefslogtreecommitdiff
path: root/user/mariadb/mariadb.initd
diff options
context:
space:
mode:
authorDan Theisen <djt@hxx.in>2019-07-03 15:49:03 +0000
committerDan Theisen <djt@hxx.in>2019-07-06 02:32:42 +0000
commitc50636433139f26543aad061d54c3708b2a4e22a (patch)
tree76ba19e8e61c6e6f3a7c482377c9072e0ddaf2b2 /user/mariadb/mariadb.initd
parent38a0fdf20fdbc5142113e969cceee302f48a585d (diff)
downloadpackages-c50636433139f26543aad061d54c3708b2a4e22a.tar.gz
packages-c50636433139f26543aad061d54c3708b2a4e22a.tar.bz2
packages-c50636433139f26543aad061d54c3708b2a4e22a.tar.xz
packages-c50636433139f26543aad061d54c3708b2a4e22a.zip
user/mariadb: new package
Diffstat (limited to 'user/mariadb/mariadb.initd')
-rw-r--r--user/mariadb/mariadb.initd47
1 files changed, 47 insertions, 0 deletions
diff --git a/user/mariadb/mariadb.initd b/user/mariadb/mariadb.initd
new file mode 100644
index 000000000..4e1cf8d3e
--- /dev/null
+++ b/user/mariadb/mariadb.initd
@@ -0,0 +1,47 @@
+#!/sbin/openrc-run
+
+getconf() {
+ v=$(my_print_defaults --mysqld | grep ^--$1)
+ [ -z $v ] && echo $2 || echo ${v#*=}
+}
+
+retry="60"
+extra_stopped_commands="setup"
+
+user=${MYSQLD_USER:-mysql}
+group=${MYSQLD_GROUP:-mysql}
+default_datadir=$(getconf datadir "/var/lib/mariadb")
+datadir=${MYSQLD_DATADIR:-$default_datadir}
+
+command="/usr/bin/mysqld_safe"
+command_args="--syslog --nowatch --user=$user"
+
+depend() {
+ use net
+ need localmount
+}
+
+setup() {
+ checkpath -d -m 1775 -o $user:$group /run/mariadb
+ ebegin "Creating a new MySQL database in $datadir"
+ mysql_install_db --user=$user --datadir=$datadir
+ eend $?
+}
+
+start_pre() {
+ pidfile=$(getconf pid-file "/run/mariadb/mysqld.pid")
+ command_args="$command_args --pid-file=$pidfile"
+ if [ ! -d $datadir/mysql ]; then
+ eerror "Data directory '$datadir' is empty or invalid."
+ eerror "Run '/etc/init.d/mariadb setup' to create new database."
+ fi
+}
+
+start_post() {
+ ewaitfile 10 $(getconf socket "/run/mariadb/mysqld.sock")
+}
+
+stop_pre() {
+ pidfile=$(getconf pid-file "/run/mariadb/mysqld.pid")
+}
+