#!/bin/bash ################################################################################ ## Creates vmware and vbox (script creation for vbox is not implented yet) ## runscripts from xmlfiles. ## Use template file runvmware-v2 for executeables ## ## ## Structure: ## ${vmdir}/$image.xml configurationfile ## ${vmdir}/$image.vmdk vmware image file ## ${vmdir}/$image.vbox vbox image file ## ${vmdir}/runscripts/$pool/*.vmware vmware runscript ## ${vmdir}/runscripts/$pool/*.vbox virtualbox runscript ## ${vmdir}/templates/runvmware-v2 image exec template script ################################################################################ #TODO: check first if this xml file should be used, if not jump out of the # while loop. reducee checks and resources # Just needed if vmdir is somewhere else vmdir="." && cd ${vmdir} # File for dektopentrys #TODO: where to put? temporary test file, we should delete it or move it # later, else there isnt a valid entryfile till this script is finished desktopentry="${vmdir}/desktopentrys" # template for runvmware templatevmware="${vmdir}/templates/runvmware-v2" # Take all xml files and work with them for xml in *.xml;do # converts the XML file to utf-8, whyever we need that # inefficient here, because we don't need utf-8 for every xml file # but most secure place. Else the structure gets screwed. #TODO: perhaps we can kick out the whole UTF-8 shit, if the admins # are not able to give us the correct format, we shouldnt fix it iconv -c -f utf-8 -t utf-8 < ${xml} > ${xml}.utf ############################################################################## ## get needed information from xml file and check them if needed ############################################################################## # get image name image=`grep -i "> isnt nice for so much lines echo "Desktop entry for ${image}" >> ${desktopentry} echo "[Desktop Entry]" >> ${desktopentry} echo "X-SuSE-translate=true" >> ${desktopentry} echo "Encoding=UTF-8" >> ${desktopentry} echo "Type=XSession" >> ${desktopentry} #TODO: Fix path echo "Exec=/path/to/the/execfile/${image}" >> ${desktopentry} echo "Name=${short_description}" >> ${desktopentry} echo "Comment=${comment}" >> ${desktopentry} #TODO: I dont like SLXGrp as variable herein, why we need it here? #echo "SLXGrp=${pools}" >> ${desktopentry} #TODO: do we need XDM configuration? -> Chemie pool #echo "XDM=${xdm}" >> ${desktopentry} echo "" >> ${desktopentry} fi ################################################################################ ## TODO: remember default/ chemie/ option (desktopentrys! and runfiles) ## delete old desktop list ## fucking pools/directory hirarchy... test it with running script and find ## that way the error ################################################################################ # If we have vmware, build execute from template if [ "${vm}" = "vmware" ]; then sed -e "s/imagename=\"CHANGEIT\"/imagename=\"${image}\"/" \ -e "s/displayname=\"CHANGEIT\"/displayname=\"${short_description}\"/" \ -e "s/vmostype=\"CHANGEIT\"/vmostype=\"${os}\"/" \ -e "s/network=\"CHANGEIT\"/network=\"${network}\"/" \ ${templatevmware} \ > ${vmdir}/runscripts/${i}/${image}.runvmware # if we have virtualbox, can only be vbox cause checked above else echo "Currently Virtualbox isn't implented" exit 0 fi done done # Delete all .utf files, we dont need them anymore rm -f *.xml.utf