smf-vboxballoonctrl.sh revision 8a0e16a59a2c5ffeeac323e1842e65a4ddf3c5c1
# $Id$
# Copyright (C) 2008-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.
#
#
# smf-vboxballoonctrl method
#
# Argument is the method name (start, stop, ...)
VW_OPT="$1"
VW_EXIT=0
echo "ERROR: /opt/VirtualBox/VBoxBalloonCtrl does not exist."
return $SMF_EXIT_ERR_CONFIG
fi
echo "ERROR: /opt/VirtualBox/VBoxBalloonCtrl does not exist."
return $SMF_EXIT_ERR_CONFIG
fi
# Get svc configuration
[ $? != 0 ] && VBOXWATCHDOG_USER=
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_INTERVAL=
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_INCREMENT=
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_DECREMENT=
VBOXWATCHDOG_BALLOON_LOWERLIMIT=`/usr/bin/svcprop -p config/balloon_lowerlimit $SMF_FMRI 2>/dev/null`
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_LOWERLIMIT=
VBOXWATCHDOG_BALLOON_SAFETYMARGIN=`/usr/bin/svcprop -p config/balloon_safetymargin $SMF_FMRI 2>/dev/null`
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_SAFETYMARGIN=
[ $? != 0 ] && VBOXWATCHDOG_ROTATE=
[ $? != 0 ] && VBOXWATCHDOG_LOGSIZE=
[ $? != 0 ] && VBOXWATCHDOG_LOGINTERVAL=
# Handle legacy parameters, do not add any further ones unless absolutely necessary.
if [ -z "$VBOXWATCHDOG_BALLOON_INTERVAL" ]; then
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_INTERVAL=
fi
if [ -z "$VBOXWATCHDOG_BALLOON_INCREMENT" ]; then
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_INCREMENT=
fi
if [ -z "$VBOXWATCHDOG_BALLOON_DECREMENT" ]; then
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_DECREMENT=
fi
if [ -z "$VBOXWATCHDOG_BALLOON_LOWERLIMIT" ]; then
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_LOWERLIMIT=
fi
if [ -z "$VBOXWATCHDOG_BALLOON_SAFETYMARGIN" ]; then
[ $? != 0 ] && VBOXWATCHDOG_BALLOON_SAFETYMARGIN=
fi
# Provide sensible defaults
# Assemble the parameter list
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\""
VW_EXIT=$?
if [ $VW_EXIT != 0 ]; then
echo "VBoxBalloonCtrl failed with $VW_EXIT."
VW_EXIT=1
fi
;;
stop)
# Kill service contract
;;
*)
;;
esac
exit $VW_EXIT