summaryrefslogtreecommitdiffstats
path: root/resources/config/1/uniontmp/etc/rc3.d/K02vmware-env
blob: ddc4f5ca307e86f386a3955d38ee2dc3e1d810e1 (plain) (blame)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/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