aboutsummaryrefslogtreecommitdiffstats
path: root/main/open-vm-tools/open-vm-tools.initd
blob: fab4d22a392842fd6c193a9010178d952837bcac (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
#!/sbin/openrc-run
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# Note: $VM_DRAG_AND_DROP is here for backward compatibility.
: ${vm_drag_and_drop:="${VM_DRAG_AND_DROP:-}"}

command="/usr/bin/vmtoolsd"
command_background="yes"
pidfile="/run/vmtoolsd.pid"
# To not complain about missing messages...
start_stop_daemon_args="--env LANG=en_US.UTF-8"

vmblockmntpt="/proc/fs/vmblock/mountPoint"
vmblockfusemntpt="/run/vmblock-fuse"

depend() {
	before net X
}

start_vmblock() {
	checkpath -d -m 1777 /tmp/VMwareDnD

	if command -v vmware-vmblock-fuse > /dev/null; then
		modprobe fuse > /dev/null 2>&1
		checkpath -d "$vmblockfusemntpt"

		ebegin "Mounting vmblock-fuse"
		vmware-vmblock-fuse \
			-o subtype=vmware-vmblock,default_permissions,allow_other \
			"$vmblockfusemntpt"
		eend $?
	else
		modprobe vmblock > /dev/null 2>&1
		checkpath -d "$vmblockmntpt"

		ebegin "Mounting vmblock"
		mount -t vmblock vmblock "$vmblockmntpt"
		eend $?
	fi
}

stop_vmblock() {
	if [ -d "$vmblockfusemntpt" ]; then
		ebegin "Unmounting vmblock-fuse"
		umount "$vmblockfusemntpt"
		eend $?
	else
		ebegin "Unmounting vmblock"
		umount "$vmblockmntpt"
		eend $?
	fi
}

start_pre() {
	if [ "$vm_drag_and_drop" = yes ]; then
		start_vmblock
	fi
	return 0
}

stop_post() {
	if [ "$vm_drag_and_drop" = yes ]; then
		stop_vmblock
	fi
	return 0
}