From 73ad67ba1f7fd64900bf7364eb89d9b08382fbf9 Mon Sep 17 00:00:00 2001 From: Christian Rößler Date: Tue, 10 Sep 2013 14:55:17 +0200 Subject: [vbox] Standardization for run-virt --- .../opt/openslx/etc/virtualbox/run-virt.include | 642 +++++++++++++++++++++ 1 file changed, 642 insertions(+) create mode 100755 remote/modules/vbox/data/opt/openslx/etc/virtualbox/run-virt.include (limited to 'remote/modules/vbox/data') diff --git a/remote/modules/vbox/data/opt/openslx/etc/virtualbox/run-virt.include b/remote/modules/vbox/data/opt/openslx/etc/virtualbox/run-virt.include new file mode 100755 index 00000000..b755133f --- /dev/null +++ b/remote/modules/vbox/data/opt/openslx/etc/virtualbox/run-virt.include @@ -0,0 +1,642 @@ +# run-virt.include +# ----------------------------------------------------------------------------- +# Copyright (c) 2009..2012 - RZ Uni Freiburg +# Copyright (c) 2009..2013 - 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/ +# ----------------------------------------------------------------------------- +# run-virt.include +# - component for vmware/player of the vmchooser plugin run-virt.sh +################################################################################ + +# configuration writer functions +################################################################################ + +function clean_string () +{ + if [ "$#" -ge 1 ]; then + echo "$@" | tr '[A-Z]' '[a-z]' | tr -d '\t _./' + else + cat - | tr '[A-Z]' '[a-z]' | tr -d '\t _./' + fi +} + +vmostype=$(clean_string "$vmostype") + +runvmwareconfheader () +{ + echo "# This configuration file was generated by $0" > "$conffile" + + MAXMEM="9999999" + MAXCORES="256" + + # check for the ostype + # 1) memory limits + case "$vmostype" in + win31*|windows31*) + MAXMEM="32" + vmostype="win31" + ;; + winnt*|windowsnt*) + MAXMEM="1000" + vmostype="winnt" + ;; + win95*|windows95*) + MAXMEM="96" + vmostype="win95" + ;; + win98*|windows98*) + MAXMEM="384" + vmostype="win98" + ;; + winme*|windowsme*) + MAXMEM="384" + vmostype="winme" + ;; + win2000|windows2000|win2000pro*) + MAXMEM="4000" + vmostype="win2000pro" + ;; + win2000srv*|windows2000srv*|win2000serv*|windows2000serv*) + MAXMEM="4000" + vmostype="win2000serv" + ;; + win2000adv*|windows2000adv*|win2000dat*|windows2000dat*) + MAXMEM="8000" + vmostype="win2000advserv" + ;; + winnet*64|win*2003*64|windowsnet*64) + MAXMEM="8000" + vmostype="winnetstandard-64" + ;; + winnet*|win*2003*|windowsnet*) + MAXMEM="4000" + vmostype="winnetstandard" + ;; + winxphome*|windowsxphome*) + MAXMEM="4000" + vmostype="winxphome" + ;; + winxp*64|windowsxp*64) + MAXMEM="8000" + vmostype="winxppro-64" + ;; + winxp*|windowsxp*) + MAXMEM="4000" + vmostype="winxppro" + ;; + winvista*64|windowsvista*64) + MAXMEM="16000" + vmostype="winvista-64" + ;; + winvista*|windowsvista*) + MAXMEM="8000" + vmostype="winvista" + ;; + win7*64|windows7*64) + MAXMEM="32000" + vmostype="windows7-64" + ;; + win7*|windows7*) + MAXMEM="8000" + vmostype="windows7" + ;; + win*64) + MAXMEM="16000" + ;; + win*) + MAXMEM="8000" + ;; + dos|msdos*|ms-dos*) + MAXMEM="128" + vmostype="dos" + ;; + *64) + MAXMEM="123456" + ;; + *) + MAXMEM="8000" + ;; + esac + + # 2) other hardware + capabilities + shfolders="FALSE" + case "$vmostype" in + win31) + MAXCORES="1" + sound="sb16" + ;; + winnt) + MAXCORES="2" + sound="sb16" + ;; + win95|win98|winme) + MAXCORES="1" + ;; + win2000pro) # Don't know if Win 2000 supports shared folders, disabled to be safe + MAXCORES="2" + ;; + win2000serv) + MAXCORES="4" + ;; + win2000advserv) + MAXCORES="8" + ;; + winxphome) + MAXCORES="1" + shfolders="TRUE" + ;; + winxp*|winvista*|windows7*) + shfolders="TRUE" + ;; + winnet*) + shfolders="TRUE" + ;; + linux*|ubuntu*|suse*|debian*) + shfolders="TRUE" + ;; + macos*64) + MAXCORES="2" + vmostype="freebsd-64" + ;; + macos*) + MAXCORES="1" + vmostype="freebsd" + ;; + beos*) + vmostype="other" + ;; + # Unknown guestOS setting in .xml - use conservative defaults + *64) + vmostype="other-64" + ;; + *) + vmostype="other" + ;; + esac + + svga_autodetect="TRUE" + + real_core_count="$cpu_cores" + [ "$cpu_cores" -gt "$MAXCORES" ] && cpu_cores="$MAXCORES" + # It currently makes no sense to set the virtual number of cores + # to a different value than the virtual number of cores per virtual CPU. + cores_per_socket="$cpu_cores" + + if [ "x$shfolders" != "xFALSE" ]; then + ENABLE_SHARE='sharedFolder.option = "alwaysEnabled"' + else + ENABLE_SHARE='' + fi + + [ "$mem" -ge "$MAXMEM" ] && mem="$MAXMEM" + [ "$hwver" -lt "7" -a "$mem" -gt "3500" ] && mem="3500" + + cap3d="WHAT IS THIS VAR USED FOR?" # helper var for loging output + + cat >> "$conffile" </dev/null 2>&1 +} + +preferencesheader () +{ + cat > "$vmhome/preferences" <> "$vmhome/preferences" <> "$vmhome/preferences" </dev/null 2>&1 +mkdir -p "$confdir" >/dev/null 2>&1 +mkdir -p "$vmhome/dndlogs" >/dev/null 2>&1 +touch "$vmhome/dndlogs/dndlog.conf" >/dev/null 2>&1 + +# create preferences +preferencesheader + +# create VMware startup file +runvmwareconfheader + +# link to conffile if confdir != redodir +ln -s "$conffile" "$redodir/run-vmware.conf" >/dev/null 2>&1 + +# sync is needed to ensure that data is really written to virtual disk +sync + +# own nvram. We need it for floppy drive b, default nvram has just drive a +# TODO: optimize, currently kinda inefficient, too much copys, but we +# don't know which one is installed... +cp "/opt/openslx/etc/vmware/nvram" "$confdir/nvram" 2>/dev/null + + +# logging and stdout +################################################################################ + +# log script information +writelog "# File created by $0 (VMversion ${vmversion})\n# on $(date)\n" +## Edited for persistent mode. +writelog "Starting with ${diskmode} mode ...\n" +## + +# write all results to logfile +# log disksetup +writelog "Directories:" +writelog "\tConfdir:\t${confdir}" +writelog "\tConffile:\t${conffile}" +writelog "\tRedodir:\t${redodir}" +writelog "\tVMhome:\t\t${vmhome}" +writelog "\t/tmp info: \ +$(grep "/tmp " /proc/mounts) $(df -h | grep " /tmp$" | awk '{print $2}')" +# hw setup +writelog "Hardware:" +writelog "\tMAC:\t\t00:50:56:${VM_ID}:${machostpart}" +if [ -n "${network_card}" ]; then + writelog "\tNet Adaptor:\t${network_card}" +fi +writelog "\tMem:\t\t${mem} MB" +# echo nur wenn hostmem gesetzt +[ -n "${hostmem}" ] && writelog "\tHostmem:\t${hostmem} MB" +writelog "\tMax. res.:\t${xres}x${yres}" +writelog "\tCD-ROM1:\t${cdrom0}" +writelog "\tCD-ROM2:\t${cdrom1}" +writelog "\tFloppy_A:\t${floppy0}" +if [ "${serial}" = "TRUE" ]; then + writelog "\tSerial Port:\t${serialdev}" +fi +if [ "${parallel}" = "TRUE" ]; then + writelog "\tParallel Port:\t${paraldev}" +fi +# image +writelog "Diskimage:" +writelog "\tDiskfile:\t${diskfile}" +writelog "\tDisktype:\t${hddrv}" +writelog "\tHWVersion:\t${hwver}" +writelog "\tVMostype:\t${vmostype}" +# misc +writelog "Misc:" +writelog "\tDisplayname:\t${displayname}" +if [ "${cap3d}" = "TRUE" -a "${enable3d}" = "TRUE" ]; then + writelog "\t3D Graphics:\tenabled" +fi +# empty line at end +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 + +# For debugging +cp "$conffile" "/tmp/vmware-last-config" + +# using the modified version of the wrapper script +VIRTCMD="/opt/openslx/bin/vmplayer" +VIRTCMDOPTS="${vmopt} ${conffile}" +RMDIRS="${redodir} ${conffile}" -- cgit v1.2.3-55-g7522