ksmtuned.init 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. #
  3. # ksmtuned Kernel Samepage Merging (KSM) Tuning Daemon
  4. #
  5. # Author: Dan Kenigsberg <danken@redhat.com>
  6. #
  7. # Copyright 2009 Red Hat, Inc. and/or its affiliates.
  8. # Released under the GPL
  9. #
  10. # chkconfig: 345 85 15
  11. # description: The KSM tuning daemon controls whether (and with what vigor) \
  12. # ksm should ksm search duplicated pages.
  13. # processname: ksmtuned
  14. # config: /etc/ksmtuned.conf
  15. # pidfile: /run/ksmtuned.pid
  16. #
  17. ### BEGIN INIT INFO
  18. # Provides: ksmtuned
  19. # Required-Start:
  20. # Required-Stop:
  21. # Should-Start:
  22. # Default-Start: 3 4 5
  23. # Short-Description: tune the speed of ksm
  24. # Description: The Kernel Samepage Merging control Daemon is a simple script
  25. # that controls whether (and with what vigor) should ksm search duplicated
  26. # memory pages.
  27. # needs testing and ironing. contact danken@redhat.com if something breaks.
  28. ### END INIT INFO
  29. . /etc/rc.d/init.d/functions
  30. prog=ksmtuned
  31. ksmtuned=/usr/sbin/ksmtuned
  32. pidfile=${PIDFILE-/run/ksmtune.pid}
  33. RETVAL=0
  34. start() {
  35. echo -n $"Starting $prog: "
  36. daemon --pidfile=${pidfile} $ksmtuned
  37. RETVAL=$?
  38. echo
  39. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
  40. }
  41. stop() {
  42. echo -n $"Stopping $prog: "
  43. killproc -p ${pidfile}
  44. RETVAL=$?
  45. echo
  46. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
  47. }
  48. restart() {
  49. stop
  50. start
  51. }
  52. condrestart() {
  53. [ -e /var/lock/subsys/$prog ] && restart || :
  54. }
  55. case "$1" in
  56. start)
  57. start
  58. ;;
  59. stop)
  60. stop
  61. ;;
  62. status)
  63. status -p ${pidfile} $prog
  64. RETVAL=$?
  65. ;;
  66. restart)
  67. restart
  68. ;;
  69. condrestart)
  70. condrestart
  71. ;;
  72. retune)
  73. kill -SIGUSR1 `cat ${pidfile}`
  74. RETVAL=$?
  75. ;;
  76. *)
  77. echo $"Usage: $prog {start|stop|restart|condrestart|status|retune|help}"
  78. RETVAL=3
  79. esac
  80. exit $RETVAL