#!/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§ # ----------------------------------------------------------------------------- export PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin:/opt/openslx/usr/bin:/opt/openslx/usr/sbin #functions: helper functions tempdir () { # Create a special tempfs directory mkdir -m 1777 -p /tmp/vmware # Don't mount special tempfs, when using local harddrive for /tmp [ ! -n "$(cat /proc/mounts |grep ' /tmp '|grep '/dev/sd')" ] \ && mount -t tmpfs -o size=180%,mode=1777 tmpfs /tmp/vmware } load_modules () { # VMplayer common stuff insmod /lib/modules/vmware/vmmon.ko || return 1 insmod /lib/modules/vmware/vmnet.ko || return 1 # VMplayer 3.X specific stuff insmod /lib/modules/vmware/vmci.ko insmod /lib/modules/vmware/vmblock.ko insmod /lib/modules/vmware/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 fi /opt/openslx/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 # TODO: iptables in stage32? # iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE # /etc/vmware/vmnet-natd-8.mac simply contains a mac like 00:50:56:F1:30:50 $location/vmnet-natd -d /var/run/vmnet-natd-8.pid \ -m /etc/vmware/vmnet-natd-8.mac -c /etc/vmware/nat.conf 2>/dev/null # or logfile /opt/openslx/usr/sbin/udhcpd \ -S /etc/vmware/udhcpd/udhcpd-vmnet8.conf fi } vmblock () { # let point the path directly to the directory where the binary lives # TODO: get it to work /usr/bin/vmware-usbarbitrator } case "$1" in start) #start: defines start function for initscript # load the configuration file . /etc/openslx/vmware/vmware.conf # hack to access the first serial/parallel port chmod a+rw /dev/ttyS0 chmod a+rw /dev/parport0 tempdir 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 umount -l /tmp/vmware 2>/dev/null 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