From 3ba5a58e5b04b771e6ee99ee6d6f772991c1c236 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 2 Aug 2013 17:27:28 +0200 Subject: [vmchooser] moved all vmchooser specific files and scripts to /opt/openslx. Renamed 'var/lib/virt' to 'mnt/vmstore'. Added bwlehrpool theme for vmchooser# --- mltk | 2 +- .../vmchooser/data/etc/openslx/vmchooser/smb.conf | 25 - .../data/etc/openslx/vmchooser/vmchooser-env | 112 ---- .../data/etc/openslx/vmchooser/vmchooser.conf | 4 - .../data/etc/systemd/system/mount-vm-store.service | 10 + .../network.target.wants/mount-vm-store.service | 1 + .../network.target.wants/var-lib-virt.service | 1 - .../data/etc/systemd/system/var-lib-virt.service | 10 - .../data/etc/systemd/system/vmchooser.service | 2 +- .../vmchooser/data/opt/openslx/bin/xmlfilter.sh | 64 --- .../data/opt/openslx/etc/vmchooser/smb.conf | 25 + .../data/opt/openslx/etc/vmchooser/vmchooser.conf | 4 + .../vmchooser/data/opt/openslx/scripts/run-virt.sh | 466 ---------------- .../opt/openslx/scripts/systemd-mount_vm_store | 6 +- .../data/opt/openslx/scripts/systemd-vmchooser_env | 112 ++++ .../data/opt/openslx/scripts/vmchooser-run_virt | 464 +++++++++++++++ .../data/opt/openslx/scripts/vmchooser-xml_filter | 64 +++ .../themes/bwlehrpool/bwlehrpool-left.png | Bin 0 -> 5361 bytes .../themes/bwlehrpool/bwlehrpool-right.png | Bin 0 -> 3390 bytes .../vmchooser/themes/bwlehrpool/bwlehrpool.ini | 4 + .../vmchooser/themes/openslx/openslx-left.png | Bin 0 -> 9187 bytes .../vmchooser/themes/openslx/openslx-right.png | Bin 0 -> 3390 bytes .../usr/share/vmchooser/themes/openslx/openslx.ini | 4 + .../vmchooser/themes/planets/planets-left.png | Bin 0 -> 11337 bytes .../vmchooser/themes/planets/planets-right.png | Bin 0 -> 3082 bytes .../usr/share/vmchooser/themes/planets/planets.ini | 4 + .../data/opt/openslx/xsessions/default.desktop | 2 +- .../vmchooser/themes/openslx/openslx-left.png | Bin 9187 -> 0 bytes .../vmchooser/themes/openslx/openslx-right.png | Bin 3390 -> 0 bytes .../share/vmchooser/themes/openslx/openslx.ini | 4 - .../vmchooser/themes/planets/planets-left.png | Bin 11337 -> 0 bytes .../vmchooser/themes/planets/planets-right.png | Bin 3082 -> 0 bytes .../share/vmchooser/themes/planets/planets.ini | 4 - .../local/share/vmchooser/themes/unifr/title_l.png | Bin 17458 -> 0 bytes .../local/share/vmchooser/themes/unifr/title_r.png | Bin 4113 -> 0 bytes .../local/share/vmchooser/themes/unifr/unifr.ini | 4 - .../vmchooser/data/var/opt/openslx/bin/run-virt.sh | 1 - remote/modules/vmchooser/vmchooser.build | 22 +- .../modules/vmplayer/data/etc/openslx/vmware/nvram | Bin 8664 -> 0 bytes .../data/etc/openslx/vmware/run-virt.include | 619 --------------------- .../vmplayer/data/etc/openslx/vmware/vmware-env | 281 ---------- .../vmplayer/data/etc/openslx/vmware/vmware.conf | 8 - .../data/etc/systemd/system/vmware.service | 2 +- .../vmplayer/data/opt/openslx/etc/vmware/nvram | Bin 0 -> 8664 bytes .../data/opt/openslx/etc/vmware/run-virt.include | 619 +++++++++++++++++++++ .../data/opt/openslx/etc/vmware/vmware.conf | 8 + .../data/opt/openslx/scripts/systemd-vmware_env | 281 ++++++++++ 47 files changed, 1622 insertions(+), 1617 deletions(-) delete mode 100644 remote/modules/vmchooser/data/etc/openslx/vmchooser/smb.conf delete mode 100755 remote/modules/vmchooser/data/etc/openslx/vmchooser/vmchooser-env delete mode 100644 remote/modules/vmchooser/data/etc/openslx/vmchooser/vmchooser.conf create mode 100644 remote/modules/vmchooser/data/etc/systemd/system/mount-vm-store.service create mode 120000 remote/modules/vmchooser/data/etc/systemd/system/network.target.wants/mount-vm-store.service delete mode 120000 remote/modules/vmchooser/data/etc/systemd/system/network.target.wants/var-lib-virt.service delete mode 100644 remote/modules/vmchooser/data/etc/systemd/system/var-lib-virt.service delete mode 100755 remote/modules/vmchooser/data/opt/openslx/bin/xmlfilter.sh create mode 100644 remote/modules/vmchooser/data/opt/openslx/etc/vmchooser/smb.conf create mode 100644 remote/modules/vmchooser/data/opt/openslx/etc/vmchooser/vmchooser.conf delete mode 100755 remote/modules/vmchooser/data/opt/openslx/scripts/run-virt.sh create mode 100755 remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env create mode 100755 remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt create mode 100755 remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter create mode 100644 remote/modules/vmchooser/data/opt/openslx/usr/share/vmchooser/themes/bwlehrpool/bwlehrpool-left.png create mode 100644 remote/modules/vmchooser/data/opt/openslx/usr/share/vmchooser/themes/bwlehrpool/bwlehrpool-right.png create mode 100644 remote/modules/vmchooser/data/opt/openslx/usr/share/vmchooser/themes/bwlehrpool/bwlehrpool.ini create mode 100644 remote/modules/vmchooser/data/opt/openslx/usr/share/vmchooser/themes/openslx/openslx-left.png create mode 100644 remote/modules/vmchooser/data/opt/openslx/usr/share/vmchooser/themes/openslx/openslx-right.png create mode 100644 remote/modules/vmchooser/data/opt/openslx/usr/share/vmchooser/themes/openslx/openslx.ini create mode 100644 remote/modules/vmchooser/data/opt/openslx/usr/share/vmchooser/themes/planets/planets-left.png create mode 100644 remote/modules/vmchooser/data/opt/openslx/usr/share/vmchooser/themes/planets/planets-right.png create mode 100644 remote/modules/vmchooser/data/opt/openslx/usr/share/vmchooser/themes/planets/planets.ini delete mode 100644 remote/modules/vmchooser/data/usr/local/share/vmchooser/themes/openslx/openslx-left.png delete mode 100644 remote/modules/vmchooser/data/usr/local/share/vmchooser/themes/openslx/openslx-right.png delete mode 100644 remote/modules/vmchooser/data/usr/local/share/vmchooser/themes/openslx/openslx.ini delete mode 100644 remote/modules/vmchooser/data/usr/local/share/vmchooser/themes/planets/planets-left.png delete mode 100644 remote/modules/vmchooser/data/usr/local/share/vmchooser/themes/planets/planets-right.png delete mode 100644 remote/modules/vmchooser/data/usr/local/share/vmchooser/themes/planets/planets.ini delete mode 100644 remote/modules/vmchooser/data/usr/local/share/vmchooser/themes/unifr/title_l.png delete mode 100644 remote/modules/vmchooser/data/usr/local/share/vmchooser/themes/unifr/title_r.png delete mode 100644 remote/modules/vmchooser/data/usr/local/share/vmchooser/themes/unifr/unifr.ini delete mode 120000 remote/modules/vmchooser/data/var/opt/openslx/bin/run-virt.sh delete mode 100644 remote/modules/vmplayer/data/etc/openslx/vmware/nvram delete mode 100644 remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include delete mode 100755 remote/modules/vmplayer/data/etc/openslx/vmware/vmware-env delete mode 100644 remote/modules/vmplayer/data/etc/openslx/vmware/vmware.conf create mode 100644 remote/modules/vmplayer/data/opt/openslx/etc/vmware/nvram create mode 100644 remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include create mode 100644 remote/modules/vmplayer/data/opt/openslx/etc/vmware/vmware.conf create mode 100755 remote/modules/vmplayer/data/opt/openslx/scripts/systemd-vmware_env diff --git a/mltk b/mltk index ee965f49..24de8d33 100755 --- a/mltk +++ b/mltk @@ -264,7 +264,7 @@ run() { [[ $SERVER_SYNC == 1 ]] && sync_remote [[ $SERVER_CLEAN == 1 ]] && clean_target $TARGET [[ $SERVER_EXPORT == 1 ]] && export_target $TARGET $SERVER_EXPORT_TYPE - [[ $SERVER_CONFIG == 1 ]] && echo "LASFKHSL" && generate_config $SERVER_CONFIG_TYPE + [[ $SERVER_CONFIG == 1 ]] && generate_config $SERVER_CONFIG_TYPE fi } diff --git a/remote/modules/vmchooser/data/etc/openslx/vmchooser/smb.conf b/remote/modules/vmchooser/data/etc/openslx/vmchooser/smb.conf deleted file mode 100644 index ec757ce4..00000000 --- a/remote/modules/vmchooser/data/etc/openslx/vmchooser/smb.conf +++ /dev/null @@ -1,25 +0,0 @@ -# basic samba configuration file for OpenSLX host-internal networking -[global] - workgroup = OPENSLX - netbios name = HOMESERVER - security = SHARE - server string = Home and Print Provider - bind interfaces only = Yes - interfaces = NWIF - pid directory = PIDDIR - -[userhome] - comment = Home Directory of USER - path = /home/USER - create mask = 0700 - guest ok = No - read only = No - -[scratch] - comment = Host System Temp Folder - path = /tmp - create mask = 0700 - guest ok = Yes - read only = No - browseable = Yes - diff --git a/remote/modules/vmchooser/data/etc/openslx/vmchooser/vmchooser-env b/remote/modules/vmchooser/data/etc/openslx/vmchooser/vmchooser-env deleted file mode 100755 index e2a3e063..00000000 --- a/remote/modules/vmchooser/data/etc/openslx/vmchooser/vmchooser-env +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh - -export PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin:/opt/openslx/usr/bin:/opt/openslx/usr/sbin - -#source config file with vars (e.g. ipaddr, macaddr, hostname) -. /opt/openslx/config - -#from plugins/vmchooser/40-started-hw-config/run-virt.sh -#TODO: extra systemd-service for hwinfo -hwinfo --cdrom | grep -i "Device File:" | awk {'print $3'} >/etc/openslx/hwinfo.cdrom -hwinfo --floppy | grep -i "Device File:" | awk {'print $3'} >/etc/openslx/hwinfo.floppy - -#from plugins/vmchooser/XX_vmchooser.sh -VMCHOOSER_CONF_DIR=/etc/openslx/vmchooser - -mkdir -p ${VMCHOOSER_CONF_DIR}/loopimg -mkdir -p ${VMCHOOSER_CONF_DIR}/fd-loop -m 1777 - -# mount a clean tempfs (bug in UnionFS prevents loopmount to work) -grep -qE "unionfs |aufs " /proc/mounts && \ -mount -n -o size=1500k -t tmpfs vm-loopimg ${VMCHOOSER_CONF_DIR}/loopimg - -# create an empty floppy image of 1.4MByte size -dd if=/dev/zero of=${VMCHOOSER_CONF_DIR}/loopimg/fd.img count=2880 bs=512 2>/dev/null -chmod 0777 ${VMCHOOSER_CONF_DIR}/loopimg/fd.img - -# use dos formatter copied into stage3 -mkdosfs ${VMCHOOSER_CONF_DIR}/loopimg/fd.img >/dev/null 2>&1 #|| error -mount -n -t msdos -o loop,umask=000 ${VMCHOOSER_CONF_DIR}/loopimg/fd.img \ - ${VMCHOOSER_CONF_DIR}/fd-loop - -#pvs integration -#if [ $vmchooser_pvs -ne 0 ]; then -# sed -i /usr/share/xsessions/default.desktop \ -# -e "s,vmchooser$,vmchooser --pvs," -#fi - -# setup more scratch space for virtual machines, if configured -mkdir -p /tmp/virt -mkdir -p /var/log/samba - -# enable normal users to setup the extended virtual machine redo file space -# and image source via network block device (NBD only at the moment) -# allow to start/stop samba on virtual devices (latter one ignores multiple -# independent daemons) - -#cat >> /mnt/etc/sudoers << EOF -# allow to start and stop the special /tmp redo file space (RAM + NBD/NFS server RAID) -#ALL ALL=NOPASSWD: /sbin/losetup /dev/loop* -#ALL ALL=NOPASSWD: /sbin/mdadm -C /dev/md0 -l linear --raid-devices=2 /dev/loop* /dev/* -#ALL ALL=NOPASSWD: /opt/openslx/rootfs/usr/sbin/nbd-client * * /dev/nbd* -# allow to configure and start/stop samba services -#ALL ALL=NOPASSWD: /opt/openslx/rootfs/bin/sed -i /etc/*/smb.conf -e * -#ALL ALL=NOPASSWD: /usr/sbin/nmbd -s /etc/*/smb.conf -#ALL ALL=NOPASSWD: /usr/sbin/smbd -s /etc/*/smb.conf -#ALL ALL=NOPASSWD: /opt/openslx/rootfs/usr/bin/killall nmbd smbd -#EOF - -#from plugins/vmchooser/80-after-plugins/virtualization.sh - -# change free mem -mem_free=$(grep -i "^memfree:" /proc/meminfo | awk '{print $2}') -mem_cached=$(grep -i "^cached:" /proc/meminfo | awk '{print $2}') -mem_swapcached=$(grep -i "^swapcached:" /proc/meminfo | awk '{print $2}') -[ -z "$mem_free" ] && mem_free="2048000" -[ -z "$mem_cached" ] && mem_cached="0" -[ -z "$mem_swapcached" ] && mem_swapcached="0" -totalmem="$[ ( $mem_free + $mem_cached + $mem_swapcached ) / 1024 ]" -echo "totalmem=${totalmem}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf - -# cpu cores -CPU_CORES=$(grep '^processor.*:' /proc/cpuinfo | wc -l) -if [ "${CPU_CORES}" -gt "1" 2>/dev/null ]; then - echo "cpu_cores=${CPU_CORES}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf -else - echo 'cpu_cores=1' >> ${VMCHOOSER_CONF_DIR}/virtualization.conf -fi - -# arch -echo "host_arch=$(uname -m)" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf - -# VT enabled cpu? -if grep -q ^flags.*\\\ /proc/cpuinfo; then - echo "vtflag=1" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf - echo 'kvm_module="kvm_intel"' >> ${VMCHOOSER_CONF_DIR}/virtualization.conf - elif grep -q ^flags.*\\\ /proc/cpuinfo; then - echo "vtflag=1" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf - echo 'kvm_module="kvm_amd"' >> ${VMCHOOSER_CONF_DIR}/virtualization.conf - else - echo "vtflag=0" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf -fi - -# write mac -echo "hostmacaddr=${SLX_PXE_MAC}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf -# ip addr -echo "hostip=${SLX_PXE_CLIENT_IP}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf -# hostname -echo "hostname=${SLX_HOSTNAME}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf - -# get further hw information -j=0 -for i in $(cat /etc/openslx/hwinfo.cdrom); do - echo "cdrom_$j=$i" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf - j=$(expr $j + 1) -done - -j=0 -for i in $(cat /etc/openslx/hwinfo.floppy); do - echo "floppy_$j=$i" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf - j=$(expr $j + 1) -done - diff --git a/remote/modules/vmchooser/data/etc/openslx/vmchooser/vmchooser.conf b/remote/modules/vmchooser/data/etc/openslx/vmchooser/vmchooser.conf deleted file mode 100644 index 3dd30ebc..00000000 --- a/remote/modules/vmchooser/data/etc/openslx/vmchooser/vmchooser.conf +++ /dev/null @@ -1,4 +0,0 @@ -pool=default -theme=unifr -pvs=0 -path=/var/lib/virt diff --git a/remote/modules/vmchooser/data/etc/systemd/system/mount-vm-store.service b/remote/modules/vmchooser/data/etc/systemd/system/mount-vm-store.service new file mode 100644 index 00000000..cfaa7af8 --- /dev/null +++ b/remote/modules/vmchooser/data/etc/systemd/system/mount-vm-store.service @@ -0,0 +1,10 @@ +[Unit] +Description=Mount VM store per NFS +After=download-config.service network.target +Requires=network.target +DefaultDependencies=no +ConditionPathExists=/run/udhcpc/network-ready + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-mount_vm_store diff --git a/remote/modules/vmchooser/data/etc/systemd/system/network.target.wants/mount-vm-store.service b/remote/modules/vmchooser/data/etc/systemd/system/network.target.wants/mount-vm-store.service new file mode 120000 index 00000000..d6a88c27 --- /dev/null +++ b/remote/modules/vmchooser/data/etc/systemd/system/network.target.wants/mount-vm-store.service @@ -0,0 +1 @@ +../mount-vm-store.service \ No newline at end of file diff --git a/remote/modules/vmchooser/data/etc/systemd/system/network.target.wants/var-lib-virt.service b/remote/modules/vmchooser/data/etc/systemd/system/network.target.wants/var-lib-virt.service deleted file mode 120000 index f51adef6..00000000 --- a/remote/modules/vmchooser/data/etc/systemd/system/network.target.wants/var-lib-virt.service +++ /dev/null @@ -1 +0,0 @@ -../var-lib-virt.service \ No newline at end of file diff --git a/remote/modules/vmchooser/data/etc/systemd/system/var-lib-virt.service b/remote/modules/vmchooser/data/etc/systemd/system/var-lib-virt.service deleted file mode 100644 index cfaa7af8..00000000 --- a/remote/modules/vmchooser/data/etc/systemd/system/var-lib-virt.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Mount VM store per NFS -After=download-config.service network.target -Requires=network.target -DefaultDependencies=no -ConditionPathExists=/run/udhcpc/network-ready - -[Service] -Type=oneshot -ExecStart=/opt/openslx/scripts/systemd-mount_vm_store diff --git a/remote/modules/vmchooser/data/etc/systemd/system/vmchooser.service b/remote/modules/vmchooser/data/etc/systemd/system/vmchooser.service index 001d90f3..1a5a980a 100644 --- a/remote/modules/vmchooser/data/etc/systemd/system/vmchooser.service +++ b/remote/modules/vmchooser/data/etc/systemd/system/vmchooser.service @@ -6,4 +6,4 @@ Before=graphical.target [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/etc/openslx/vmchooser/vmchooser-env +ExecStart=/opt/openslx/scripts/systemd-vmchooser_env diff --git a/remote/modules/vmchooser/data/opt/openslx/bin/xmlfilter.sh b/remote/modules/vmchooser/data/opt/openslx/bin/xmlfilter.sh deleted file mode 100755 index 67e49d3e..00000000 --- a/remote/modules/vmchooser/data/opt/openslx/bin/xmlfilter.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# Copyright (c) 2007..2009 - RZ Uni FR -# Copyright (c) 2007..2011 - 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/ -# ----------------------------------------------------------------------------- -# xmlfilter.sh -# - This script is invoked by the vmchooser tool. It simply filters xml- -# files (taking the path to these files in $1). You might modify it in any -# way to match your needs, e.g. ask some database instead. You can re- -# implement it in any other programming language too. You simply have to -# return a list of proper xml files to be interpreted by the vmchooser -# binary). Please check for vmchooser.sh too ... -# ----------------------------------------------------------------------------- - -# This script . -# -# currently: -# - filter for slxgrp (which comes from /etc/machine-setup) -# - -# include default directories -. /etc/opt/openslx/openslx.conf - -if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf ]; then - . ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf -fi - -function handlePersistentVM() { - if [[ "$(grep --extended-regexp \ - "> ${LOGFILE} -} - -# remove config dirs when exit -cleanexit () { - if echo "${RMDIRS}" 2>/dev/null | grep -q ${xmlvirt}; then - writelog "${xmlvirt} exited. Cleanning up... \c" - rm -rf ${RMDIRS} >/dev/null 2>&1 - writelog "done" - fi - - exit "$1" -} - -# check for important files used -filecheck () -{ - filecheck=$(LANG=us ls -lh ${diskfile} 2>&1) - writelog "Filecheck:\n${filecheck}\n" - noimage=$(echo ${filecheck} | grep -i "no such file or directory" | wc -l) - rightsfile=${diskfile} - - # check if link - if [ -L "${diskfile}" ]; then - # take link target - rightsfile=$(ls -lh ${diskfile} 2>&1 | awk -F '-> *' '{print $2}') - rightsfile=${vmdir}/${rightsfile} - filecheck=$(LANG=us ls -lh ${rightsfile} 2>&1) - fi - - # does file exist - if [ "${noimage}" -ge "1" ]; then - writelog "Virtual Machine Image Problem:\c " - writelog "\tThe image you've specified doesn't exist." - writelog "Filecheck says:\c " - writelog "\t\t${diskfile}:\n\t\t\tNo such file or directory" - writelog "Hint:\c " - writelog "\t\t\tCompare spelling of the image with your options.\n" - exit 1 - fi - - # readable by calling user - if ! [ -r "${diskfile}" >/dev/null 2>&1 \ - -o -r "${diskfile}" >/dev/null 2>&1 ]; then - writelog "Vmware Image Problem:\c " - writelog "\tThe image you've specified has wrong rights." - writelog "Filecheck says:\t\t$(echo ${filecheck} \ - | awk '{print $1" "$3" "$4}') ${rightsfile}" - writelog "Hint:\t\t\tChange rights with: chmod a+r ${rightsfile}\n" - exit 1 - fi - - # writable (for persistent-mode)? - if ! [ -w "${diskfile}" >/dev/null 2>&1 \ - -o -w "${diskfile}" >/dev/null 2>&1 ] \ - && [ "${np}" = "independent-persistent" ]; then - writelog "Vmware Image Problem:\c " - writelog "\tThe image you have specified has wrong rights." - writelog "Filecheck says:\t\t$(echo ${filecheck} \ - | awk '{print $1" "$3" "$4}') ${rightsfile}" - writelog "Hint:\t\t\tUse nonpersistent-mode or change rights to rw\n" - exit 1 - fi -} - -################################################################################ -### Get XML file and dir -################################################################################ - -## Added for persistent support. -diskmode='nonpersistent' -xmlfile="$1" -if [[ "$(grep --extended-regexp '< *persistent *param=".+"' "$xmlfile")" ]]; then - imageFilePath="$(grep -io '/dev/null | grep '/' >/dev/null 2>&1; then - xmlpath=$(dirname "${xmlfile}") - xmlfile=$(basename "${xmlfile}") -else - xmlpath=${vmchooser_xmlpath} -fi -# full path -xmlfile="${xmlpath}/${xmlfile%.xml}.xml" - -DO_PROFILE="$(grep -c -E -i '<\s*profile\s*param="?(true|yes)"?' "$xmlfile")" - -################################################################################ -### Sanity checks -################################################################################ - -# test if the xml file is valid -if ! [ -r "${xmlfile}" ]; then - writelog "${xmlfile} not a readable XML file!" - exit 1 -fi - -# test if XML file -if ! grep '/dev/null 2>&1; then - writelog "Submitted configuration file ${xmlfile} seems to have wrong XML format" - exit 1 -fi - -# check for running in graphical environment otherwise no much use here -[ -z "$DISPLAY" ] && echo -e "\n\tStart only within a graphical desktop!\n" \ -&& exit 1 - -################################################################################ -### Logo for console -################################################################################ - -cat </dev/null | grep -q '^/' >/dev/null 2>&1; then - imgpath="$(dirname "${imgname}")" - imgname="$(basename "${imgname}")" - vmpath="${imgpath}/${imgname}" - # If old vmchooser binary stuff - # We do not need folder name as it is already included by vmchooser - elif echo "${xmlfile}" 2>/dev/null | grep -q '^/tmp/' >/dev/null 2>&1; then - vmpath="$imgname" - imgname="$(basename "${imgname}")" - ## Added for persistent support. - elif [[ "$userBranchFilePath" ]]; then - vmpath="$userBranchFilePath" - ## - # Else use same path as xml -else - imgpath="${xmlpath}" - vmpath="${imgpath}/${imgname}" -fi - -# Check if virtual machine container file exists -if ! [ -e "${vmpath}" ]; then - writelog "Virtual machine image ${vmpath} not found!" - exit 1 -fi - -# Name of the virt machine, sed because of Windows formatting -vm_name=$(grep -o 'short_description param=.*"' "${xmlfile}" \ -| sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') -# If ${vm_name} not defined use ${xmlfile} -vm_name="${vm_name:-${xmlfile%.xml}}" - -# Define vm_shortname since vm_name can be very long -vm_shortname="$(basename "${xmlfile%.xml}" | sed -e "s, ,-,g")" - -# vm_name = displayname, define for old scripts -displayname="${vm_name}" - -# image is for the following virtual machine -xmlvirt=$(grep -o 'virtualmachine param=.*"' "${xmlfile}" \ -| sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') - -# choose the proper virtualization/emulator plugin -[ "x${xmlvirt}" != "x" -a "x${xmlvirt}" != "xqemukvm" -a \ -"x${xmlvirt}" != "xvirtualbox" -a "x${xmlvirt}" != "xvmware" ] && \ -xmlvirt="emufe" - -# make a guess from the filename extension if ${xmlvirt} is empty -# (not set within the XML file) -# TODO: implement possibility to submit own configuration files -if [ -z "${xmlvirt}" ] && [ -n "${additional_config}" ]; then - writelog "No virtual machine parameter defined in ${xmlfile}" - writelog "Trying to guess VM...\c" - case "$(cat ${additional_config} | tr \"[A-Z]\" \"[a-z]\")" in - *config.version*|*virtualhw.version*|*independent-nonpersistent*|*vmdk*) - xmlvirt="vmware" - ;; - *innotek*|*virtualbox*) - xmlvirt="virtualbox" - ;; - *qemu*|*kvm*) - xmlvirt="qemukvm" - ;; - *) - xmlvirt="none" - ;; - esac - elif [ -z "${xmlvirt}" ]; then - case "$(echo ${imgname##*.} | tr \"[A-Z]\" \"[a-z]\")" in - vmdk) - xmlvirt="vmware" - ;; - vbox|vdi) - xmlvirt="virtualbox" - ;; - qcow*) - xmlvirt="qemukvm" - ;; - *) - xmlvirt="emufe" - ;; - esac - writelog "result:\t${xmlvirt}" -fi - -# Definition of the client system -vmostype=$(grep -io '/dev/null | \ -awk -F '=' {'print $2'} | tr "[A-Z]" "[a-z]") - -# Add rw share -sharepath="${HOME}" -sharename="home" - -# Set hostname: using original hostname and adding string -hostname="virt-$(hostname)" - -writelog "\tVM Hostname:\t\t$hostname" - -################################################################################ -### Setup the rest of the environment and run the configured vm -################################################################################ -# 8086:1e20 -if lspci -n | grep -E -i '8086:1e20( |$)'; then - VOL="100%" # bwPC 4: Speaker too quiet :-( -else - VOL="80%" -fi -# Adjust sound volume -#writelog "Unmuting sound...\c " -amixer -q sset Master "$VOL" unmute 2>/dev/null -amixer -q sset PCM "$VOL" unmute 2>/dev/null -amixer -q sset CD "$VOL" unmute 2>/dev/null -amixer -q sset Headphone "$VOL" unmute 2>/dev/null -amixer -q sset Front "$VOL" unmute 2>/dev/null # in SUSE 11.0 it's headphone -amixer -q sset Speaker "$VOL" unmute 2>/dev/null # annoying built-in speaker -#writelog "finished\n" - -# Load kvm modules -if [ "$vtflag" = "1" -a -n "$kvm_module" ]; then - modprobe "$kvm_module" -fi - -# Copy guest configuration (with added information) config.xml to be accessed -# via virtual floppy -cp "$xmlfile" "/etc/openslx/vmchooser/fd-loop/config.xml" -# Add another file with resolution information -xrandr | grep -o -E 'current\s*[0-9]+\s*x\s*[0-9]+' | cut -c 8- | sed -r 's/(\s|\t|\n)//g' | head -n 1 > "/etc/openslx/vmchooser/fd-loop/hostres.txt" - -# Get all virtual machine specific stuff from the respective include file -if [ -e /etc/openslx/"${xmlvirt}"/run-virt.include ] ; then - self="${xmlvirt}" - . /etc/openslx/"${xmlvirt}"/run-virt.include - # start a windowmanager for easier handling - # (expect problems /w windows opening in background /w vmware without wm) - for dm in twm xfwm4 metacity openbox blackbox kwin fvwm2 ; do - if which $dm >/dev/null 2>&1 ; then - if [ "$dm" = "fvwm2" ] ; then - echo "EdgeScroll 0 0" > ${redodir}/fvwm - fvwm2 -f ${redodir}/fvwm >/dev/null 2>&1 & - else - $dm >/dev/null 2>&1 & - fi - break - fi - done - # Start poolvideoswitch if we find the autostarter file - #if [ -e /etc/xdg/autostart/pvsgui.desktop ]; then - # /usr/local/bin/pvsgui -p 2 -b >/dev/null 2>&1 & - #fi - if [[ "$DO_PROFILE" -ge "1" ]]; then - wget "http://132.230.8.113/profile/do.php?action=start" - fi - eval ${VIRTCMD} ${VIRTCMDOPTS} - writelog "Bye." - - # Postrun for commands after virtualization finishes - if [ -n "${POSTRUN}" ]; then - eval ${POSTRUN} >/dev/null 2>&1 - fi - - cleanexit 0 -else - writelog "Failed because of missing ${xmlvirt} plugin." - cleanexit 1 -fi - -# Postrun for commands after virtualization finishes -if [ -n "${POSTRUN}" ]; then - eval ${POSTRUN} >/dev/null 2>&1 -fi - -cleanexit 0 -exit 0 diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-mount_vm_store b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-mount_vm_store index 27a8f55c..75af39fe 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-mount_vm_store +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-mount_vm_store @@ -2,7 +2,5 @@ . /opt/openslx/config || exit 1 -export PATH="$PATH:/opt/openslx/bin:/opt/openslx/usr/bin:/opt/openslx/sbin:/opt/openslx/usr/sbin" - -mkdir -p /var/lib/virt -mount -t nfs -o ro,async,nolock,vers=3 "$SLX_VM_NFS" /var/lib/virt +mkdir -p /mnt/vmstore +mount -t nfs -o ro,async,nolock,vers=3 "$SLX_VM_NFS" /mnt/vmstore diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env new file mode 100755 index 00000000..50eace20 --- /dev/null +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env @@ -0,0 +1,112 @@ +#!/bin/sh + +export PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin:/opt/openslx/usr/bin:/opt/openslx/usr/sbin + +#source config file with vars (e.g. ipaddr, macaddr, hostname) +. /opt/openslx/config + +#from plugins/vmchooser/40-started-hw-config/run-virt.sh +#TODO: extra systemd-service for hwinfo +hwinfo --cdrom | grep -i "Device File:" | awk {'print $3'} >/etc/openslx/hwinfo.cdrom +hwinfo --floppy | grep -i "Device File:" | awk {'print $3'} >/etc/openslx/hwinfo.floppy + +#from plugins/vmchooser/XX_vmchooser.sh +VMCHOOSER_CONF_DIR=/opt/openslx/etc/vmchooser + +mkdir -p ${VMCHOOSER_CONF_DIR}/loopimg +mkdir -p ${VMCHOOSER_CONF_DIR}/fd-loop -m 1777 + +# mount a clean tempfs (bug in UnionFS prevents loopmount to work) +grep -qE "unionfs |aufs " /proc/mounts && \ +mount -n -o size=1500k -t tmpfs vm-loopimg ${VMCHOOSER_CONF_DIR}/loopimg + +# create an empty floppy image of 1.4MByte size +dd if=/dev/zero of=${VMCHOOSER_CONF_DIR}/loopimg/fd.img count=2880 bs=512 2>/dev/null +chmod 0777 ${VMCHOOSER_CONF_DIR}/loopimg/fd.img + +# use dos formatter copied into stage3 +mkdosfs ${VMCHOOSER_CONF_DIR}/loopimg/fd.img >/dev/null 2>&1 #|| error +mount -n -t msdos -o loop,umask=000 ${VMCHOOSER_CONF_DIR}/loopimg/fd.img \ + ${VMCHOOSER_CONF_DIR}/fd-loop + +#pvs integration +#if [ $vmchooser_pvs -ne 0 ]; then +# sed -i /usr/share/xsessions/default.desktop \ +# -e "s,vmchooser$,vmchooser --pvs," +#fi + +# setup more scratch space for virtual machines, if configured +mkdir -p /tmp/virt +mkdir -p /var/log/samba + +# enable normal users to setup the extended virtual machine redo file space +# and image source via network block device (NBD only at the moment) +# allow to start/stop samba on virtual devices (latter one ignores multiple +# independent daemons) + +#cat >> /mnt/etc/sudoers << EOF +# allow to start and stop the special /tmp redo file space (RAM + NBD/NFS server RAID) +#ALL ALL=NOPASSWD: /sbin/losetup /dev/loop* +#ALL ALL=NOPASSWD: /sbin/mdadm -C /dev/md0 -l linear --raid-devices=2 /dev/loop* /dev/* +#ALL ALL=NOPASSWD: /opt/openslx/rootfs/usr/sbin/nbd-client * * /dev/nbd* +# allow to configure and start/stop samba services +#ALL ALL=NOPASSWD: /opt/openslx/rootfs/bin/sed -i /etc/*/smb.conf -e * +#ALL ALL=NOPASSWD: /usr/sbin/nmbd -s /etc/*/smb.conf +#ALL ALL=NOPASSWD: /usr/sbin/smbd -s /etc/*/smb.conf +#ALL ALL=NOPASSWD: /opt/openslx/rootfs/usr/bin/killall nmbd smbd +#EOF + +#from plugins/vmchooser/80-after-plugins/virtualization.sh + +# change free mem +mem_free=$(grep -i "^memfree:" /proc/meminfo | awk '{print $2}') +mem_cached=$(grep -i "^cached:" /proc/meminfo | awk '{print $2}') +mem_swapcached=$(grep -i "^swapcached:" /proc/meminfo | awk '{print $2}') +[ -z "$mem_free" ] && mem_free="2048000" +[ -z "$mem_cached" ] && mem_cached="0" +[ -z "$mem_swapcached" ] && mem_swapcached="0" +totalmem="$[ ( $mem_free + $mem_cached + $mem_swapcached ) / 1024 ]" +echo "totalmem=${totalmem}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf + +# cpu cores +CPU_CORES=$(grep '^processor.*:' /proc/cpuinfo | wc -l) +if [ "${CPU_CORES}" -gt "1" 2>/dev/null ]; then + echo "cpu_cores=${CPU_CORES}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf +else + echo 'cpu_cores=1' >> ${VMCHOOSER_CONF_DIR}/virtualization.conf +fi + +# arch +echo "host_arch=$(uname -m)" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf + +# VT enabled cpu? +if grep -q ^flags.*\\\ /proc/cpuinfo; then + echo "vtflag=1" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf + echo 'kvm_module="kvm_intel"' >> ${VMCHOOSER_CONF_DIR}/virtualization.conf + elif grep -q ^flags.*\\\ /proc/cpuinfo; then + echo "vtflag=1" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf + echo 'kvm_module="kvm_amd"' >> ${VMCHOOSER_CONF_DIR}/virtualization.conf + else + echo "vtflag=0" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf +fi + +# write mac +echo "hostmacaddr=${SLX_PXE_MAC}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf +# ip addr +echo "hostip=${SLX_PXE_CLIENT_IP}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf +# hostname +echo "hostname=${SLX_HOSTNAME}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf + +# get further hw information +j=0 +for i in $(cat /etc/openslx/hwinfo.cdrom); do + echo "cdrom_$j=$i" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf + j=$(expr $j + 1) +done + +j=0 +for i in $(cat /etc/openslx/hwinfo.floppy); do + echo "floppy_$j=$i" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf + j=$(expr $j + 1) +done + diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt new file mode 100755 index 00000000..874669dd --- /dev/null +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt @@ -0,0 +1,464 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Copyright (c) 2007..2010 - RZ Uni FR +# Copyright (c) 2007..2011 - 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.sh +# - This is the generic wrapper for the several virtualization solutions. +# The idea is to setup a set of variables used by at least two different +# tools and then include the specific plugin which configures the speci- +# fied virtualization tool. +################################################################################ + +################################################################################ +### Define default dirs / get configs +################################################################################ + +# include general configuration from vmchooser +[ -f /opt/openslx/etc/vmchooser/vmchooser.conf ] && \ +. /opt/openslx/etc/vmchooser/vmchooser.conf +# load general virtualization information +[ -f /opt/openslx/etc/vmchooser/virtualization.conf ] && \ +. /opt/openslx/etc/vmchooser/virtualization.conf + +################################################################################ +### Functions used throughout the script +################################################################################ + +# function to write to stdout and logfile +LOGFILE=/var/log/openslx/run-virt.${USER}.$$.log +writelog () { + # write to stdout + echo -e "$1" + # log into file + echo -e "$1" >> ${LOGFILE} +} + +# remove config dirs when exit +cleanexit () { + if echo "${RMDIRS}" 2>/dev/null | grep -q ${xmlvirt}; then + writelog "${xmlvirt} exited. Cleanning up... \c" + rm -rf ${RMDIRS} >/dev/null 2>&1 + writelog "done" + fi + + exit "$1" +} + +# check for important files used +filecheck () +{ + filecheck=$(LANG=us ls -lh ${diskfile} 2>&1) + writelog "Filecheck:\n${filecheck}\n" + noimage=$(echo ${filecheck} | grep -i "no such file or directory" | wc -l) + rightsfile=${diskfile} + + # check if link + if [ -L "${diskfile}" ]; then + # take link target + rightsfile=$(ls -lh ${diskfile} 2>&1 | awk -F '-> *' '{print $2}') + rightsfile=${vmdir}/${rightsfile} + filecheck=$(LANG=us ls -lh ${rightsfile} 2>&1) + fi + + # does file exist + if [ "${noimage}" -ge "1" ]; then + writelog "Virtual Machine Image Problem:\c " + writelog "\tThe image you've specified doesn't exist." + writelog "Filecheck says:\c " + writelog "\t\t${diskfile}:\n\t\t\tNo such file or directory" + writelog "Hint:\c " + writelog "\t\t\tCompare spelling of the image with your options.\n" + exit 1 + fi + + # readable by calling user + if ! [ -r "${diskfile}" >/dev/null 2>&1 \ + -o -r "${diskfile}" >/dev/null 2>&1 ]; then + writelog "Vmware Image Problem:\c " + writelog "\tThe image you've specified has wrong rights." + writelog "Filecheck says:\t\t$(echo ${filecheck} \ + | awk '{print $1" "$3" "$4}') ${rightsfile}" + writelog "Hint:\t\t\tChange rights with: chmod a+r ${rightsfile}\n" + exit 1 + fi + + # writable (for persistent-mode)? + if ! [ -w "${diskfile}" >/dev/null 2>&1 \ + -o -w "${diskfile}" >/dev/null 2>&1 ] \ + && [ "${np}" = "independent-persistent" ]; then + writelog "Vmware Image Problem:\c " + writelog "\tThe image you have specified has wrong rights." + writelog "Filecheck says:\t\t$(echo ${filecheck} \ + | awk '{print $1" "$3" "$4}') ${rightsfile}" + writelog "Hint:\t\t\tUse nonpersistent-mode or change rights to rw\n" + exit 1 + fi +} + +################################################################################ +### Get XML file and dir +################################################################################ + +## Added for persistent support. +diskmode='nonpersistent' +xmlfile="$1" +if [[ "$(grep --extended-regexp '< *persistent *param=".+"' "$xmlfile")" ]]; then + imageFilePath="$(grep -io '/dev/null | grep '/' >/dev/null 2>&1; then + xmlpath=$(dirname "${xmlfile}") + xmlfile=$(basename "${xmlfile}") +else + xmlpath=${vmchooser_xmlpath} +fi +# full path +xmlfile="${xmlpath}/${xmlfile%.xml}.xml" + +DO_PROFILE="$(grep -c -E -i '<\s*profile\s*param="?(true|yes)"?' "$xmlfile")" + +################################################################################ +### Sanity checks +################################################################################ + +# test if the xml file is valid +if ! [ -r "${xmlfile}" ]; then + writelog "${xmlfile} not a readable XML file!" + exit 1 +fi + +# test if XML file +if ! grep '/dev/null 2>&1; then + writelog "Submitted configuration file ${xmlfile} seems to have wrong XML format" + exit 1 +fi + +# check for running in graphical environment otherwise no much use here +[ -z "$DISPLAY" ] && echo -e "\n\tStart only within a graphical desktop!\n" \ +&& exit 1 + +################################################################################ +### Logo for console +################################################################################ + +cat </dev/null | grep -q '^/' >/dev/null 2>&1; then + imgpath="$(dirname "${imgname}")" + imgname="$(basename "${imgname}")" + vmpath="${imgpath}/${imgname}" + # If old vmchooser binary stuff + # We do not need folder name as it is already included by vmchooser + elif echo "${xmlfile}" 2>/dev/null | grep -q '^/tmp/' >/dev/null 2>&1; then + vmpath="$imgname" + imgname="$(basename "${imgname}")" + ## Added for persistent support. + elif [[ "$userBranchFilePath" ]]; then + vmpath="$userBranchFilePath" + ## + # Else use same path as xml +else + imgpath="${xmlpath}" + vmpath="${imgpath}/${imgname}" +fi + +# Check if virtual machine container file exists +if ! [ -e "${vmpath}" ]; then + writelog "Virtual machine image ${vmpath} not found!" + exit 1 +fi + +# Name of the virt machine, sed because of Windows formatting +vm_name=$(grep -o 'short_description param=.*"' "${xmlfile}" \ +| sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') +# If ${vm_name} not defined use ${xmlfile} +vm_name="${vm_name:-${xmlfile%.xml}}" + +# Define vm_shortname since vm_name can be very long +vm_shortname="$(basename "${xmlfile%.xml}" | sed -e "s, ,-,g")" + +# vm_name = displayname, define for old scripts +displayname="${vm_name}" + +# image is for the following virtual machine +xmlvirt=$(grep -o 'virtualmachine param=.*"' "${xmlfile}" \ +| sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') + +# choose the proper virtualization/emulator plugin +[ "x${xmlvirt}" != "x" -a "x${xmlvirt}" != "xqemukvm" -a \ +"x${xmlvirt}" != "xvirtualbox" -a "x${xmlvirt}" != "xvmware" ] && \ +xmlvirt="emufe" + +# make a guess from the filename extension if ${xmlvirt} is empty +# (not set within the XML file) +# TODO: implement possibility to submit own configuration files +if [ -z "${xmlvirt}" ] && [ -n "${additional_config}" ]; then + writelog "No virtual machine parameter defined in ${xmlfile}" + writelog "Trying to guess VM...\c" + case "$(cat ${additional_config} | tr \"[A-Z]\" \"[a-z]\")" in + *config.version*|*virtualhw.version*|*independent-nonpersistent*|*vmdk*) + xmlvirt="vmware" + ;; + *innotek*|*virtualbox*) + xmlvirt="virtualbox" + ;; + *qemu*|*kvm*) + xmlvirt="qemukvm" + ;; + *) + xmlvirt="none" + ;; + esac + elif [ -z "${xmlvirt}" ]; then + case "$(echo ${imgname##*.} | tr \"[A-Z]\" \"[a-z]\")" in + vmdk) + xmlvirt="vmware" + ;; + vbox|vdi) + xmlvirt="virtualbox" + ;; + qcow*) + xmlvirt="qemukvm" + ;; + *) + xmlvirt="emufe" + ;; + esac + writelog "result:\t${xmlvirt}" +fi + +# Definition of the client system +vmostype=$(grep -io '/dev/null | \ +awk -F '=' {'print $2'} | tr "[A-Z]" "[a-z]") + +# Add rw share +sharepath="${HOME}" +sharename="home" + +# Set hostname: using original hostname and adding string +hostname="virt-$(hostname)" + +writelog "\tVM Hostname:\t\t$hostname" + +################################################################################ +### Setup the rest of the environment and run the configured vm +################################################################################ +# 8086:1e20 +if lspci -n | grep -E -i '8086:1e20( |$)'; then + VOL="100%" # bwPC 4: Speaker too quiet :-( +else + VOL="80%" +fi +# Adjust sound volume +#writelog "Unmuting sound...\c " +amixer -q sset Master "$VOL" unmute 2>/dev/null +amixer -q sset PCM "$VOL" unmute 2>/dev/null +amixer -q sset CD "$VOL" unmute 2>/dev/null +amixer -q sset Headphone "$VOL" unmute 2>/dev/null +amixer -q sset Front "$VOL" unmute 2>/dev/null # in SUSE 11.0 it's headphone +amixer -q sset Speaker "$VOL" unmute 2>/dev/null # annoying built-in speaker +#writelog "finished\n" + +# Load kvm modules +if [ "$vtflag" = "1" -a -n "$kvm_module" ]; then + modprobe "$kvm_module" +fi + +# Copy guest configuration (with added information) config.xml to be accessed +# via virtual floppy +cp "$xmlfile" "/opt/openslx/etc/vmchooser/fd-loop/config.xml" +# Add another file with resolution information +xrandr | grep -o -E 'current\s*[0-9]+\s*x\s*[0-9]+' | cut -c 8- | sed -r 's/(\s|\t|\n)//g' | head -n 1 > "/opt/openslx/etc/vmchooser/fd-loop/hostres.txt" + +# Get all virtual machine specific stuff from the respective include file +if [ -e /opt/openslx/etc/"${xmlvirt}"/run-virt.include ] ; then + self="${xmlvirt}" + . /opt/openslx/etc/"${xmlvirt}"/run-virt.include + # start a windowmanager for easier handling + # (expect problems /w windows opening in background /w vmware without wm) + for dm in twm xfwm4 metacity openbox blackbox kwin fvwm2 ; do + if which $dm >/dev/null 2>&1 ; then + if [ "$dm" = "fvwm2" ] ; then + echo "EdgeScroll 0 0" > ${redodir}/fvwm + fvwm2 -f ${redodir}/fvwm >/dev/null 2>&1 & + else + $dm >/dev/null 2>&1 & + fi + break + fi + done + # Start poolvideoswitch if we find the autostarter file + #if [ -e /etc/xdg/autostart/pvsgui.desktop ]; then + # /usr/local/bin/pvsgui -p 2 -b >/dev/null 2>&1 & + #fi + if [[ "$DO_PROFILE" -ge "1" ]]; then + wget "http://132.230.8.113/profile/do.php?action=start" + fi + eval ${VIRTCMD} ${VIRTCMDOPTS} + writelog "Bye." + + # Postrun for commands after virtualization finishes + if [ -n "${POSTRUN}" ]; then + eval ${POSTRUN} >/dev/null 2>&1 + fi + + cleanexit 0 +else + writelog "Failed because of missing ${xmlvirt} plugin." + cleanexit 1 +fi + +# Postrun for commands after virtualization finishes +if [ -n "${POSTRUN}" ]; then + eval ${POSTRUN} >/dev/null 2>&1 +fi + +cleanexit 0 +exit 0 diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter new file mode 100755 index 00000000..67e49d3e --- /dev/null +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter @@ -0,0 +1,64 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Copyright (c) 2007..2009 - RZ Uni FR +# Copyright (c) 2007..2011 - 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/ +# ----------------------------------------------------------------------------- +# xmlfilter.sh +# - This script is invoked by the vmchooser tool. It simply filters xml- +# files (taking the path to these files in $1). You might modify it in any +# way to match your needs, e.g. ask some database instead. You can re- +# implement it in any other programming language too. You simply have to +# return a list of proper xml files to be interpreted by the vmchooser +# binary). Please check for vmchooser.sh too ... +# ----------------------------------------------------------------------------- + +# This script . +# +# currently: +# - filter for slxgrp (which comes from /etc/machine-setup) +# + +# include default directories +. /etc/opt/openslx/openslx.conf + +if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf ]; then + . ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf +fi + +function handlePersistentVM() { + if [[ "$(grep --extended-regexp \ + " /dev/null + pinfo "Running cmake" + cmake $CMAKE_ARGS $SRCDIR || perror "'cmake $CMAKE_ARGS $SRCDIR' failed." + make || perror "'make' failed." + cd - &> /dev/null } post_copy() { diff --git a/remote/modules/vmplayer/data/etc/openslx/vmware/nvram b/remote/modules/vmplayer/data/etc/openslx/vmware/nvram deleted file mode 100644 index 85125f1e..00000000 Binary files a/remote/modules/vmplayer/data/etc/openslx/vmware/nvram and /dev/null differ diff --git a/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include b/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include deleted file mode 100644 index 71d294cb..00000000 --- a/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include +++ /dev/null @@ -1,619 +0,0 @@ -# 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 "/etc/openslx/vmware/nvram" "$confdir/nvram" 2>/dev/null - - -# logging and stdout -################################################################################ - -# log script information -writelog "# File created by $0 (VMversion ${vmversion})\n# on $(date)\n" -writelog "Starting with non-persistent 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 - -# using the modified version of the wrapper script -VIRTCMD="/opt/openslx/bin/vmplayer" -VIRTCMDOPTS="${vmopt} ${conffile}" -RMDIRS="${redodir} ${conffile}" diff --git a/remote/modules/vmplayer/data/etc/openslx/vmware/vmware-env b/remote/modules/vmplayer/data/etc/openslx/vmware/vmware-env deleted file mode 100755 index feff5135..00000000 --- a/remote/modules/vmplayer/data/etc/openslx/vmware/vmware-env +++ /dev/null @@ -1,281 +0,0 @@ -#!/bin/sh -# Copyright (c) 2009 - 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/ -# ----------------------------------------------------------------------------- - -export PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin:/opt/openslx/usr/bin:/opt/openslx/usr/sbin - -VMWARE_CONF_DIR=/etc/openslx/vmware - -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 - -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 -} - -load_modules () { - # 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 -} - -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 - $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid -n 0 -fi -if [ -n "$vmnet1" ] ; then - $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \ - /dev/vmnet1 vmnet1 - 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 -fi -if [ -n "$vmnet8" ] ; then - $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet8.pid \ - /dev/vmnet8 vmnet8 - 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 - $location/vmnet-natd -d /var/run/vmnet-natd-8.pid \ - -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 - -} - -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 - 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 - ;; - stop) - #stop: defines stop function for initscript - killall vmnet-netifup vmnet-natd vmnet-bridge vmware vmplayer \ - vmware-tray vmnet-dhcpd - # might take a while until all services are shut down - sleep 1 - umount -l /tmp/vmware 2>/dev/null - unload_modules - - ;; - restart) - #restart: defines restart function for initscript - $0 stop && $0 start - ;; - status) - #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/vmplayer/data/etc/openslx/vmware/vmware.conf b/remote/modules/vmplayer/data/etc/openslx/vmware/vmware.conf deleted file mode 100644 index 210b814f..00000000 --- a/remote/modules/vmplayer/data/etc/openslx/vmware/vmware.conf +++ /dev/null @@ -1,8 +0,0 @@ -#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" diff --git a/remote/modules/vmplayer/data/etc/systemd/system/vmware.service b/remote/modules/vmplayer/data/etc/systemd/system/vmware.service index 6bffb508..30bb42ff 100644 --- a/remote/modules/vmplayer/data/etc/systemd/system/vmware.service +++ b/remote/modules/vmplayer/data/etc/systemd/system/vmware.service @@ -6,4 +6,4 @@ After=vmchooser.service [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/etc/openslx/vmware/vmware-env start +ExecStart=/opt/openslx/scripts/systemd-vmware_env start diff --git a/remote/modules/vmplayer/data/opt/openslx/etc/vmware/nvram b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/nvram new file mode 100644 index 00000000..85125f1e Binary files /dev/null and b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/nvram differ diff --git a/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include new file mode 100644 index 00000000..675835a9 --- /dev/null +++ b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include @@ -0,0 +1,619 @@ +# 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" +writelog "Starting with non-persistent 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 + +# using the modified version of the wrapper script +VIRTCMD="/opt/openslx/bin/vmplayer" +VIRTCMDOPTS="${vmopt} ${conffile}" +RMDIRS="${redodir} ${conffile}" diff --git a/remote/modules/vmplayer/data/opt/openslx/etc/vmware/vmware.conf b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/vmware.conf new file mode 100644 index 00000000..210b814f --- /dev/null +++ b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/vmware.conf @@ -0,0 +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 +version="5.0" +buildversion="1031769" diff --git a/remote/modules/vmplayer/data/opt/openslx/scripts/systemd-vmware_env b/remote/modules/vmplayer/data/opt/openslx/scripts/systemd-vmware_env new file mode 100755 index 00000000..4103eae6 --- /dev/null +++ b/remote/modules/vmplayer/data/opt/openslx/scripts/systemd-vmware_env @@ -0,0 +1,281 @@ +#!/bin/sh +# Copyright (c) 2009 - 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/ +# ----------------------------------------------------------------------------- + +export PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin:/opt/openslx/usr/bin:/opt/openslx/usr/sbin + +VMWARE_CONF_DIR=/opt/openslx/etc/vmware + +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 + +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 +} + +load_modules () { + # 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 +} + +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 + $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid -n 0 +fi +if [ -n "$vmnet1" ] ; then + $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \ + /dev/vmnet1 vmnet1 + 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 +fi +if [ -n "$vmnet8" ] ; then + $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet8.pid \ + /dev/vmnet8 vmnet8 + 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 + $location/vmnet-natd -d /var/run/vmnet-natd-8.pid \ + -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 + +} + +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 + 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 + ;; + stop) + #stop: defines stop function for initscript + killall vmnet-netifup vmnet-natd vmnet-bridge vmware vmplayer \ + vmware-tray vmnet-dhcpd + # might take a while until all services are shut down + sleep 1 + umount -l /tmp/vmware 2>/dev/null + unload_modules + + ;; + restart) + #restart: defines restart function for initscript + $0 stop && $0 start + ;; + status) + #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 + -- cgit v1.2.3-55-g7522