[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] debian hobbit client init script
- To: hobbit (at) hswn.dk
- Subject: [patch] debian hobbit client init script
- From: Gildas Le Nadan <gn1 (at) sanger.ac.uk>
- Date: Mon, 20 Nov 2006 15:22:39 +0000
- User-agent: Debian Thunderbird 1.0.2 (X11/20060724)
Hi,
As I said earlier we want the hobbit client script to remove the
temporary files and kill the rogue processes when stopped, mainly so the
hobbit-client installation/upgrade process through cfengine runs smoothly.
Here is a patch to the debian hobbit client init script to do the
following actions when the hobbit client is stopped:
- remove the /var/run/hobbitclient-runtime.cfg file
- kill the unwanted vmstat processes that were left running
- remove any files owned by hobbit from /tmp
Patch may be applied on 4.2.0 with allinone patch applied, using:
cd hobbit-4.2.0
patch -p1 < /path/to/patch/hobbitclient_clean.patch
Comments to help polishing this solution are more than welcome!
Cheers
Gildas
diff -Naur hobbit-4.2.0-allinone/debian/hobbit-client.init hobbit-4.2.0-cfengine/debian/hobbit-client.init
--- hobbit-4.2.0-allinone/debian/hobbit-client.init 2006-08-09 21:10:17.000000000 +0100
+++ hobbit-4.2.0-cfengine/debian/hobbit-client.init 2006-11-20 13:48:29.757748327 +0000
@@ -26,14 +26,33 @@
exit 1
fi
-set $HOBBITSERVERS
-if [ $# -eq 1 ]; then
- echo "BBDISP=\"$HOBBITSERVERS\"" >/var/run/hobbitclient-runtime.cfg
- echo "BBDISPLAYS=\"\"" >>/var/run/hobbitclient-runtime.cfg
-else
- echo "BBDISP=\"0.0.0.0\"" >/var/run/hobbitclient-runtime.cfg
- echo "BBDISPLAYS=\"$HOBBITSERVERS\"" >>/var/run/hobbitclient-runtime.cfg
-fi
+set_servers () {
+ set $HOBBITSERVERS
+ if [ $# -eq 1 ]; then
+ echo "BBDISP=\"$HOBBITSERVERS\"" >/var/run/hobbitclient-runtime.cfg
+ echo "BBDISPLAYS=\"\"" >>/var/run/hobbitclient-runtime.cfg
+ else
+ echo "BBDISP=\"0.0.0.0\"" >/var/run/hobbitclient-runtime.cfg
+ echo "BBDISPLAYS=\"$HOBBITSERVERS\"" >>/var/run/hobbitclient-runtime.cfg
+ fi
+}
+
+kill_rogue_vmstat () {
+ for VMSTAT_PID in `ps -U hobbit | grep vmstat | awk '{print $1}'`; do
+ kill ${VMSTAT_PID}
+ done
+ # wait for the nohup parent shell script to finish
+ sleep 1
+}
+
+clean_var_run () {
+ rm /var/run/hobbitclient-runtime.cfg >/dev/null 2>&1
+}
+
+clean_tmp () {
+ # it's not the cleanest but debian client use /tmp as BBTMP anyway
+ find /tmp -user hobbit -exec rm -rf \{} \; >/dev/null 2>&1
+}
if [ "$CLIENTHOSTNAME" != "" ]; then
DMNOPTS="${DMNOPTS} --hostname=${CLIENTHOSTNAME}"
@@ -47,17 +66,23 @@
case "$CMD" in
start)
echo -n "Starting $DESC: "
+ set_servers
su -c "$DAEMON $DMNOPTS start" - hobbit
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
su -c "$DAEMON stop" - hobbit
+ kill_rogue_vmstat
+ clean_tmp
+ clean_var_run
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
su -c "$DAEMON stop" - hobbit
+ kill_rogue_vmstat
+ clean_tmp
su -c "$DAEMON $DMNOPTS start" - hobbit
echo "$NAME."
;;