cd8d5cb
#!/bin/bash
cd8d5cb
#
cd8d5cb
# ksmtuned     Kernel Samepage Merging (KSM) Tuning Daemon
cd8d5cb
#
cd8d5cb
# Author:      Dan Kenigsberg <danken@redhat.com>
cd8d5cb
#
cd8d5cb
# Copyright 2009 Red Hat, Inc. and/or its affiliates.
cd8d5cb
# Released under the GPL
cd8d5cb
#
8e8b4c1
# chkconfig: 345 85 15
cd8d5cb
# description: The KSM tuning daemon controls whether (and with what vigor) \
cd8d5cb
#              ksm should ksm search duplicated pages.
cd8d5cb
# processname: ksmtuned
cd8d5cb
# config: /etc/ksmtuned.conf
cd8d5cb
# pidfile: /var/run/ksmtuned.pid
cd8d5cb
#
cd8d5cb
### BEGIN INIT INFO
cd8d5cb
# Provides: ksmtuned
cd8d5cb
# Required-Start:
cd8d5cb
# Required-Stop:
cd8d5cb
# Should-Start:
8e8b4c1
# Default-Start: 3 4 5
cd8d5cb
# Short-Description: tune the speed of ksm
cd8d5cb
# Description: The Kernel Samepage Merging control Daemon is a simple script
cd8d5cb
#   that controls whether (and with what vigor) should ksm search duplicated
cd8d5cb
#   memory pages.
cd8d5cb
#   needs testing and ironing. contact danken@redhat.com if something breaks.
cd8d5cb
### END INIT INFO
cd8d5cb
cd8d5cb
. /etc/rc.d/init.d/functions
cd8d5cb
cd8d5cb
prog=ksmtuned
cd8d5cb
ksmtuned=/usr/sbin/ksmtuned
cd8d5cb
pidfile=${PIDFILE-/var/run/ksmtune.pid}
cd8d5cb
RETVAL=0
cd8d5cb
cd8d5cb
start() {
cd8d5cb
    echo -n $"Starting $prog: "
cd8d5cb
    daemon --pidfile=${pidfile} $ksmtuned
cd8d5cb
    RETVAL=$?
cd8d5cb
    echo
cd8d5cb
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
cd8d5cb
}
cd8d5cb
cd8d5cb
stop() {
cd8d5cb
    echo -n $"Stopping $prog: "
cd8d5cb
    killproc -p ${pidfile}
cd8d5cb
    RETVAL=$?
cd8d5cb
    echo
cd8d5cb
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
cd8d5cb
}
cd8d5cb
cd8d5cb
restart() {
cd8d5cb
    stop
cd8d5cb
    start
cd8d5cb
}
cd8d5cb
cd8d5cb
condrestart() {
cd8d5cb
    [ -e /var/lock/subsys/$prog ] && restart || :
cd8d5cb
}
cd8d5cb
cd8d5cb
case "$1" in
cd8d5cb
  start)
cd8d5cb
	start
cd8d5cb
	;;
cd8d5cb
  stop)
cd8d5cb
	stop
cd8d5cb
	;;
cd8d5cb
  status)
cd8d5cb
        status -p ${pidfile} $prog
cd8d5cb
	RETVAL=$?
cd8d5cb
	;;
afaf04c
  restart|force-reload)
cd8d5cb
	restart
cd8d5cb
	;;
afaf04c
  condrestart|try-restart)
cd8d5cb
	condrestart
cd8d5cb
	;;
39f14e1
  retune)
502ffee
        pid=`cat ${pidfile} 2> /dev/null`
39f14e1
        RETVAL=$?
502ffee
        if [ -z "$pid" ]; then
502ffee
	    echo $"Cannot retune, service is not running."
502ffee
	else
502ffee
            kill -SIGUSR1 $pid
502ffee
            RETVAL=$?
502ffee
	fi
b4ed0c8
        ;;
cd8d5cb
  *)
afaf04c
	echo $"Usage: $prog {start|stop|restart|force-reload|condrestart|try-restart|status|retune|help}"
afaf04c
	RETVAL=2
cd8d5cb
esac
cd8d5cb
cd8d5cb
exit $RETVAL