dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame ksmtuned.init

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