rc.mysql 2.6 KB

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