diff options
Diffstat (limited to 'remote/modules/vmware/data/opt')
| -rwxr-xr-x | remote/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env | 227 | ||||
| -rw-r--r-- | remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include | 39 |
2 files changed, 59 insertions, 207 deletions
diff --git a/remote/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env b/remote/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env index dc60e3d5..d80b28a6 100755 --- a/remote/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env +++ b/remote/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env @@ -1,5 +1,6 @@ -#!/opt/openslx/bin/ash -# Copyright (c) 2009 - OpenSLX GmbH +#!/bin/ash +# ----------------------------------------------------------------------------- +# Copyright (c) 2013 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -9,154 +10,19 @@ # # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- +# systemd-vmware_env +# - This is the systemd configuration and provisioning script for the various +# VMware modules and services +################################################################################ VMWARE_CONF_DIR=/opt/openslx/vmchooser/vmware VMCHOOSER_CONF_DIR=/opt/openslx/vmchooser/config -for wait in 1 1 2 2 3 end; do - grep '^SLX_DNS' "/opt/openslx/config" > /dev/null && break - [ "$wait" == "end" ] && echo "No DNS config found, using google dns" && break - echo "Waiting for DNS config.." - sleep "$wait" -done - -#source config file -. "/opt/openslx/config" -. "${VMWARE_CONF_DIR}/vmware.conf" || slxlog "vmware-conf" "Could not source '${VMWARE_CONF_DIR}/vmware.conf' in $0" "${VMWARE_CONF_DIR}/vmware.conf" - -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 ${SLX_NET_DOMAIN} virtual.site -${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 "$VMCHOOSER_CONF_DIR/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 "# Linux NAT configuration file" \ - > /etc/vmware/nat.conf - echo "[host]" \ - >> /etc/vmware/nat.conf - echo "ip = $vmnet/$vmpx" \ - >> /etc/vmware/nat.conf - echo "device = /dev/vmnet8" \ - >> /etc/vmware/nat.conf - echo "activeFTP = 1" \ - >> /etc/vmware/nat.conf - echo "[udp]" \ - >> /etc/vmware/nat.conf - echo "timeout = 60" \ - >> /etc/vmware/nat.conf - echo "[incomingtcp]" \ - >> /etc/vmware/nat.conf - echo "[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 # no "" - done - - chmod 0700 /dev/vmnet* -} - load_modules () { local FAILED="" - # VMplayer common stuff + # module stuff insmod /lib/modules/vmware/vmmon.ko || FAILED="$FAILED vmmon" insmod /lib/modules/vmware/vmnet.ko || FAILED="$FAILED vmnet" - # VMplayer 3.X specific stuff insmod /lib/modules/vmware/vmci.ko || FAILED="$FAILED vmci" insmod /lib/modules/vmware/vmblock.ko || FAILED="$FAILED vmblock" insmod /lib/modules/vmware/vsock.ko || FAILED="$FAILED vsock" @@ -168,41 +34,30 @@ unload_modules () { } 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 - if ! $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid -n 0; then - slxlog "vmware-bridge" "Launching $location/vmnet-bridge failed." - fi + # create the needed devices which effects all vmware options + # they are not created automatically via module load + for device in "/dev/vmnet0 c 119 0" "/dev/vmnet1 c 119 1" \ + "/dev/vmnet2 c 119 2" "/dev/vmmon c 10 165"; do + mknod ${device} + done + chmod 0700 /dev/vmnet* + + # setup bridge (vmnet0), nat (vmnet1) and software defined networking (vmnet2) interfaces + if ! /usr/bin/vmnet-netifup -d /var/run/vmnet-netifup-vmnet0.pid /dev/vmnet0 vmnet0 ; then + slxlog "vmware-netifup" "Launching /usr/bin/vmnet-netifup for vmnet0 failed." fi - if [ -n "$vmnet1" ] ; then - if ! $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid /dev/vmnet1 vmnet1; then - slxlog "vmware-netifup" "Launching $location/vmnet-netifup for vmnet1 failed." - fi - ip addr add $vmnet1 dev vmnet1 - ip link set vmnet1 up - if [ -n "$vmnet1nat" ] ; then - 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 -S /etc/vmware/udhcpd/udhcpd-vmnet1.conf + ip link set dev vmnet0 up + brctl addif br0 vmnet0 + if ! /usr/bin/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid /dev/vmnet1 vmnet1; then + slxlog "vmware-netifup" "Launching /usr/bin/vmnet-netifup for vmnet1 failed." fi - if [ -n "$vmnet8" ] ; then - if ! $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet8.pid /dev/vmnet8 vmnet8; then - slxlog "vmware-netifup" "Launching $location/vmnet-netifup for vmnet8 failed." - fi - ip addr add $vmnet8 dev vmnet8 - ip link set vmnet8 up - echo "1" >/proc/sys/net/ipv4/conf/vmnet8/forwarding - echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding 2>/dev/null - 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 - if ! $location/vmnet-natd -d /var/run/vmnet-natd-8.pid -m /etc/vmware/vmnet-natd-8.mac -c /etc/vmware/nat.conf; then - slxlog "vmware-natd" "Launching $location/vmnet-natd for vmnet8 failed." - fi - /opt/openslx/usr/sbin/udhcpd -S /etc/vmware/udhcpd/udhcpd-vmnet8.conf + ip link set dev vmnet1 up + brctl addif nat1 vmnet1 + if ! /usr/bin/vmnet-netifup -d /var/run/vmnet-netifup-vmnet2.pid /dev/vmnet2 vmnet2; then + slxlog "vmware-netifup" "Launching /usr/bin/vmnet-netifup for vmnet2 failed." fi + ip link set dev vmnet2 up + brctl addif vsw2 vmnet2 } vmblock () { @@ -211,28 +66,24 @@ vmblock () { fi } +# create required standard directories +mkdir -p "/tmp/virt/vmware" "/dev/shm/vmware" "/run/vmware" -m 1777 - +# FixMe: Should be rewritten for proper systemd operation case "$1" in start) - #start: defines start function for initscript - vm_dhcpd - setup_network # hack to access the first serial/parallel port - chmod a+rw /dev/ttyS0 - chmod a+rw /dev/parport0 - mkdir -m 1777 -p /tmp/vmware + [ -c /dev/ttyS0 ] && chmod a+rw /dev/ttyS0 + [ -c /dev/parport0 ] && 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 + killall vmnet-netifup vmnet-bridge vmware vmplayer vmware-tray # might take a while until all services are shut down - sleep 1 - umount -l /tmp/vmware 2>/dev/null + sleep 0.5 unload_modules ;; @@ -244,11 +95,5 @@ case "$1" in #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 diff --git a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include index a4e03b7f..3f24e9d5 100644 --- a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include +++ b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include @@ -1,4 +1,3 @@ -# run-virt.include # ----------------------------------------------------------------------------- # Copyright (c) 2009..2012 - RZ Uni Freiburg # Copyright (c) 2009..2013 - OpenSLX GmbH @@ -12,10 +11,11 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # run-virt.include -# - component for vmware/player of the vmchooser plugin run-virt.sh +# - component for vmware/player of the vmchooser plugin vmchooser-run_virt ################################################################################ -# configuration writer functions +################################################################################ +### configuration writer functions ################################################################################ function clean_string () @@ -258,9 +258,9 @@ floppy1.fileName = "$floppy1name" ethernet0.present = "TRUE" ethernet0.addressType = "static" $network_virtualDev -ethernet0.connectionType = "$network_kind" +ethernet0.connectionType = "hostonly" #ethernet1.connectionType = "custom" -#ethernet1.vnet = "/dev/vmnet2" +ethernet0.vnet = "$hostdev" ethernet0.address = "00:50:56:$macaddrsuffix" ethernet0.wakeOnPcktRcv = "FALSE" @@ -396,7 +396,6 @@ HEREEND # declaration of default variables ################################################################################ - [ "$mem" -gt 3800 -a "$(uname -m)" != "x86_64" ] && mem=3800 # VM-ID static (0D), remove if changed to 00 @@ -409,9 +408,9 @@ else VM_ID=$[ $$ % 100 ] fi # temporary disk space for logs, etc... -redodir=/tmp/vmware/${USER}.$$ +redodir=/tmp/virt/vmware/${USER}.$$ # dir for configs and vmem file -confdir=/tmp/vmware/${USER}.$$ +confdir=/tmp/virt/vmware/${USER}.$$ # configfile conffile="${confdir}/run-vmware.conf" # diskfile @@ -439,6 +438,20 @@ else network_virtualDev='# using default virtualDev for ethernet0' fi +# use different network card (default e1000, vlance, vmxnet) +hostdev="/dev/vmnet1" +case "${network_kind}" in + bridge) + hostdev="/dev/vmnet0" + ;; + nat) + hostdev="/dev/vmnet1" + ;; + hostonly|host-only) + hostdev="/dev/vmnet2" + ;; +esac + # set standard sound card, overwrite depending on OS (options sb16, es1371, hdaudio) sound="es1371" @@ -617,15 +630,9 @@ fi writelog "" -# finally set env for run-virt.sh ################################################################################ - -# configure and start samba service to provide user's home directory -#if [ -f /usr/sbin/smbd ] ; then -# sudo /opt/openslx/bin/sed -i /etc/vmware/smb.conf -e "s,USER,$USER," -# sudo /usr/sbin/nmbd -s /etc/vmware/smb.conf -# sudo /usr/sbin/smbd -s /etc/vmware/smb.conf -#fi +### Set env for vmchooser-run_virt +################################################################################ # For debugging cp "$conffile" "/tmp/vmware-last-config" |
