rc.mysql 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. mysql_flush_logs () {
  24. HOME=@l_prefix@/etc/mysql @l_prefix@/bin/mysqladmin \
  25. --defaults-extra-file=${mysql_pwd_file} \
  26. flush-logs
  27. }
  28. %status -u @l_susr@ -o
  29. mysql_usable="unknown"
  30. mysql_active="no"
  31. HOME=@l_prefix@/etc/mysql @l_prefix@/bin/mysqladmin \
  32. --defaults-extra-file=${mysql_pwd_file} \
  33. ping >/dev/null 2>&1 && mysql_active="yes"
  34. if [ $mysql_active = "no" -a -f $mysql_pid_file ] ; then
  35. kill -0 `cat $mysql_pid_file` && mysql_active="unknown"
  36. fi
  37. echo "mysql_enable=\"$mysql_enable\""
  38. echo "mysql_usable=\"$mysql_usable\""
  39. echo "mysql_active=\"$mysql_active\""
  40. %start -p 400 -u @l_susr@
  41. rcService mysql enable yes || exit 0
  42. rcService mysql active yes && exit 0
  43. cd @l_prefix@
  44. cmd="@l_prefix@/bin/mysqld_safe"
  45. cmd="$cmd --pid-file=$mysql_pid_file"
  46. cmd="$cmd --log-error=$mysql_err_log"
  47. su @l_rusr@ -c "$cmd </dev/null >/dev/null 2>&1 &" </dev/null >/dev/null 2>&1
  48. %stop -p 600 -u @l_susr@
  49. rcService mysql enable yes || exit 0
  50. rcService mysql active no && exit 0
  51. mysql_flush_logs
  52. HOME=@l_prefix@/etc/mysql @l_prefix@/bin/mysqladmin \
  53. --defaults-extra-file=${mysql_pwd_file} \
  54. shutdown
  55. %restart -p 400 -u @l_susr@
  56. rcService mysql enable yes || exit 0
  57. rcService mysql active no && exit 0
  58. rc mysql stop start
  59. %daily -u @l_susr@
  60. rcService mysql enable yes || exit 0
  61. rcTmp -i
  62. hintfile=`rcTmp -f -n hint`
  63. shtool rotate -f \
  64. -n ${mysql_common_numfiles} -s ${mysql_common_minsize} -d \
  65. -z ${mysql_common_complevel} -m 660 -o @l_rusr@ -g @l_rgrp@ \
  66. -P "${mysql_common_prolog}" \
  67. -E "${mysql_common_epilog}; echo 1 >$hintfile" \
  68. ${mysql_common_log}
  69. shtool rotate -f \
  70. -n ${mysql_err_numfiles} -s ${mysql_err_minsize} -d \
  71. -z ${mysql_err_complevel} -m 660 -o @l_rusr@ -g @l_rgrp@ \
  72. -P "${mysql_err_prolog}" \
  73. -E "${mysql_err_epilog}; echo 1 >$hintfile" \
  74. ${mysql_err_log}
  75. if [ -s $hintfile ]; then
  76. mysql_flush_logs
  77. fi
  78. rcTmp -k