From 1e471825b405ecc0ae15c643a17794a77187fd75 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 27 Oct 2006 18:08:54 +0000 Subject: changed default session chooser and vmware image chooser. defaultwm and kursimages were replaced through runvmware --xdm all and --xdm vm there is an improved error handling in runvmware, aswell. servconfig changed due to this modifications. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@473 95ad53e4-c205-0410-b2fa-d234c58c8868 --- vmware/runvmware | 211 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 114 insertions(+), 97 deletions(-) (limited to 'vmware/runvmware') diff --git a/vmware/runvmware b/vmware/runvmware index 14915ffc..fd380955 100755 --- a/vmware/runvmware +++ b/vmware/runvmware @@ -1,33 +1,30 @@ #!/bin/sh # # Description: Script for preparing VMware environment Diskless -# X Stations (v4) +# X Stations and interactive session chooser (v4) # # Author(s): Dirk von Suchodoletz , 18-03-2006 -# Michael Janczyk , 03-10-2006 +# Michael Janczyk , 27-10-2006 # Copyright: (c) 2003, 2006 - RZ Universitaet Freiburg # -# Version: 0.15.435 +# Version: 0.16.473 # ################################################################################ - -# read from machine-setup (for slxgrp) +### read from machine-setup (for slxgrp) ####################################### . /etc/machine-setup - ### VERBOSE? ################################################################### # set verbose mode (set -x(v)) #set -xv - - ### HEADER SECTION ############################################################# # write runvmware.conf -runvmwareconfheader () { +runvmwareconfheader () +{ echo " ############################################################################## ###### This configuration file was generated by 'runvmware', ###### @@ -133,18 +130,18 @@ runvmwareconfheader () { } -preferencesheader () { +preferencesheader () +{ echo " ############################################################################## ###### This configuration file was generated by 'runvmware', ###### ###### dont use it for your own configurations - it will be overwritten ###### ###### ###### - -################# wichtig ################# -# das *.vmem wird immer angelegt und frisst soviel Speicher, wie fuer den Gast -# vorgesehen. Sollte nicht im tempfs liegen. NFS OK, da IO nur einmal beim -# Start erheblich. Wird gesteuert ueber tmpDirectory = /nfs-viel-platz -# und darin wird dann vmware-$user angelegt. + ################################## Wichtig! ################################## + ###### *.vmem wird immer angelegt und frisst soviel Speicher, wie fuer ###### + ###### den Gast vorgesehen. Sollte nicht im tempfs liegen. NFS OK, da ###### + ###### IO nur einmal beim Start erheblich. Wird gesteuert ueber ###### + ###### tmpDirectory = /nfs-viel-platz und darin wird dann vmware-\$user ###### ###### angelegt. ###### hints.hideAll = \"TRUE\" pref.exchangeSelections = \"TRUE\" @@ -168,15 +165,8 @@ preferencesheader () { } - - ### VARIABLES SECTION ########################################################## - # declaration of default variables - -# first read variables from machine-setup -. /etc/machine-setup - # script variables last_changes=$(head -n 15 $0 | grep "@" | awk -F ", " '{print $2}' \ | awk -F "-" '{print $3" "$2" "$1}' | sort -bfnr \ @@ -212,7 +202,6 @@ guestres= g_xres= g_yres= - # VMware variables # VMware build vmbuild=$(vmware -v | awk -F "-" '{print $2}') @@ -225,9 +214,14 @@ vmdir="/var/lib/vmware" # templates dir vmtempl="${vmdir}/templ" # .desktop files directory +xsessions="/usr/share/xsessions" vmsessions="${vmdir}/vmsessions" -desktops= -desktopsnr= +themesdir="/var/lib/openslx/themes" +desktops=( `ls ${vmsessions}/*.desktop 2>/dev/null` ) +desktopsnr=$(echo "${#desktops[*]}") +dialogtitle='--title "VMware Image Menu"' +slxgrp=$(echo ${slxgrp} | tr [A-Z] [a-z]) +slxgrptest= execute=() menu= # special Variables @@ -250,7 +244,6 @@ displayname="Diskless X Station VMware Image" # image checking variable filecheck= - # command line variables # start with this this default commmand line options + extra defaults=$(grep -v "#.*" ${vmtempl}/defaults) @@ -261,17 +254,16 @@ nofclopt=$(expr $# + $(echo ${defaults} | wc -w)) silent= include= debug=0 -inter= +istart= +xdm= comdef= - - ### FUNCTIONS SECTION ########################################################## - # function to write to stdout/logfile # logs labeled with $2=0 write to stdout, if debug set, write to logfile -writelog () { +writelog () +{ # write to stdout [ -z ${silent} ] && [ "$2" = "0" ] && echo -e "$1" @@ -287,17 +279,20 @@ writelog () { } -help () { +help () +{ cat < start image /\${vmdir}/.vmdk + --xdm all lists xdm sessions and VMware images, + vm lists only VMware images, use only w/ xdm + -s|--start start image /\${vmdir}/.vmdk -a|--alias use aliases --silent no stdout from runvmware - --mem override autoallocation of memory, in percent + --mem override autoallocation of memory, in percent m,M megabyte, g,G gigabyte, h,H reserve f. host --res Maximum resolution of the guest os, e.g. 800x600 --delay delay the start of the script n seconds @@ -332,7 +327,8 @@ EOH } -checkalias () { +checkalias () +{ if [ -r "${vmtempl}/alias" ]; then writelog "Checking alias for ${startvm}...\c" 0 1 @@ -352,11 +348,39 @@ checkalias () { } -x_dialog () { - desktops=( `ls ${vmsessions}/*.desktop 2>/dev/null` ) - desktopsnr=$(echo "${#desktops[*]}") - slxgrp=$(echo ${slxgrp} | tr [A-Z] [a-z]) - slxgrptest= +xdm_mode () +{ + # Xdailog test + xdialog=$(which Xdialog) + [ -z "${xdialog}" ] && \ + xterm -e 'echo -e "\n\n\n\n\n\n\t\t\tNo Xdialog installed!!!\ + \n\n\t\t\tClosing in 3 seconds."; sleep 3' && exit 1 + + # set X background + res=$(xvidtune -show | grep -wo "\".*\"" | sed "s/\"//g") + if ! [ -f ${themesdir}/bootsplash/images/silent-${res}.jpg ]; then + img=$(ls ${themesdir}/bootsplash/images/ | grep -m 1 "silent") + display -window root ${themesdir}/bootsplash/images/${img} + else + display -window root ${themesdir}/bootsplash/images/silent-${res}.jpg + fi + + dialogtitle='--rc-file ${themesdir}/Xdialog/gtkrc \ + --title "VMware Image Menu"' + + if [ "${xdm}" = "all" ]; then + desktops=( `ls ${xsessions}/*.desktop 2>/dev/null \ + | grep -v "default.*" | sort -bf; \ + ls ${vmsessions}/*.desktop 2>/dev/null | sort -bf` ) + desktopsnr=$(echo "${#desktops[*]}") + dialogtitle='--rc-file ${themesdir}/Xdialog/gtkrc \ + --title "Desktop / VMware-Image Menu"' + fi +} + + +x_dialog () +{ (( args=0 )) declare -i i=0 @@ -392,13 +416,18 @@ x_dialog () { (( args=${args}+1 )) done - + # test if menu not empty? - [ -z "${menu}" ] && Xdialog --infobox "No items found to display!!!" 10 30 3000 && exit 1 + if [ -z "${menu}" ]; then + Xdialog --infobox "No items found to display!!! + For Vmware images add .desktop files to + ${vmsessions}" 10 50 6000 + exit 1 + fi # --stderr because of 1>/dev/null # echoing to file because Xdialog sux when used w/ quotes - echo -e "Xdialog --title \"VMware Image Menu\" \ + echo -e "Xdialog ${dialogtitle} \ --screen-center \ --fill \ --no-wrap \ @@ -412,11 +441,11 @@ x_dialog () { . ${tmpdir}/Xdialog rm -f ${tmpdir}/Xdialog - } -filecheck () { +filecheck () +{ filecheck=$(LANG=us ls -lh ${diskfile} 2>&1) writelog "Filecheck:\n${filecheck}\n" 0 1 noimage=$(echo ${filecheck} | grep -i "no such file or directory" | wc -l) @@ -463,12 +492,9 @@ filecheck () { writelog "Hint:\t\t\tUse nonpersistent-mode or change rights to rw\n" 0 0 exit 1 fi - } - - #### INTERPRET COMMAND LINE OPTIONS ############################################ # print help if no clo if [ ${nofclopt} = "0" ]; then @@ -489,11 +515,17 @@ while [ ${nofclopt} -gt "${args}" ]; do exit 0 ;; -i|--interactive) - inter="TRUE" + istart="TRUE" + ;; + --xdm) + (( args=${args}+1 )) + xdm=${lineopts[${args}]} + xdmstart="TRUE" ;; -s|--start) (( args=${args}+1 )) startvm=${lineopts[${args}]} + sstart="TRUE" ;; -a|--alias) alias="TRUE" @@ -566,9 +598,37 @@ while [ ${nofclopt} -gt "${args}" ]; do done +### STARTING ################################################################### +# create environment +# remove leftover locks from former runs, +# problems may occure if you run more then one vmware with this script +rm -f ${tmpdir}/*LOCK >/dev/null 2>&1 +rm -f ${tmpdir}/*.${debug}.log >/dev/null 2>&1 + +# create vmware directories +mkdir -p ${tmpdir} >/dev/null 2>&1 +mkdir -p ${vmhome} >/dev/null 2>&1 +# NO X-server no runvmware ;) +[ -z "$DISPLAY" ] && echo -e "\n\tStart only within a desktop!\n" && exit 1 -### STARTING ################################################################### +# if --xdm set don't go further, only used for xdm starts +if [ "${xdm}" = "all" -o "${xdm}" = "vm" ]; then + xdm_mode + args_dial=$(x_dialog 2>&1) # 2>&1, see function + exec ${args_dial} + exit 0 +elif [ -n "${xdmstart}" -a -z "${xdm}" ]; then + xterm -e 'echo -e "\n\n\n\n\n\n\t\t\tWrong --xdm option! \ + \n\t\t\tOnly all or vm possible.\ + \n\n\t\t\tClosing in 3 seconds."; sleep 3' && exit 1 +fi + +# if not interactive mode or image spezified via command line stop +if [ -z "${istart}" -a -z "${sstart}" ]; then + writelog "\n\tSpecify image to start /w -s or run interactive mode -i!\n" 0 0 + exit 1 +fi # logo for console if [ -z ${silent} ]; then @@ -587,23 +647,7 @@ writelog "Starting...`echo ${np} | sed -e \"s,i.*-,,g\" \ fi - - ### CHECK MACHINE SETUP ######################################################## - -# create environment -# remove leftover locks from former runs, -# problems may occure if you run more then one vmware with this script -rm -f ${tmpdir}/*LOCK >/dev/null 2>&1 -rm -f ${tmpdir}/*.${debug}.log >/dev/null 2>&1 - - -# create vmware directories -mkdir -p ${tmpdir} >/dev/null 2>&1 -mkdir -p ${vmhome} >/dev/null 2>&1 - - - # start logging, because now we have the directories created ;) writelog "##################################################" 1 99 writelog "#\n# File created by $0 (v.${version})\n# on `date`" 1 99 @@ -618,8 +662,6 @@ writelog "Directories: \tTmpdir:\t\t${tmpdir}\n\tVMhome:\t\t${vmhome}\n\tTmpdir info:\ \t`mount | grep -i "/tmp "`\n" 0 1 - - # configuring MAC address: first four bytes are fixed (00:50:56:0D) the # last two bytes are taken from the local network adaptor writelog "Starting hardware / device detection...\c" 0 1 @@ -627,7 +669,6 @@ writelog "Starting hardware / device detection...\c" 0 1 mac=$(/sbin/ifconfig eth0 | grep eth0 | sed -e "s, ,,g" \ | awk -F ":" '{print $(NF-1)":"$NF}') - # get memory in MB memtest=$(expr $(grep -i "memtotal" /proc/meminfo | awk '{print $2}') / 1024) @@ -661,7 +702,6 @@ if [ "${mem}" -lt "128" ] || [ "${mem}" -gt "${memtest}" ]; then exit 1 fi - # look for cdrom,dvd and floppy and add them to the vm config file if [ -L /dev/cdrom ] ; then cdr_1="TRUE" @@ -671,11 +711,9 @@ if [ -L /dev/cdrom1 ] ; then cdr_2="TRUE" fi - # check for floppy controller test ! -d /sys/block/fd0 && floppya="FALSE" - # guest resolution if [ -n "${guestres}" ]; then g_xres=$(echo "${guestres}" | awk -F "x" '{print $1}') @@ -696,19 +734,14 @@ writelog "finished\nResults:\n\tMAC:\t\t00:50:56:0D:${mac}\n\tMem:\t\t${mem} MB \t${floppyb}\n\tCD-ROM_1:\t${cdr_1}\n\tCD-ROM_2:\t${cdr_2}\n" 0 1 - - ### SELECT VIRTUAL IMAGE ####################################################### - # interactive mode -if [ -n "${inter}" ]; then +if [ -n "${istart}" ]; then writelog "Starting interactive mode...\c" 0 0 - menutest=$(ls ${vmsessions} | grep -x ".*desktop" 2>/dev/null | wc -l) - # check for session files - if [ "${menutest}" = "0" ]; then - writelog "\rNo sessions found in ${vmsessions} for option -i" 0 99 + if [ -z "${desktops}" ]; then + writelog "\rNo .desktop files found in ${vmsessions} for option -i" 0 99 writelog "Please use option -s and check your configuration \n" 0 0 exit 1 fi @@ -737,11 +770,9 @@ if [ -n "${inter}" ]; then writelog "finished.\nResult:\n\tVMimage:\t${startvm}\n" 0 1 fi - # aliases [ -n "${alias}" ] && checkalias - # image allocation writelog "Starting image detection...\c" 0 1 @@ -755,36 +786,28 @@ if [ -z "${comdef}" ]; then # if ${ostype} not found use else statement vmostype=${vmostype:-"other"} - fi - # define name for VMware window displayname=$(grep -m 1 -i "name" \ ${vmsessions}/*${startvm}.desktop | awk -F "=" '{print $2}') # if variable not set displayname=${displayname:-"VMware Image"} - writelog "finished\nResults:\n\tDiskfile:\t${diskfile} \tVMostype:\t${vmostype}\n\tDisplayname:\t${displayname}\n" 0 1 - # link to windows image writelog "Linking \"ln -fs ${diskfile} \t${tmpdir}/disk\"...\c" 0 1 ln -fs ${diskfile} ${tmpdir}/disk writelog "finished\nResult:\n`ls -l ${tmpdir}/disk`\n" 0 1 - # check if image exists, etc... filecheck - - ### WRITE CONFIGURATION FILES ################################################## - # create preferences preferencesheader @@ -804,9 +827,7 @@ amixer -q sset PCM 28 unmute writelog "finished\n" 0 0 - ### RUN VMWARE(-Player) ######################################################## - # ...with the automatically written config file if [ `which vmplayer 2>/dev/null` ] && [ -z "${vmrun}" ] \ || [ "${vmrun}" = "vmplayer" ]; then @@ -828,12 +849,8 @@ elif [ `which vmware 2>/dev/null` ] && [ -z "${vmrun}" ] \ else writelog "\nNo VMware/VMPlayer found!\n" 0 99 exit 1 - fi - - - writelog "\nBye.\n" 0 0 exit 0 ################################################################################ -- cgit v1.2.3-55-g7522