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