#!/bin/sh # Copyright (c) 2009 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING # # If you have any feedback please consult http://openslx.org/feedback and # send your suggestions, praise, or complaints to feedback@openslx.org # # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # §filename§ # - §desc§ # §generated§ # ----------------------------------------------------------------------------- ### BEGIN INIT INFO # Provides: vmware-slx # Required-Start: $remote_fs # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 1 # Short-Description: Setup environment for VMware Workstation or Player (local3X). ### END INIT INFO . /lib/lsb/init-functions #functions: helper functions load_modules () { # VMplayer common stuff insmod /lib/modules/$(uname -r)/misc/vmmon.ko || return 1 insmod /lib/modules/$(uname -r)/misc/vmnet.ko || return 1 # VMplayer 3.X specific stuff insmod /lib/modules/$(uname -r)/misc/vmci.ko insmod /lib/modules/$(uname -r)/misc/vmblock.ko insmod /lib/modules/$(uname -r)/misc/vsock.ko } unload_modules () { rmmod vmnet vmmonvsock vmci vmblock 2>/dev/null } vmnetif () { # let point the path directly to the directory where the binary lives location="/usr/bin" if [ -n "$vmnet0" ] ; then # the path might be directly point to the plugin dir $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid -n 0 fi if [ -n "$vmnet1" ] ; then $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \ /dev/vmnet1 vmnet1 ip addr add $vmnet1 dev vmnet1 ip link set vmnet1 up if [ -n "$vmnet1nat" ] ; then echo "1" >/proc/sys/net/ipv4/conf/vmnet1/forwarding 2>/dev/null echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding 2>/dev/null #iptables -A -s vmnet1 -d br0 fi /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \ -S /etc/vmware/udhcpd/udhcpd-vmnet1.conf fi if [ -n "$vmnet8" ] ; then $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet8.pid \ /dev/vmnet8 vmnet8 ip addr add $vmnet8 dev vmnet8 ip link set vmnet8 up echo "1" >/proc/sys/net/ipv4/conf/vmnet8/forwarding 2>/dev/null echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding 2>/dev/null iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \ -S /etc/vmware/udhcpd/udhcpd-vmnet8.conf fi } vmblock () { # let point the path directly to the directory where the binary lives /usr/bin/vmware-usbarbitrator } case "$1" in start) #start: defines start function for initscript # include default directories . /etc/opt/openslx/openslx.conf # load the configuration file . ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmware/vmware.conf # hack to access the first serial/parallel port chmod a+rw /dev/ttyS0 chmod a+rw /dev/parport0 load_modules vmnetif vmblock ;; stop) #stop: defines stop function for initscript killall vmnet-netifup vmnet-natd vmnet-bridge vmware vmplayer \ vmware-tray vmnet-dhcpd 2>/dev/null # might take a while until all services are shut down sleep 1 unload_modules ;; restart) #restart: defines restart function for initscript $0 stop && $0 start ;; status) #status: defines status function for initscript vmstatus ;; *) #usage: defines usage function for initscript ## print out usage echo "Usage: $0 {start, stop, restart, status}" >&2 exit 1 ;; esac exit 0