Re: Connecting MYSQL/MariaDB as an openrc service
Reply #4 –
Actually this is what is installed right now. Things have slowly evolved.
world/mariadb 11.7.2-2 [installed: 11.7.2-3]
When I first migrated to artix, I wasn't happy with the mysql set up and I was moved on to mariabd. I am friends with Monty. So I hacked my own openrc scripts that called mysqladmin. I've always had problems with the temp directory being created and had to make it by hand (I know I am stupid)
Now, I think things have caught up and changed, maybe
#!/usr/bin/openrc-run
2 # Distributed under the terms of the GNU General Public License v2
3 echo "Hello"
4 #extra_commands="checkconfig"
5 #extra_started_commands="reload"
6
7 : ${MARIADB_CONFDIR:=/etc/mysql}
8 : ${MARIADB_CONFIG:=${MARIADB_CONFDIR}/my.cnf}
9 : ${MARIADB_PIDFILE:=/run/${SVCNAME}/${SVCNAME}.pid}
10 : ${MARIADB_BINARY:=/usr/bin/mysqld}
11 : ${MARIADB_OPTS:='user=mariadb'}
12
13 echo "PIDFILE ${MARIADB_PIDFILE}"
14 depend() {
15 use logger dns
16 if [ "${rc_need+set}" = "set" ] ; then
17 : # Do nothing, the user has explicitly set rc_need
18 else
19 local x warn_addr
20 for x in $(awk '/^ListenAddress/{ print $2 }' "$MARIADB_CONFIG" 2>/dev/null) ; do
21 case "${x}" in
22 0.0.0.0|0.0.0.0:*) ;;
23 ::|\[::\]*) ;;
24 *) warn_addr="${warn_addr} ${x}" ;;
25 esac
26 done
27 if [ -n "${warn_addr}" ] ; then
28 need net
29 ewarn "You are binding an interface in ListenAddress statement in your mariadbd_config!"
30 ewarn "You must add rc_need=\"net.FOO\" to your /etc/conf.d/mariadbd"
31 ewarn "where FOO is the interface(s) providing the following address(es):"
32 ewarn "${warn_addr}"
33 fi
34 fi
35 }
36
37 checkconfig() {
38 if [ ! -d /var/empty ] ; then
39 mkdir -p /var/empty || return 1
40 fi
41
42 if [ ! -e "${MARIADB_CONFIG}" ] ; then
43 eerror "You need an ${MARIADB_CONFIG} file to run mariadbd"
44 eerror "There is a sample file in /usr/share/doc/openmariadb"
45 return 1
46 fi
47
48 }
49
50 start() {
51 checkconfig || return 1
52
53 ebegin "Starting ${SVCNAME}"
54 echo "PIDFILE ${MARIADB_PIDFILE}"
55 echo "Command ${MARIADB_BINARY} --${MARIADB_OPTS}"
56 start-stop-daemon -vP --start --background "${MARIADB_BINARY}" --"${MARIADB_OPTS}"
57 echo "${MARIADB_BINARY}"
58 eend $?
59 }
60
61 stop() {
62 if [ "${RC_CMD}" = "restart" ] ; then
63 checkconfig || return 1
64 fi
65
66 ebegin "Stopping ${SVCNAME}"
67 start-stop-daemon --stop --exec "${MARIADB_BINARY}" \
68 --pidfile "${MARIADB_PIDFILE}" --quiet
69 eend $?
70 }
71
72 reload() {
73 checkconfig || return 1
74 ebegin "Reloading ${SVCNAME}"
75 start-stop-daemon --signal HUP \
76 --exec "${MARIADB_BINARY}" --pidfile "${MARIADB_PIDFILE}"
77 eend $?
78 }