summaryrefslogtreecommitdiff
blob: 69b0a46ef0fb36e0cc5c9f627dda70b30bc0c0bb (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
#!/sbin/runscript
# Copyright 1999-2008 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 time syncronization system service"
        start-stop-daemon --start --make-pidfile \
		--exec /usr/sbin/vboxadd-timesync --pidfile /var/run/vboxadd-timesync.pid \
		--name vboxadd-timesync \
		--background

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

stop() {
        ebegin "Stopping VirtualBox guest additions"

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

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