]> git.proxmox.com Git - ksm-control-daemon.git/blob - debian/patches/init-script.diff
initial import (from svn)
[ksm-control-daemon.git] / debian / patches / init-script.diff
1 Index: new/ksmtuned.init
2 ===================================================================
3 --- new.orig/ksmtuned.init 2011-06-14 05:58:03.000000000 +0200
4 +++ new/ksmtuned.init 2011-06-14 06:01:38.000000000 +0200
5 @@ -19,7 +19,8 @@
6 # Required-Start:
7 # Required-Stop:
8 # Should-Start:
9 -# Default-Start: 3 4 5
10 +# Default-Start: 2 3 4 5
11 +# Default-Stop: 0 1 6
12 # Short-Description: tune the speed of ksm
13 # Description: The Kernel Samepage Merging control Daemon is a simple script
14 # that controls whether (and with what vigor) should ksm search duplicated
15 @@ -27,27 +28,50 @@
16 # needs testing and ironing. contact danken@redhat.com if something breaks.
17 ### END INIT INFO
18
19 -. /etc/rc.d/init.d/functions
20 +. /lib/lsb/init-functions
21 +
22 +PATH=/sbin:/bin:/usr/sbin:/usr/bin
23
24 prog=ksmtuned
25 ksmtuned=/usr/sbin/ksmtuned
26 +DESC="KSM control daemon"
27 +
28 pidfile=${PIDFILE-/var/run/ksmtune.pid}
29 RETVAL=0
30
31 +test -x $ksmtuned || exit 0
32 +
33 +# Include defaults if available
34 +if [ -f /etc/default/$prog ] ; then
35 + . /etc/default/$prog
36 +fi
37 +
38 +if [ "$START" != "yes" ]; then
39 + exit 0
40 +fi
41 +
42 start() {
43 - echo -n $"Starting $prog: "
44 - daemon --pidfile=${pidfile} $ksmtuned
45 +
46 + [ -d /sys/kernel/mm/ksm/ ] || exit 0;
47 +
48 + log_daemon_msg "Starting $DESC" $prog
49 + pid=$( pidofproc -p ${pidfile} $ksmtuned )
50 + if [ -n "$pid" ] ; then
51 + log_begin_msg "Already running."
52 + log_end_msg 0
53 + exit 0
54 + fi
55 +
56 + start-stop-daemon --start --quiet --pidfile=${pidfile} --exec $ksmtuned
57 RETVAL=$?
58 - echo
59 - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
60 + log_end_msg $RETVAL
61 }
62
63 stop() {
64 - echo -n $"Stopping $prog: "
65 - killproc -p ${pidfile}
66 + log_daemon_msg "Stopping $DESC" $prog
67 + start-stop-daemon --stop --quiet --pidfile ${pidfile}
68 RETVAL=$?
69 - echo
70 - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
71 + log_end_msg $RETVAL
72 }
73
74 restart() {
75 @@ -55,10 +79,6 @@
76 start
77 }
78
79 -condrestart() {
80 - [ -e /var/lock/subsys/$prog ] && restart || :
81 -}
82 -
83 case "$1" in
84 start)
85 start
86 @@ -67,27 +87,28 @@
87 stop
88 ;;
89 status)
90 - status -p ${pidfile} $prog
91 - RETVAL=$?
92 + pidofproc -p ${pidfile} $ksmtuned >/dev/null
93 + RETVAL=$?
94 + if [ $RETVAL -eq 0 ]; then
95 + log_success_msg "$DESC is running."
96 + else
97 + log_failure_msg "$DESC is not running."
98 + fi
99 ;;
100 restart|force-reload)
101 restart
102 ;;
103 - condrestart|try-restart)
104 - condrestart
105 - ;;
106 - retune)
107 - pid=`cat ${pidfile} 2> /dev/null`
108 - RETVAL=$?
109 - if [ -z "$pid" ]; then
110 - echo $"Cannot retune, service is not running."
111 - else
112 + reload)
113 + pid=$( pidofproc -p ${pidfile} $ksmtuned )
114 + if [ -n "$pid" ] ; then
115 kill -SIGUSR1 $pid
116 RETVAL=$?
117 - fi
118 + else
119 + log_failure_msg "$DESC is not running."
120 + fi
121 ;;
122 *)
123 - echo $"Usage: $prog {start|stop|restart|force-reload|condrestart|try-restart|status|retune|help}"
124 + echo $"Usage: $prog {start|stop|restart|force-reload|status|reload|help}"
125 RETVAL=2
126 esac
127