diff options
| author | root | 2013-06-03 17:34:24 +0200 |
|---|---|---|
| committer | root | 2013-06-03 17:34:24 +0200 |
| commit | 79938062f218767d03b713db88cdca41543f5924 (patch) | |
| tree | 89d5e2f288d7736401b34f8ccd57c6acb6d4257e /remote/modules/vmplayer/data/etc/openslx/vmware | |
| parent | [kernel] Fix aufs3 patching (diff) | |
| parent | Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts (diff) | |
| download | tm-scripts-79938062f218767d03b713db88cdca41543f5924.tar.gz tm-scripts-79938062f218767d03b713db88cdca41543f5924.tar.xz tm-scripts-79938062f218767d03b713db88cdca41543f5924.zip | |
Merge branch 'master' of simonslx:openslx-ng/tm-scripts
Diffstat (limited to 'remote/modules/vmplayer/data/etc/openslx/vmware')
3 files changed, 204 insertions, 77 deletions
diff --git a/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include b/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include index 012ad82a..837513d2 100644 --- a/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include +++ b/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include @@ -158,15 +158,13 @@ floppy0.startConnected = \"FALSE\" floppy0.autodetect = \"TRUE\" floppy0.fileName = \"auto detect\" # we need floppy b: for our windows client configuration -#TODO: enable floppy1 floppy1.present = \"${floppy1}\" -floppy1.startConnected = \"FALSE\" +floppy1.startConnected = \"TRUE\" floppy1.fileType = \"file\" floppy1.fileName = \"${floppy1name}\" # nics -#TODO: enable eth0 -ethernet0.present = \"FALSE\" +ethernet0.present = \"TRUE\" ethernet0.addressType = \"static\" ${network_virtualDev} ethernet0.connectionType = \"${network_kind}\" @@ -386,43 +384,6 @@ case "$parallel" in ;; esac -# adjust memory available for vmware guests -#if [ -n "${forcemem}" ]; then -# mem="${forcemem}" -#else -# case "$vmversion" in -# 2.*|6.*) -# permem=30 -# ;; -# 3.*|7.*) -# permem=25 -# ;; -# esac -# if [ "${totalmem}" -ge "2500" ]; then -# permem=40 -# fi -# # check if /tmp is on harddisk -# if grep -qe "/dev/.* /tmp " /proc/mounts ; then -# permem=60 -# id44="1" -# # Hack, if more than 2,5G RAM use 40% of Ram and write vmem into Ram as well -# # (40% vmware | 40% confdir(vmem...) | 20% host -# # VMplayer 2+ issue -# if [ "${totalmem}" -ge "2500" ]; then -# permem=40 -# confdir=/dev/shm/vmware/$USER -# conffile=${confdir}/run-vmware.conf -# mkdir -p /dev/shm/vmware/$USER -# fi -# fi -# mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) -# if [ "${id44}" = "1" ]; then -# hostmem=$(expr ${totalmem} - ${mem}) -# else -# hostmem=$(expr ${totalmem} - ${mem} - ${mem}) -# fi -#fi - # check if ide/scsi and hwver of image # read only the first 30 lines to be shure imghead=$(head -n 30 ${diskfile}) diff --git a/remote/modules/vmplayer/data/etc/openslx/vmware/vmware-env b/remote/modules/vmplayer/data/etc/openslx/vmware/vmware-env index b829e9b6..6200c981 100755 --- a/remote/modules/vmplayer/data/etc/openslx/vmware/vmware-env +++ b/remote/modules/vmplayer/data/etc/openslx/vmware/vmware-env @@ -9,35 +9,202 @@ # # 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 +VMWARE_CONF_DIR=/etc/openslx/vmware + +#source config file +. /opt/openslx/config +. ${VMWARE_CONF_DIR}/vmware.conf + +setup_bridge() { + # Init hook to create a bridge on the active network interface + # (should be kept identical to the files of virtualbox and qemukvm plugins) + ############################################################################# + + local bridge=br0 + local brnwif=eth0 + local nwifmac=${SLX_PXE_MAC} + + # bridge 0 already defined or some other problem + brctl addbr ${bridge} + brctl stp ${bridge} 0 + brctl setfd ${bridge} 0.000000000001 + ip link set addr ${nwifmac} ${bridge} + ip link set dev ${nwif} up + brctl addif ${bridge} ${nwif} +} + +vm_dhcpd() { + + #from plugins/vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh + + # read the DNS configuration and if available set WPAD configuration + [ -z "${SLX_DNS}" ] && SLX_DNS="8.8.8.8" + [ -n "${wpad}" ] && wpad_config="option wpad ${wpad}" + + # configuring dhcpd stub for virtual networks + cat > ${VMWARE_CONF_DIR}/udhcpd.conf << EOF +# general udhcpd configuration file for virtual machines written by $0 + +# start and end of the IP lease block +start CNETWORK.20 +end CNETWORK.100 + +# interface that udhcpd will use +interface NWIF + +# how long an offered address is reserved (leased) in seconds +offer_time 6000 + +# location of the leases file +lease_file LEASEFILE + +# location of the pid file +pidfile PIDFILE + +option dns ${SLX_DNS} +option subnet 255.255.255.0 +option router CNETWORK.1 +option wins CNETWORK.10 +option domain virtual.site ${domain_name} +${wpad_config} + +# additional options known to udhcpd +#subnet #timezone +#router #timesvr +#namesvr #dns +#logsvr #cookiesvr +#lprsvr #bootsize +#domain #swapsvr +#rootpath #ipttl +#mtu #broadcast +#wins #lease +#ntpsrv #tftp +#bootfile #wpad +EOF + +} + +setup_network() { + #from plugins/vmware/XX_vmware.sh + + mkdir -p /tmp/virt/vmware -m 1777 + mkdir -p /dev/shm/vmware -m 1777 + mkdir -p /var/run/vmware -m 1777 + mkdir -p /etc/vmware/udhcpd + + # variable might contain ",NAT" which is to be taken off + if [ -n "$vmnet1" ] ; then + local vmip=${vmnet1%/*} # x.x.x.x/yy => 'x.x.x.x'"> + local vmsub=$(echo $vmip |sed 's,\(.*\)\..*,\1,') # x.x.x.x => x.x.x + # setting up the udhcpd configuration + sed -e "s,NWIF,vmnet1,;s,/misc/,/vmware/," \ + -e "s,CNETWORK,$vmsub,;s,PIDFILE,/var/run/vmware/udhcpd-vmnet1.pid," \ + -e "s,LEASEFILE,/var/run/vmware/udhcpd-vmnet1.leases," \ + ${VMWARE_CONF_DIR}/udhcpd.conf >/etc/vmware/udhcpd/udhcpd-vmnet1.conf + # setting the base samba configuration if available + if [ -f /etc/openslx/vmchooser/smb.conf \ + -a -f /usr/sbin/smbd ] ; then + sed -e "s#NWIF#vmnet1,vmnet8#;s,PIDDIR,/var/run/vmware," \ + ${VMCHOOSER_CONF_DIR}/smb.conf \ + >/etc/vmware/smb.conf + fi + fi + + # vmware nat interface configuration + if [ -n "$vmnet8" ] ; then + local vmnet8ip=${vmnet8%/*} + local vmpx=${vmnet8#*/} + local vmsub=$(echo $vmnet8ip |sed 's,\(.*\)\..*,\1,') # x.x.x.x => x.x.x"> + # vmip is user for vmnet8 device + # vmnet is user for config files nat.conf/dhcp + local vmip="${vmsub}.1" + local vmnet="${vmsub}.2" + # setting up the udhcpd configuration + sed -e "s,NWIF,vmnet8,;s,/misc/,/vmware/," \ + -e "s,CNETWORK,$vmsub,;s,PIDFILE,/var/run/vmware/udhcpd-vmnet8.pid," \ + -e "s,LEASEFILE,/var/run/vmware/udhcpd-vmnet8.leases," \ + ${VMWARE_CONF_DIR}/udhcpd.conf >/etc/vmware/udhcpd/udhcpd-vmnet8.conf + # might be not needed any more ... + echo -e "# Linux NAT configuration file" \ + > /etc/vmware/nat.conf + echo -e "[host]" \ + >> /etc/vmware/nat.conf + echo -e "ip = $vmnet/$vmpx" \ + >> /etc/vmware/nat.conf + echo -e "device = /dev/vmnet8" \ + >> /etc/vmware/nat.conf + echo -e "activeFTP = 1" \ + >> /etc/vmware/nat.conf + echo -e "[udp]" \ + >> /etc/vmware/nat.conf + echo -e "timeout = 60" \ + >> /etc/vmware/nat.conf + echo -e "[incomingtcp]" \ + >> /etc/vmware/nat.conf + echo -e "[incomingudp]" \ + >> /etc/vmware/nat.conf + echo "00:50:56:F1:30:50" > /etc/vmware/vmnet-natd-8.mac + fi + + ############################################################################ + # vmware stuff second part: setting up the environment + # make udhcpd more silent + touch /var/run/vmware/udhcpd-vmnet1.leases \ + /var/run/vmware/udhcpd-vmnet8.leases + + # create the needed devices which effects all vmware options + # they are not created automatically via module load + for i in "/dev/vmnet0 c 119 0" "/dev/vmnet1 c 119 1" \ + "/dev/vmnet8 c 119 8" "/dev/vmmon c 10 165"; do + mknod $i + done + + chmod 0700 /dev/vmnet* +} + +adapt_tmpfs() { + # from plugins/vmware/init-hooks/80-after-plugins/adapt-tmpfs.sh + # Init hook to adapt the tmpfs size for VMware/Player + # (should be kept identical to the files of virtualbox plugin) + ############################################################################# + + # adapt tmpfs size (overbook) + case $(grep tmpfs /proc/mounts) in + */tmp*) + mount -o remount,size=175% /tmp + ;; + */uniontmp*) + mount -o remount,size=175% /uniontmp + ;; + esac +} + +#from /etc/init.d/vmware-env + #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 + # 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 - + # VMplayer common stuff + insmod /lib/modules/vmware/vmmon.ko + insmod /lib/modules/vmware/vmnet.ko + # 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 + rmmod vmnet vmmonvsock vmci vmblock } vmnetif () { @@ -53,7 +220,7 @@ if [ -n "$vmnet1" ] ; then 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/vmnet1/forwarding echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding 2>/dev/null fi /opt/openslx/usr/sbin/udhcpd \ @@ -64,13 +231,13 @@ if [ -n "$vmnet8" ] ; then /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/vmnet8/forwarding 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 + # 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 + -m /etc/vmware/vmnet-natd-8.mac -c /etc/vmware/nat.conf # or logfile /opt/openslx/usr/sbin/udhcpd \ -S /etc/vmware/udhcpd/udhcpd-vmnet8.conf fi @@ -80,28 +247,28 @@ 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 - # load the configuration file - . /etc/openslx/vmware/vmware.conf + vm_dhcpd + setup_network +# adapt_tmpfs # hack to access the first serial/parallel port chmod a+rw /dev/ttyS0 chmod a+rw /dev/parport0 tempdir load_modules vmnetif - # vmblock - + vmblock ;; stop) #stop: defines stop function for initscript killall vmnet-netifup vmnet-natd vmnet-bridge vmware vmplayer \ - vmware-tray vmnet-dhcpd 2>/dev/null + vmware-tray vmnet-dhcpd # might take a while until all services are shut down sleep 1 umount -l /tmp/vmware 2>/dev/null @@ -124,4 +291,3 @@ case "$1" in ;; esac -exit 0 diff --git a/remote/modules/vmplayer/data/etc/openslx/vmware/vmware.conf b/remote/modules/vmplayer/data/etc/openslx/vmware/vmware.conf index 5a52ca41..210b814f 100644 --- a/remote/modules/vmplayer/data/etc/openslx/vmware/vmware.conf +++ b/remote/modules/vmplayer/data/etc/openslx/vmware/vmware.conf @@ -1,8 +1,8 @@ -# configuration file for vmware background services written in stage3 setup -#vmnet0=true -#vmnet1=192.168.101.1/24 -#vmnet1nat=true -#vmnet8=192.168.102.1/24 -# stage1 variables produced during plugin install +#configuration file for vmware background services written in stage3 setup +vmnet0=true +vmnet1=192.168.101.1/24 +vmnet1nat=true +vmnet8=192.168.102.1/24 +#stage1 variables produced during plugin install version="5.0" buildversion="1031769" |
