mariadb.initd 758 B

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