diff options
8 files changed, 25 insertions, 35 deletions
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_variables.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_variables.inc index 9525a290..f0aae889 100644 --- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_variables.inc +++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_variables.inc @@ -5,6 +5,10 @@ VMCHOOSER_DIR="/opt/openslx/vmchooser" VMCHOOSER_CONF_DIR="$VMCHOOSER_DIR/config" LOGFILE="/var/log/openslx/run-virt.${USER}.$$.log" +TMPDIR="/tmp/virt/$(whoami)" +USER="$(whoami)" + +readonly VMCHOOSER_DIR VMCHOOSER_CONF_DIR LOGFILE TMPDIR USER # include general configuration from vmchooser [ -f "$VMCHOOSER_CONF_DIR/vmchooser.conf" ] && . "$VMCHOOSER_CONF_DIR/vmchooser.conf" @@ -12,3 +16,6 @@ LOGFILE="/var/log/openslx/run-virt.${USER}.$$.log" [ -f "$VMCHOOSER_CONF_DIR/virtualization.conf" ] && . "$VMCHOOSER_CONF_DIR/virtualization.conf" # Load general openslx config [ -f "/opt/openslx/config" ] && . "/opt/openslx/config" +# Create temp dir +mkdir -p "$TMPDIR" # TODO error out if failed + diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc index 806423cc..e84486cf 100644 --- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc +++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc @@ -14,13 +14,11 @@ elif [ -z "$SLX_DNBD3_SERVERS" ] || [ "x$SLX_VM_DNBD3" != "xyes" ]; then writelog "Can't use dnbd3 as no servers are given in config, or SLX_VM_DNBD3 is not set to yes" else # Mount path for images mounted with dnbd3-fuse - dnbd3_fuse_mount_point="/tmp/virt/${USER}.fuse" + dnbd3_fuse_mount_point="$TMPDIR/dnbd3fuse.mnt" mkdir -p "${dnbd3_fuse_mount_point}" - # try to unmount first - fusermount -u "${dnbd3_fuse_mount_point}" # start dnbd3-fuse in subshell ( - tmplog="$(mktemp)" + tmplog="$TMPDIR/dnbd3fuse.log" [ -z "$tmplog" ] && tmplog="/tmp/dnbd3-fuse.$$.$RANDOM.$USER" dnbd3-fuse -f -o allow_other,max_readahead=262144 -h "$SLX_DNBD3_SERVERS" -i "${imgrelpath}" "${dnbd3_fuse_mount_point}" > "$tmplog" 2>&1 RET=$? diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_printer_lpd.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_printer_lpd.inc index ab010722..ee0b2c70 100644 --- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_printer_lpd.inc +++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_printer_lpd.inc @@ -3,7 +3,6 @@ ##################################### QUEUE="STANDARD" # This has to match the queue you configured in your VM -USER="$(whoami)" SPOOLDIR= ### Disabled: 100megs is not enough, some jobs are HUGE, try to use temp which should be on disk @@ -15,7 +14,7 @@ SPOOLDIR= # If failed, try to fall back to /tmp if [ -z "${SPOOLDIR}" ] || [ ! -w "${SPOOLDIR}/${QUEUE}" ]; then - SPOOLDIR="/tmp/printergui-${USER}-$$-${RANDOM}" + SPOOLDIR="${TMPDIR}/printergui-${RANDOM}" rm -rf -- "${SPOOLDIR}" if ! mkdir -p "${SPOOLDIR}/${QUEUE}"; then slxlog "virt-spooldir" "Could not create spool directory ($SPOOLDIR) for $USER - printing will not work!" diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc index f20b799f..b85bb32c 100644 --- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc +++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc @@ -14,24 +14,22 @@ writelog() { # Clean exit will be called at the end of vmchooser-run_virt cleanexit() { sleep 1 - # remove config dirs when exit - if echo "${RMDIRS}" 2>/dev/null | grep -q "${xmlvirt}"; then - writelog "${xmlvirt} exited. Cleaning up... \c" -# rm -rf -- ${RMDIRS} >/dev/null 2>&1 - writelog "done" - fi # Ummount dnbd3-fuse if [ -n "$dnbd3_fuse_mount_point" ] && [ -e "$dnbd3_fuse_mount_point/img" ]; then - for timeout in 1 1 2; do + for timeout in 1 1 1 FAIL; do fusermount -u "$dnbd3_fuse_mount_point" && break writelog "dnbd3 still busy...." + [ "$timeout" = "FAIL" ] && break sleep "$timeout" done fi # Kill LPD - [ -n "$PID_LPD" ] && kill "$PID_LPD" - # Remove spool directory for printjobs from VM - [ -n "${SPOOLDIR}" ] && rm -rf -- "${SPOOLDIR}" + [ -n "${PID_LPD}" ] && kill "${PID_LPD}" + + # If we're not in debug mode, remove all temporary files + if [ -n "${TMPDIR}" -a -z "$SLX_DEBUG" ]; then + rm -rf -- "${TMPDIR}" + fi [ $# -gt 0 ] && exit "$1" exit 129 # No exit code was given :/ diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt index 7d83844e..8e1bbd0d 100755 --- a/remote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt +++ b/remote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt @@ -23,7 +23,7 @@ RUNVIRTINCLUDEDIR=/opt/openslx/scripts/includes xmlfile="$1" # Functions needed by vmchooser-run_virt (writelog(), cleanexit(), rv_clean_string()) -source ${RUNVIRTINCLUDEDIR}/vmchooser_runvirt_functions.inc && trap cleanexit SIGINT SIGTERM +source ${RUNVIRTINCLUDEDIR}/vmchooser_runvirt_functions.inc && trap 'trap "" SIGINT SIGTERM; cleanexit' SIGINT SIGTERM # Define default dirs / get configs source ${RUNVIRTINCLUDEDIR}/set_runvirt_variables.inc # Function to detect whether we can use the new way (vmx via http) or the old way (legacy): diff --git a/remote/modules/vbox/data/opt/openslx/vmchooser/virtualbox/run-virt.include b/remote/modules/vbox/data/opt/openslx/vmchooser/virtualbox/run-virt.include index f35bc9d8..1b116f32 100755 --- a/remote/modules/vbox/data/opt/openslx/vmchooser/virtualbox/run-virt.include +++ b/remote/modules/vbox/data/opt/openslx/vmchooser/virtualbox/run-virt.include @@ -19,12 +19,13 @@ ################################################################################ VMCHOOSERVBOX="/opt/openslx/vmchooser/${self}" -TMPDIR=/tmp/virt/${self} # create TMPDIR for all users -mkdir -m 1777 ${TMPDIR} 2>/dev/null -confdir="/tmp/virt/${self}/${USER}/${VM_ID}" # dir for configs +confdir="${TMPDIR}/vbox" # dir for configs export VBOX_USER_HOME=${confdir} # instead of $HOME/.VirtualBox # define dirs and files which can be removed after exit, be carefull! -RMDIRS="${snapshotdir} ${confdir} /tmp/virt/.vbox-${USER}-ipc" +# TODO: Machanism not in use anymore. A better approach would be anyways to +# Define a fixed directory which can be deleted recursively on exit. $TMPDIR +# would be a start. +#RMDIRS="${snapshotdir} ${confdir} /tmp/virt/.vbox-${USER}-ipc" # rm -rf ${RMDIRS} 2>/dev/null machfolder="${confdir}/Machines" # use vm_shortname for dir and config names since vm_name can be very long @@ -205,7 +206,7 @@ if echo "${imgmode}" | grep -q rw; then cleanexit 1 fi touch "${vmpath}.lock" # add lock - RMDIRS="${RMDIRS} ${vmpath}.lock" # remove lock after VM stopped + #RMDIRS="${RMDIRS} ${vmpath}.lock" # remove lock after VM stopped TODO See note at the top imgtype="Normal" imageuuid=${diskuuid} # replace image uuid in machine config elif [ ${diskless} -eq 0 ]; then @@ -432,5 +433,4 @@ VIRTCMDOPTS="--startvm ${machineuuid} --start-running --fullscreen" # set headless mode (-v off to disable vrdp) VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) VIRTCMDOPTSHL="-s ${machineuuid}" -RMDIRS="${TMPDIR}" diff --git a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_vmware_include_variables.inc b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_vmware_include_variables.inc index 5a5d1132..0c45ee59 100644 --- a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_vmware_include_variables.inc +++ b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_vmware_include_variables.inc @@ -5,17 +5,6 @@ set_vmware_include_variables() { [ "$mem" -gt 3800 -a "$(uname -m)" != "x86_64" ] && mem=3800 - # VM-ID static (0D), remove if changed to 00 - VM_ID="0D" - - # should be dynamic - if [ "x$(which bc)" != "x" ]; then - VM_ID=$(echo "obase=16; $$" | bc) - VM_ID=$(expr substr $VM_ID $(expr ${#VM_ID} - 1) 2) - else - VM_ID=$[ $$ % 100 ] - fi - # temporary disk space for logs, etc... redodir="/tmp/virt/vmware/${USER}.$$" diff --git a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include index a823df72..f63092bd 100644 --- a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include +++ b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include @@ -68,5 +68,4 @@ cp "$conffile" "/tmp/vmware-last-config" # using the modified version of the wrapper script VIRTCMD="/opt/openslx/bin/vmplayer" VIRTCMDOPTS="${vmopt} ${conffile}" -RMDIRS="${redodir} ${conffile}" |
