You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2010-2018 OpenWrt.org
  3. START=95
  4. STOP=10
  5. USE_PROCD=1
  6. #PROCD_DEBUG=1
  7. MYSQLD=mysqld
  8. DEFAULT=/etc/default/$MYSQLD
  9. LOGGER="/usr/bin/logger -p user.err -s -t $MYSQLD"
  10. PROG=/usr/bin/$MYSQLD
  11. unset MY_ARGS MY_GROUP MY_USER
  12. [ -f $DEFAULT ] && . $DEFAULT
  13. my_user="${MY_USER:-mariadb}"
  14. my_group="${MY_GROUP:-mariadb}"
  15. start_service() {
  16. local conf='/etc/mysql/my.cnf'
  17. local datadir="$( sed -nE "s/^\s*datadir\s*=\s*('([^']*)'|\x22([^\x22]*)\x22|(.*\S))\s*$/\2\3\4/p" "$conf" )"
  18. [ -d "$datadir" ] || {
  19. $LOGGER "datadir '$datadir' in '$conf' does not exist"
  20. return 1
  21. }
  22. [ -f "$datadir/mysql/tables_priv.MYD" ] || {
  23. $LOGGER "cannot detect privileges table, you might need to"
  24. $LOGGER "run 'mysql_install_db --force' to initialize the system tables"
  25. return 1
  26. }
  27. mkdir -p /var/lib/mysql
  28. chown "$my_user":"$my_group" /var/lib/mysql
  29. mkdir -p /var/run/mysqld
  30. chown "$my_user":"$my_group" /var/run/mysqld
  31. procd_open_instance
  32. procd_set_param command $PROG $MY_ARGS
  33. procd_set_param pidfile /var/run/mysqld.pid
  34. # forward stderr to logd
  35. procd_set_param stderr 1
  36. procd_close_instance
  37. }