15
15
. /lib/lsb/init-functions
17
test -d /usr/share/doc/virtualbox-ose-guest-utils -a -x /usr/sbin/VBoxService || exit 0
17
19
in_virtual_machine()
19
21
if [ -z "$(lspci -d 80ee:beef)" ]; then
20
log_warning_msg 'VirtualBox Additions Disabled, not in a Virtual Machine';
22
log_warning_msg "VirtualBox Additions disabled, not in a Virtual Machine"
31
lsmod | grep -q "$1[^_-]"
29
in_virtual_machine || exit 0
30
log_action_begin_msg 'Starting VirtualBox Additions';
32
# udev should have already handled this module
33
modprobe --quiet vboxadd
34
if [ "$?" -ne 0 ]; then
35
# vboxadd not installed, or has a problem
36
log_action_msg 'no guest utils available, kernel module not loadable';
41
# this one is not handled by udev
42
modprobe --quiet vboxvfs
43
if [ "$?" -ne 0 ]; then
44
# vboxvfs not installed, or has a problem
45
log_action_msg 'shared folders not available, kernel module not loadable';
36
in_virtual_machine || exit 0
37
log_begin_msg "Starting VirtualBox Additions"
39
# should already be loaded automatically
40
if ! running vboxadd; then
41
if ! modprobe vboxadd > /dev/null 2>&1; then
42
# vboxadd not installed, or has a problem
43
log_failure_msg "Guest additions not available, kernel module not loadable (vboxadd)"
49
if ! running vboxvfs; then
50
if ! modprobe vboxvfs > /dev/null 2>&1; then
51
# vboxvfs not installed, or has a problem
52
log_failure_msg "Shared folders not available, kernel module not loadable (vboxvfs)"
49
58
# Mount all shared folders from /etc/fstab. Normally this is done by some
50
# other startup script but this requires the vboxdrv kernel module loaded.
59
# other startup script but this requires the vboxvfs kernel module loaded.
53
start-stop-daemon --start --quiet --exec /usr/sbin/VBoxService
62
start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/VBoxService
57
in_virtual_machine || exit 0
58
log_action_begin_msg 'Stopping VirtualBox Additions';
72
in_virtual_machine || exit 0
73
log_begin_msg "Stopping VirtualBox Additions"
59
75
start-stop-daemon --stop --quiet --oknodo --exec /usr/sbin/VBoxService
83
if running vboxvfs; then
84
if ! rmmod vboxvfs 2>/dev/null; then
85
log_failure_msg "Cannot unload shared folders kernel module (vboxvfs)"
91
if running vboxadd; then
92
if ! rmmod vboxadd 2>/dev/null; then
93
log_failure_msg "Cannot unload guest additions kernel module (vboxadd)"
62
102
restart|force-reload)
64
# If the "reload" option is implemented, move the "force-reload"
65
# option to the "reload" entry. If not, "force-reload" is
66
# just the same as "restart".
109
if ! running vboxadd; then
110
echo "Guest additions kernel module (vboxadd) not loaded"
114
if ! running vboxvfs; then
115
echo "Shared folders kernel module (vboxvfs) not loaded"
119
if ! pgrep -x VBoxService > /dev/null; then
120
echo "VBoxService daemon isn't running"
72
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
128
echo "Usage: $0 {start|stop|restart|force-reload|status}"