mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
mariadb: convert init script to procd
Also create a user "mariadb" and use it for running the server. And add possibility to easily add command line args. Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user