summaryrefslogtreecommitdiff
path: root/debian/virtualbox-guest-x11.init
blob: 8ce6d4409b534edefa7dcbbf3db60028c6e303a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
# (C) 2012 Felix Geyer <fgeyer@debian@org>

### BEGIN INIT INFO
# Provides:          virtualbox-guest-x11
# Short-Description: VirtualBox Linux X11 Additions
# Required-Start:    $remote_fs
# Required-Stop:
# Default-Start:     S
# Default-Stop:
### END INIT INFO

PATH=$PATH:/bin:/sbin:/usr/sbin

. /lib/lsb/init-functions

test -e /usr/lib/VBoxOGL.so || exit 0

in_virtual_machine()
{
	if [ -z "$(lspci -d 80ee:beef)" ]; then
		log_warning_msg "VirtualBox Additions disabled, not in a Virtual Machine"
		return 1
	fi

	return 0
}

running()
{
    lsmod | grep -q "$1[^_-]"
}

case "$1" in
  start)
	in_virtual_machine || exit 0
	log_begin_msg "Loading VirtualBox video kernel module"

	if ! running vboxvideo; then
		if ! modprobe vboxvideo > /dev/null 2>&1; then
			if ! find /lib/modules/`uname -r` -name "vboxvideo\.*" 2>/dev/null|grep -q vboxvideo; then
				log_failure_msg "No suitable module for running kernel found"
			else
				log_failure_msg "modprobe vboxvideo failed. Please use 'dmesg' to find out why"
			fi
			log_end_msg 1
			exit 1
		fi
	fi

	log_end_msg 0
	;;

  stop)
	;;

  restart|force-reload)
	$0 start
	;;

  *)
	echo "Usage: $0 {start|stop|restart|force-reload}"
	exit 1
	;;
esac

exit 0