diff options
Diffstat (limited to 'os-plugins/plugins/vmware/files/vmware-init')
| -rwxr-xr-x | os-plugins/plugins/vmware/files/vmware-init | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/os-plugins/plugins/vmware/files/vmware-init b/os-plugins/plugins/vmware/files/vmware-init new file mode 100755 index 00000000..d41230ca --- /dev/null +++ b/os-plugins/plugins/vmware/files/vmware-init @@ -0,0 +1,115 @@ +#!/bin/sh +# +# parts taken from vmware start script: +# Copyright 1998-2007 VMware, Inc. All rights reserved. +# +# This script manages the services needed to run VMware software + +# Basic support for the Linux Standard Base Specification 1.3 +# Used by insserv and other LSB compliant tools. +### BEGIN INIT INFO +# Provides: VMware +# Required-Start: $network $syslog +# Required-Stop: +# Default-Start: 2 3 5 +# Default-Stop: 0 6 +# Short-Description: Manages the services needed to run VMware software +# Description: Manages the services needed to run VMware software +### END INIT INFO + +# prereqs: +# 1) a) this script b) the modules (vmmon, vmblock, vmnet) match the +# installed vmware/player version (ensured by stage1 install) +# 2) the script is tailored to the vendor-os we are running +# 3) the script checks a configuration file to know which modes to +# prepare +# 4) we use the dhcp-server for ALL internal interfaces we are running +# 5) stage3 produces a configfile /etc/vmware/slxvmconfig where the +# settings of networking etc. are made + +# read the configuration file generated in stage3 to configure the +# host internal interfaces +. /etc/vmware/slxvmconfig + + +load_modules() { + # to be filled in via the stage1 configuration script + modprobe -qa vmmon vmnet vmblock 2>/dev/null + # most probably nobody wants to run the parallel port driver ... + #modprobe vm... +} +unload_modules() { + # to be filled with the proper list within via the stage1 configuration + # script + rmmod vmmon vmblock vmnet 2>/dev/null +} +# the bridged interface +setup_vmnet0() { + if [ -n "$vmnet0" ] ; then + # the path might be directly point to the plugin dir + /usr/bin/vmnet-bridge -d /var/run/vmnet-bridge-0.pid /dev/vmnet0 eth0 + fi +} +# we definately prefer the hostonly interface for NATed operation too +# distinction is made via enabled forwarding +setup_vmnet1() { + if [ -n "$vmnet1" ] ; then + test -c /dev/vmnet1 || mknod c 119 1 /dev/vmnet1 + # the path might be directly point to the plugin dir + /usr/bin/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \ + /dev/vmnet1 vmnet1 + dhcpif="$dhcpif vmnet1" + ip addr add $vmnet1 dev vmnet1 + if [ -n "$vmnet1nat" ] ; then + # needs refinement interface name for eth0 is known in stage3 already + echo "1" > /proc/sys/net/ipv4/conf/vmnet1/forwarding 2>/dev/null + echo "1" > /proc/sys/net/ipv4/conf/eth0/forwarding 2>/dev/null + #iptables -A -s vmnet1 -d eth0 + fi + fi +} +# incomplete ... +setup_vmnet8() { + if [ -n "$vmnet8" ] ; then + test -c /dev/vmnet1 || mknod c 119 8 /dev/vmnet8 + # /etc/vmware/vmnet-natd-8.mac simply contains a mac like 00:50:56:F1:30:50 + /usr/bin/vmnet-natd -d /var/run/vmnet-natd-8.pid \ + -m /etc/vmware/vmnet-natd-8.mac -c /etc/vmware/nat.conf + dhcpif="$dhcpif vmnet8" + ip addr add $vmnet8 dev vmnet8 + fi +} +runvmdhcpd() { + if [ -n "$dhcpif" ] ; then + # the path might be directly point to the plugin dir + mkdir /var/run/vmware 2>/dev/null + /usr/bin/vmnet-dhcpd -cf /etc/vmware/dhcpd.conf -lf \ + /var/run/vmware/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet8.pid $dhcpif + fi +} + +case $1 in + start) + # message output should match the given vendor-os + echo "Starting vmware background services ..." + load_modules + setup_vmnet0 + setup_vmnet1 + setup_vmnet8 + runvmdhcpd + ;; + stop) + # message output should match the given vendor-os + echo "Stopping vmware background services ..." + killall vmnet-netifup vmnet-natd vmnet-bridge vmware vmplayer \ + vmware-tray 2>/dev/null + # wait for shutting down of interfaces + usleep 50000 + unload_modules + ;; + status) + echo "Say something useful here ..." + ;; +esac + +exit 0 |
