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

depend() {
	need localmount
	use logger net
	after samba
}

vmware_prettify() {
	# Yea, the code is ugly but the output is pretty
	state=$1
	waserror=0
	while read line
	do
		# Ignore blank lines		
		[ "${line}" = "" ] && continue

		# Determine what kind of line it is to provide einfo or ewarn etc
		case ${line} in
		*Starting\ *)
			einfo ${line};;
		*Stopping\ *)
			einfo ${line};;
		*VMware\ Virtual\ Infrastructure\ Web\ Access*)
			# Really nasty hack, because for some reason, vmware-server 2 doesn't say done when it mentions this
			einfon "  ${line}"
			echo
			eend 0;;
		*)
			# Strip out anything after the <esc> code
			message=`echo ${line} | sed -e "s/^\(.*\).*$/\1/"`
			einfon "  ${message}"
			echo

			echo ${line} | grep -q done
			status=$?
			eend ${status}

			if [ ${status} -ne 0 ]
			then
				logger -p local0.err -t vmware-${state} "${line}"
				waserror=${status}
			fi
		esac
		continue

	done
	if [ ${waserror} -ne 0 ]
	then
		eend 1 "VMware is not properly configured! See above."
	fi
	return ${waserror}
}

start() {
	test -x /etc/vmware/init.d/vmware || \
		eend 1 "vmware init script not found. Aborting" || return 1

	/etc/vmware/init.d/vmware start | vmware_prettify start
	return $?
}

stop() {
	/etc/vmware/init.d/vmware stop | vmware_prettify stop
	return $?
}