vboxdrv.sh.in revision e6b62bbfe72b2586784167aaa552426303ef444f
# Sun xVM VirtualBox
# Linux kernel module init script
#
# Copyright (C) 2006-2007 Sun Microsystems, Inc.
#
# 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 30 60
# description: VirtualBox Linux kernel module
#
### BEGIN INIT INFO
# Provides: vboxdrv
# Required-Start: $syslog
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Short-Description: VirtualBox Linux kernel module
### END INIT INFO
if [ -n "$INSTALL_DIR" ]; then
VBOXMANAGE="$INSTALL_DIR/VBoxManage"
else
fi
if [ -n "$NOLSB" ]; then
if [ -f /etc/redhat-release ]; then
elif [ -f /etc/SuSE-release ]; then
elif [ -f /etc/gentoo-release ]; then
fi
fi
if [ -z "$NOLSB" ]; then
echo ""
log_failure_msg "$1"
}
log_success_msg " done."
}
log_daemon_msg "$@"
}
else
if [ "$system" = "redhat" ]; then
echo -n " "
echo
echo " ($1)"
}
echo -n " "
echo
}
elif [ "$system" = "suse" ]; then
rc_status -v
echo " ($1)"
}
rc_status -v
}
elif [ "$system" = "gentoo" ]; then
. /sbin/functions.sh
eerror "$1"
}
eend "$?"
}
ebegin "$1"
}
shift
fi
else
echo " ...failed!"
echo " ($1)"
}
echo " ...done."
}
fi
if [ "$system" != "gentoo" ]; then
[ -z "${1:-}" ] && return 1
if [ -z "${2:-}" ]; then
echo -n "$1"
else
echo -n "$1: $2"
fi
}
fi
fi
failure()
{
fail_msg "$1"
exit 0
}
running()
{
}
start()
{
begin_msg "Starting VirtualBox kernel module"
if ! running; then
failure "No suitable module for running kernel found"
fi
fi
fi
sleep .2
fi
# ensure the character special exists
if [ ! -c $DEVICE ]; then
MINOR=0
else
MAJOR=10
fi
fi
failure "Cannot locate the VirtualBox device"
fi
fi
fi
# ensure permissions
if ! chown :$GROUPNAME $DEVICE 2>/dev/null; then
failure "Cannot change owner $GROUPNAME for device $DEVICE"
fi
}
stop()
{
begin_msg "Stopping VirtualBox kernel module"
if running; then
fi
fi
fi
}
# enter the following variables in /etc/default/virtualbox:
# SHUTDOWN_USERS="foo bar"
# check for running VMs of user foo and user bar
# SHUTDOWN=poweroff
# SHUTDOWN=acpibutton
# SHUTDOWN=savestate
# select one of these shutdown methods for running VMs
stop_vms()
{
wait=0
for i in $SHUTDOWN_USERS; do
# don't create the ipcd directory with wrong permissions!
export VBOX_IPC_SOCKETID="$i"
VMS=`$VBOXMANAGE -nologo list runningvms 2>/dev/null`
begin_msg "Powering off remaining VMs"
done
begin_msg "Sending ACPI power button event to remaining VMs"
wait=30
done
begin_msg "Saving state of remaining VMs"
done
fi
fi
fi
done
# wait for some seconds when doing ACPI shutdown
fi
}
setup()
{
stop
begin_msg "Removing old VirtualBox kernel module"
fi
begin_msg "Recompiling VirtualBox kernel module"
if ! $BUILDINTMP install > $LOG 2>&1; then
fi
}
{
if running; then
echo "VirtualBox kernel module is loaded."
for i in $SHUTDOWN_USERS; do
# don't create the ipcd directory with wrong permissions!
export VBOX_IPC_SOCKETID="$i"
VMS=`$VBOXMANAGE -nologo list runningvms 2>/dev/null`
echo "The following VMs are currently running:"
echo " $v"
done
fi
fi
done
else
echo "VirtualBox kernel module is not loaded."
fi
}
case "$1" in
;;
stop)
stop
;;
;;
stop && start
;;
stop
;;
;;
;;
*)
echo "Usage: $0 {start|stop|stop_vms|restart|force-reload|status|setup}"
exit 1
esac
exit 0