mariadb-supervise.initd 889 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/openrc-run
  2. extra_stopped_commands="setup"
  3. supervisor=supervise-daemon
  4. #healthcheck_timer=10
  5. retry="60"
  6. pidfile="/run/mysqld/$RC_SVCNAME.pid"
  7. command="/usr/bin/mysqld"
  8. command_args="--basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --pid-file=/run/mysqld/mariadb.pid"
  9. depend() {
  10. use net
  11. need localmount
  12. }
  13. start_pre() {
  14. required_dirs=$(getconf datadir "/var/lib/mysql")
  15. if [ ! -d $required_dirs/mysql ]; then
  16. eerror "Datadir '$required_dirs' is empty or invalid."
  17. eerror "Run '/etc/init.d/mariadb setup' to create new database."
  18. fi
  19. }
  20. start_post() {
  21. ewaitfile 10 $(getconf socket "/run/mysqld/mysqld.sock")
  22. }
  23. setup() {
  24. ebegin "Creating a new MySQL database"
  25. mysql_install_db --user=mysql --datadir=/var/lib/mysql
  26. eend $?
  27. }
  28. getconf() {
  29. v=$(my_print_defaults --mysqld | grep ^--$1)
  30. [ -z $v ] && echo $2 || echo ${v#*=}
  31. }