rc.mysql 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!@l_prefix@/bin/openpkg rc
  2. ##
  3. ## rc.mysql -- Run-Commands
  4. ##
  5. %config
  6. mysql_enable="$openpkg_rc_def"
  7. mysql_pwd_file=@l_prefix@/etc/mysql/my.pwd
  8. mysql_cnf_file=@l_prefix@/etc/mysql/my.cnf
  9. mysql_common_prolog="true"
  10. mysql_common_epilog="true"
  11. mysql_common_numfiles="10"
  12. mysql_common_minsize="1M"
  13. mysql_common_complevel="9"
  14. mysql_err_prolog="true"
  15. mysql_err_epilog="true"
  16. mysql_err_numfiles="10"
  17. mysql_err_minsize="1M"
  18. mysql_err_complevel="9"
  19. %common
  20. mysql_pid_file=@l_prefix@/var/mysql/mysqld.pid
  21. mysql_err_log=@l_prefix@/var/mysql/mysqld.err
  22. mysql_common_log=@l_prefix@/var/mysql/common.log
  23. %status -u @l_rusr@ -o
  24. mysql_usable="unknown"
  25. mysql_active="no"
  26. @l_prefix@/bin/mysqladmin \
  27. --defaults-extra-file=${mysql_pwd_file} \
  28. ping >/dev/null 2>&1 && mysql_active="yes"
  29. if [ $mysql_active = "no" -a -f $mysql_pid_file ] ; then
  30. kill -0 `cat $mysql_pid_file` && mysql_active="unknown"
  31. fi
  32. echo "mysql_enable=\"$mysql_enable\""
  33. echo "mysql_usable=\"$mysql_usable\""
  34. echo "mysql_active=\"$mysql_active\""
  35. %start -p 400 -u @l_rusr@
  36. rcService mysql enable yes || exit 0
  37. rcService mysql active yes && exit 0
  38. cd @l_prefix@
  39. @l_prefix@/bin/mysqld_safe >/dev/null 2>&1 \
  40. --pid-file="$mysql_pid_file" \
  41. --log-error="$mysql_err_log" &
  42. %stop -p 600 -u @l_susr@
  43. rcService mysql enable yes || exit 0
  44. rcService mysql active no && exit 0
  45. HOME=@l_prefix@/etc/mysql @l_prefix@/bin/mysqladmin \
  46. --defaults-extra-file=${mysql_pwd_file} \
  47. flush-logs
  48. HOME=@l_prefix@/etc/mysql @l_prefix@/bin/mysqladmin \
  49. --defaults-extra-file=${mysql_pwd_file} \
  50. shutdown
  51. %restart -p 400 -u @l_rusr@
  52. rcService mysql enable yes || exit 0
  53. rcService mysql active no && exit 0
  54. rc mysql stop start
  55. %daily -u @l_susr@
  56. rcService mysql enable yes || exit 0
  57. rcTmp -i
  58. hintfile=`rcTmp -f -n hint`
  59. shtool rotate -f \
  60. -n ${mysql_common_numfiles} -s ${mysql_common_minsize} -d \
  61. -z ${mysql_common_complevel} -m 660 -o @l_rusr@ -g @l_rgrp@ \
  62. -P "${mysql_common_prolog}" \
  63. -E "${mysql_common_epilog}; echo 1 >$hintfile" \
  64. ${mysql_common_log}
  65. shtool rotate -f \
  66. -n ${mysql_err_numfiles} -s ${mysql_err_minsize} -d \
  67. -z ${mysql_err_complevel} -m 660 -o @l_rusr@ -g @l_rgrp@ \
  68. -P "${mysql_err_prolog}" \
  69. -E "${mysql_err_epilog}; echo 1 >$hintfile" \
  70. ${mysql_err_log}
  71. if [ -s $hintfile ]; then
  72. rc mysql restart
  73. fi
  74. rcTmp -k