vboxballoonctrl-service.sh revision 8a0e16a59a2c5ffeeac323e1842e65a4ddf3c5c1
#
# VirtualBox watchdog daemon init script.
#
# Copyright (C) 2006-2013 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# chkconfig: 35 35 65
# description: VirtualBox watchdog daemon
#
### BEGIN INIT INFO
# Provides: vboxballoonctrl-service
# Required-Start: vboxdrv
# Required-Stop: vboxdrv
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: VirtualBox watchdog daemon
### END INIT INFO
if [ -n "$INSTALL_DIR" ]; then
binary="$INSTALL_DIR/VBoxBalloonCtrl"
else
fi
# silently exit if the package was uninstalled but not purged,
# applies to Debian packages only (but shouldn't hurt elsewhere)
if [ -f /etc/redhat-release ]; then
elif [ -f /etc/SuSE-release ]; then
elif [ -f /etc/debian_version ]; then
elif [ -f /etc/gentoo-release ]; then
elif [ -f /etc/arch-release ]; then
elif [ -f /etc/slackware-version ]; then
elif [ -f /etc/lfs-release ]; then
else
fi
fi
if [ -z "$NOLSB" ]; then
echo ""
log_failure_msg "$1"
}
log_success_msg " done."
}
log_daemon_msg "$@"
}
fi
if [ "$system" = "redhat" ]; then
if [ -n "$NOLSB" ]; then
usr="$1"
shift
}
echo
}
echo
}
echo -n "$1"
}
fi
fi
if [ "$system" = "suse" ]; then
usr="$1"
shift
}
if [ -n "$NOLSB" ]; then
rc_status -v
}
rc_status -v
}
echo -n "$1"
}
fi
fi
if [ "$system" = "debian" ]; then
usr="$1"
shift
bin="$1"
shift
}
}
if [ -n "$NOLSB" ]; then
echo " ...fail!"
}
echo " ...done."
}
echo -n "$1"
}
fi
fi
if [ "$system" = "gentoo" ]; then
if [ -f /sbin/functions.sh ]; then
. /sbin/functions.sh
fi
usr="$1"
shift
bin="$1"
shift
}
}
if [ -n "$NOLSB" ]; then
echo " ...fail!"
}
echo " ...done."
}
echo -n "$1"
}
shift
fi
fi
fi
if [ "$system" = "arch" ]; then
usr="$1"
shift
test $? -eq 0 && add_daemon rc.`basename $2`
}
killall $@
}
if [ -n "$NOLSB" ]; then
}
}
stat_busy "$1"
}
fi
fi
if [ "$system" = "slackware" ]; then
killall $1
}
if [ -n "$NOLSB" ]; then
echo " ...fail!"
}
echo " ...done."
}
echo -n "$1"
}
fi
usr="$1"
shift
}
fi
if [ "$system" = "lfs" ]; then
if [ -n "$NOLSB" ]; then
}
}
echo $1
}
fi
usr="$1"
shift
}
statusproc $1
}
fi
if [ "$system" = "other" ]; then
if [ -n "$NOLSB" ]; then
echo " ...fail!"
}
echo " ...done."
}
echo -n "$1"
}
fi
fi
}
if [ -n "$2" ]; then
fail_msg "VBOXWATCHDOG_USER must not contain multiple users!"
exit 1
fi
}
if ! test -f $PIDFILE; then
vboxdrvrunning || {
fail_msg "VirtualBox kernel module not loaded!"
exit 0
}
# Handle legacy parameters, do not add any further ones unless absolutely necessary.
[ -z "$VBOXWATCHDOG_BALLOON_INTERVAL" -a -n "$VBOXBALLOONCTRL_INTERVAL" ] && VBOXWATCHDOG_BALLOON_INTERVAL="$VBOXBALLOONCTRL_INTERVAL"
[ -z "$VBOXWATCHDOG_BALLOON_INCREMENT" -a -n "$VBOXBALLOONCTRL_INCREMENT" ] && VBOXWATCHDOG_BALLOON_INCREMENT="$VBOXBALLOONCTRL_INCREMENT"
[ -z "$VBOXWATCHDOG_BALLOON_DECREMENT" -a -n "$VBOXBALLOONCTRL_DECREMENT" ] && VBOXWATCHDOG_BALLOON_DECREMENT="$VBOXBALLOONCTRL_DECREMENT"
[ -z "$VBOXWATCHDOG_BALLOON_LOWERLIMIT" -a -n "$VBOXBALLOONCTRL_LOWERLIMIT" ] && VBOXWATCHDOG_BALLOON_LOWERLIMIT="$VBOXBALLOONCTRL_LOWERLIMIT"
[ -z "$VBOXWATCHDOG_BALLOON_SAFETYMARGIN" -a -n "$VBOXBALLOONCTRL_SAFETYMARGIN" ] && VBOXWATCHDOG_BALLOON_SAFETYMARGIN="$VBOXBALLOONCTRL_SAFETYMARGIN"
[ -z "$VBOXWATCHDOG_ROTATE" -a -n "$VBOXBALLOONCTRL_ROTATE" ] && VBOXWATCHDOG_ROTATE="$VBOXBALLOONCTRL_ROTATE"
[ -z "$VBOXWATCHDOG_LOGSIZE" -a -n "$VBOXBALLOONCTRL_LOGSIZE" ] && VBOXWATCHDOG_LOGSIZE="$VBOXBALLOONCTRL_LOGSIZE"
[ -z "$VBOXWATCHDOG_LOGINTERVAL" -a -n "$VBOXBALLOONCTRL_LOGINTERVAL" ] && VBOXWATCHDOG_LOGINTERVAL="$VBOXBALLOONCTRL_LOGINTERVAL"
PARAMS="--background"
[ -n "$VBOXWATCHDOG_BALLOON_INTERVAL" ] && PARAMS="$PARAMS --balloon-interval \"$VBOXWATCHDOG_BALLOON_INTERVAL\""
[ -n "$VBOXWATCHDOG_BALLOON_INCREMENT" ] && PARAMS="$PARAMS --balloon-inc \"$VBOXWATCHDOG_BALLOON_INCREMENT\""
[ -n "$VBOXWATCHDOG_BALLOON_DECREMENT" ] && PARAMS="$PARAMS --balloon-dec \"$VBOXWATCHDOG_BALLOON_DECREMENT\""
[ -n "$VBOXWATCHDOG_BALLOON_LOWERLIMIT" ] && PARAMS="$PARAMS --balloon-lower-limit \"$VBOXWATCHDOG_BALLOON_LOWERLIMIT\""
[ -n "$VBOXWATCHDOG_BALLOON_SAFETYMARGIN" ] && PARAMS="$PARAMS --balloon-safety-margin \"$VBOXWATCHDOG_BALLOON_SAFETYMARGIN\""
# prevent inheriting this setting to VBoxSVC
unset VBOX_RELEASE_LOG_DEST
start_daemon $VBOXWATCHDOG_USER $binary $PARAMS > /dev/null 2>&1
# ugly: wait until the final process has forked
sleep .1
RETVAL=0
else
RETVAL=1
fi
fi
return $RETVAL
}
stop() {
if test -f $PIDFILE; then
RETVAL=$?
else
fi
fi
return $RETVAL
}
stop && start
}
echo -n "Checking for VBox watchdog service"
if [ -f $PIDFILE ]; then
echo " ...running"
else
echo " ...not running"
fi
}
case "$1" in
;;
stop)
stop
;;
;;
;;
;;
;;
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL