aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenballoon/xenballoond.init
diff options
context:
space:
mode:
Diffstat (limited to 'tools/xenballoon/xenballoond.init')
-rw-r--r--tools/xenballoon/xenballoond.init91
1 files changed, 91 insertions, 0 deletions
diff --git a/tools/xenballoon/xenballoond.init b/tools/xenballoon/xenballoond.init
new file mode 100644
index 0000000000..bd2d928052
--- /dev/null
+++ b/tools/xenballoon/xenballoond.init
@@ -0,0 +1,91 @@
+#!/bin/bash
+#
+# xenballoond Script to start and stop Xen ballooning daemon.
+#
+# Copyright (C) 2008 Oracle Corporation and/or its affiliates.
+# All rights reserved.
+# Written by: Dan Magenheimer <dan.magenheimer@oracle.com>
+#
+# chkconfig: 2345 98 01
+# description: Starts and stops the Xen control daemon.
+### BEGIN INIT INFO
+# Provides: xenballoond
+# Required-Start: $syslog $remote_fs
+# Should-Start:
+# Required-Stop: $syslog $remote_fs
+# Should-Stop:
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Default-Enabled: yes
+# Short-Description: Start/stop xend
+# Description: Starts and stops the Xen ballooning daemon.
+### END INIT INFO
+
+# Source function library
+. /etc/init.d/functions
+
+#don't use in domain0
+[ -f /proc/xen/capabilities ] && \
+ grep -q "control_d" /proc/xen/capabilities && exit 0
+
+if [ -f /etc/sysconfig/xenballoon.conf ]; then
+ . /etc/sysconfig/xenballoon.conf
+fi
+
+# Check that balloon driver is present
+[ ! -f /proc/xen/balloon ] && exit 0
+
+# Record original memory (in kB)
+[ -z "$XENBALLOON_MAXMEMFILE" ] && exit 0
+let maxmem=`grep MemTotal /proc/meminfo | sed 's/ */ /' | cut -f2 -d' '`
+if [ -f "$XENBALLOON_MAXMEMFILE" ]; then
+ let oldmax=`cat $XENBALLOON_MAXMEMFILE`
+ if [ $oldmax -gt $maxmem ]; then
+ let maxmem=oldmax
+ fi
+fi
+echo $maxmem > $XENBALLOON_MAXMEMFILE
+
+RETVAL=0
+prog="xenballoond"
+
+start() {
+ # Start daemons.
+ echo -n $"Starting $prog: "
+ daemon xenballoond $OPTIONS
+ RETVAL=$?
+ echo
+ return $RETVAL
+}
+
+stop() {
+ echo -n $"Shutting down $prog: "
+ killproc xenballoond
+ RETVAL=$?
+ echo
+ return $RETVAL
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status xenballoond
+ RETVAL=$?
+ ;;
+ restart|reload)
+ stop
+ start
+ RETVAL=$?
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|status}"
+ exit 1
+esac
+
+exit $RETVAL