summaryrefslogtreecommitdiff
blob: 7d3d4865a89f7185a093fe34e90df46aca0a57d9 (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
#!/sbin/runscript
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header:

depend() {
        need localmount
	before xdm
}

createvboxdevice() {
		local maj min

		maj=`sed -n 's;\([0-9]\+\) vboxadd;\1;p' /proc/devices`

		if ! [[ -z $maj ]] ; then
			min=0
		else
			min=`sed -n 's;\([0-9]\+\) vboxadd;\1;p' /proc/misc`
			if ! [[ -z $min ]] ; then
				maj=10
			fi
		fi

		mknod /dev/vboxadd c $maj $min -m 0664 &> /dev/null
}

start() {
	ebegin "Starting VirtualBox guest additions"

	if [[ -e /dev/vboxadd ]] ; then
		rm -f /dev/vboxadd &> /dev/null
	fi

	einfo "	Loading kernel modules and creating devices"
	/sbin/modprobe vboxadd &> /dev/null
	createvboxdevice
	/sbin/modprobe vboxvfs &> /dev/null

	einfo "	Starting the vboxadd system service"
        start-stop-daemon --start --make-pidfile \
		--exec /usr/sbin/vboxadd-service --pidfile /var/run/vboxadd-service.pid \
		--name vboxadd-service \
		--background -- \
		--foreground

        eend $? "Failed to start VirtualBox guest additions"
}

stop() {
        ebegin "Stopping VirtualBox guest additions"

	einfo "	Stopping the vboxadd system service"
	start-stop-daemon --stop --quiet \
		--pidfile /var/run/vboxadd-service.pid --name vboxadd-service

	einfo " Unloading kernel modules and removing devices"
	/sbin/rmmod vboxvfs &> /dev/null
	/sbin/rmmod vboxadd &> /dev/null
	rm -f /dev/vboxadd &> /dev/null
        eend $?
}