mariadb: convert init script to procd
- also adds mariadb user to run the server as - tweaks the default configuration a bit Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
This commit is contained in:
parent
a26540d61c
commit
a4df7b1db3
4 changed files with 59 additions and 23 deletions
|
@ -268,6 +268,7 @@ define Package/mariadb-server
|
|||
TITLE:=MariaDB database core server binaries
|
||||
MENU:=1
|
||||
PROVIDES:=mysql-server
|
||||
USERID:=mariadb=376:mariadb=376
|
||||
endef
|
||||
|
||||
define Package/mariadb-server/description
|
||||
|
@ -344,9 +345,10 @@ CMAKE_OPTIONS += \
|
|||
-DINSTALL_SCRIPTDIR=bin \
|
||||
-DINSTALL_SQLBENCHDIR="" \
|
||||
-DINSTALL_SUPPORTFILESDIR=share/mysql \
|
||||
-DMYSQLD_USER=root \
|
||||
-DINSTALL_UNIX_ADDRDIR=/var/run/mysqld/mysqld.sock \
|
||||
-DMYSQLD_USER=mariadb \
|
||||
-DMYSQL_DATADIR=/var/lib/mysql \
|
||||
-DMYSQL_UNIX_ADDR=/var/run/mysqld.sock \
|
||||
-DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \
|
||||
-DSKIP_TESTS=ON \
|
||||
-DWITH_ASAN=OFF \
|
||||
-DWITH_EMBEDDED_SERVER=OFF \
|
||||
|
@ -463,10 +465,12 @@ endef
|
|||
define Package/mariadb-server/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(foreach b,$(MARIADB_SERVER),$(call Package/mariadb/install/bin,$(1),$(b));)
|
||||
$(INSTALL_DIR) $(1)/etc/default
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/mysql/conf.d
|
||||
$(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld
|
||||
$(INSTALL_CONF) conf/my.cnf $(1)/etc/mysql
|
||||
$(INSTALL_CONF) conf/mysqld.default $(1)/etc/default/mysqld
|
||||
$(INSTALL_DIR) $(1)$(PLUGIN_DIR)
|
||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)$(PLUGIN_DIR)/daemon_example.ini $(1)$(PLUGIN_DIR)
|
||||
$(INSTALL_DIR) $(1)/usr/share/mysql/english
|
||||
|
@ -484,6 +488,7 @@ define Package/mariadb-server-extra/install
|
|||
endef
|
||||
|
||||
define Package/mariadb-server/conffiles
|
||||
/etc/default/mysqld
|
||||
/etc/mysql/my.cnf
|
||||
$(PLUGIN_DIR)/daemon_example.ini
|
||||
endef
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
[client]
|
||||
port = 3306
|
||||
socket = /var/run/mysqld.sock
|
||||
socket = /var/run/mysqld/mysqld.sock
|
||||
|
||||
[mysqld]
|
||||
user = root
|
||||
socket = /var/run/mysqld.sock
|
||||
user = mariadb
|
||||
socket = /var/run/mysqld/mysqld.sock
|
||||
port = 3306
|
||||
basedir = /usr
|
||||
|
||||
|
@ -21,21 +21,21 @@ skip-external-locking
|
|||
bind-address = 127.0.0.1
|
||||
|
||||
# Fine Tuning
|
||||
key_buffer = 16M
|
||||
key_buffer_size = 16M
|
||||
max_allowed_packet = 16M
|
||||
thread_stack = 192K
|
||||
thread_cache_size = 8
|
||||
thread_cache_size = 8
|
||||
|
||||
# Here you can see queries with especially long duration
|
||||
#log_slow_queries = /var/log/mysql/mysql-slow.log
|
||||
#long_query_time = 2
|
||||
#long_query_time = 2
|
||||
#log-queries-not-using-indexes
|
||||
|
||||
# The following can be used as easy to replay backup logs or for replication.
|
||||
#server-id = 1
|
||||
#log_bin = /var/log/mysql/mysql-bin.log
|
||||
#log_bin = /var/log/mysql/mysql-bin.log
|
||||
#expire_logs_days = 10
|
||||
#max_binlog_size = 100M
|
||||
#max_binlog_size = 100M
|
||||
#binlog_do_db = include_database_name
|
||||
#binlog_ignore_db = include_database_name
|
||||
|
||||
|
|
10
utils/mariadb/conf/mysqld.default
Normal file
10
utils/mariadb/conf/mysqld.default
Normal file
|
@ -0,0 +1,10 @@
|
|||
# The user and group that will run the MySQL server. The user mariadb is
|
||||
# automatically created by the mariadb-server package, hence that is the
|
||||
# default choice.
|
||||
|
||||
#MY_USER=mariadb
|
||||
#MY_GROUP=mariadb
|
||||
|
||||
# Additional arguments you want to pass to the MySQL server.
|
||||
|
||||
#MY_ARGS=""
|
|
@ -1,32 +1,53 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2010-2011 OpenWrt.org
|
||||
# Copyright (C) 2010-2018 OpenWrt.org
|
||||
|
||||
START=95
|
||||
STOP=10
|
||||
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_STOP_TIME=9
|
||||
PROG='/usr/bin/mysqld'
|
||||
USE_PROCD=1
|
||||
|
||||
start() {
|
||||
#PROCD_DEBUG=1
|
||||
|
||||
MYSQLD=mysqld
|
||||
|
||||
DEFAULT=/etc/default/$MYSQLD
|
||||
LOGGER="/usr/bin/logger -p user.err -s -t $MYSQLD"
|
||||
PROG=/usr/bin/$MYSQLD
|
||||
|
||||
unset MY_ARGS MY_GROUP MY_USER
|
||||
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
|
||||
my_user="${MY_USER:-mariadb}"
|
||||
my_group="${MY_GROUP:-mariadb}"
|
||||
|
||||
start_service() {
|
||||
local conf='/etc/mysql/my.cnf'
|
||||
local datadir="$( sed -nE "s/^\s*datadir\s*=\s*('([^']*)'|\x22([^\x22]*)\x22|(.*\S))\s*$/\2\3\4/p" "$conf" )"
|
||||
|
||||
[ -d "$datadir" ] || {
|
||||
logger -s "[ERROR] datadir '$datadir' in '$conf' does not exist"
|
||||
$LOGGER "datadir '$datadir' in '$conf' does not exist"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ -f "$datadir/mysql/tables_priv.MYD" ] || {
|
||||
logger -s "[ERROR] can not detect privileges table, you might need to"
|
||||
logger -s "run 'mysql_install_db --force' to initialize the system tables"
|
||||
$LOGGER "cannot detect privileges table, you might need to"
|
||||
$LOGGER "run 'mysql_install_db --force' to initialize the system tables"
|
||||
return 1
|
||||
}
|
||||
|
||||
service_start "$PROG"
|
||||
}
|
||||
mkdir -p /var/lib/mysql
|
||||
chown "$my_user":"$my_group" /var/lib/mysql
|
||||
|
||||
stop() {
|
||||
service_stop "$PROG"
|
||||
mkdir -p /var/run/mysqld
|
||||
chown "$my_user":"$my_group" /var/run/mysqld
|
||||
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command $PROG $MY_ARGS
|
||||
procd_set_param pidfile /var/run/mysqld.pid
|
||||
# forward stderr to logd
|
||||
procd_set_param stderr 1
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue