diff options
| author | Simon Rettberg | 2013-10-18 18:46:11 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2013-10-18 18:46:11 +0200 |
| commit | 5027bfbc817dc5620bbc222a47074f99bd340692 (patch) | |
| tree | c7e37f7f2e2f2c87aae2e5cdaa4f1c246b73e1fa /remote/modules/vmchooser/data | |
| parent | [rootfs-stage32] Remove retarded $PATH declaration from /etc/profile (diff) | |
| parent | Merge branch 'master' of dnbd3:openslx-ng/tm-scripts (diff) | |
| download | tm-scripts-5027bfbc817dc5620bbc222a47074f99bd340692.tar.gz tm-scripts-5027bfbc817dc5620bbc222a47074f99bd340692.tar.xz tm-scripts-5027bfbc817dc5620bbc222a47074f99bd340692.zip | |
Merge branch 'master' of simonslx:openslx-ng/tm-scripts
Diffstat (limited to 'remote/modules/vmchooser/data')
| -rwxr-xr-x | remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt | 12 | ||||
| -rwxr-xr-x | remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter | 76 |
2 files changed, 48 insertions, 40 deletions
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt index ec860b3c..4a0ba8c6 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt @@ -428,6 +428,7 @@ if [ "$vtflag" = "1" -a -n "$kvm_module" ]; then modprobe "$kvm_module" fi + # # # # # # Start printer daemon # # # # # # # USER="$(whoami)" SPOOLDIR="/var/spool" @@ -436,7 +437,10 @@ QUEUE="STANDARD" # Start the lpdaemon listening on the given port busybox tcpsvd -E 0.0.0.0 5515 \ busybox lpd "$SPOOLDIR" \ - sh -c "printergui $USER $SPOOOLDIR/$QUEUE/\$DATAFILE" & + sh -c "printergui $USER $SPOOLDIR/$QUEUE/\$DATAFILE" & + +# PID to kill the process +PID_LPD="$!" # Copy guest configuration (with added information) config.xml to be accessed @@ -451,7 +455,7 @@ cp "/opt/openslx/etc/vmchooser/openslx.exe" "/opt/openslx/etc/vmchooser/fd-loop/ unset vm_diskfile unset vm_revision unset dnbd3 -if [ -n "$SLX_DNBD3_SERVERS" ]; then +if [ -n "$SLX_DNBD3_SERVERS" -a "x$SLX_VM_DNBD3" = "xyes" ]; then if [ -e "/dev/dnbd0" -a -e "/var/run/dnbd3.socket" ]; then # Shuffle server list TMP_SERVERS=$(for SRV in $SLX_DNBD3_SERVERS; do echo "$RANDOM $SRV"; done | sort -u | sed -r 's/^[0-9]+ //') @@ -527,5 +531,9 @@ if [ -n "${POSTRUN}" ]; then eval ${POSTRUN} >/dev/null 2>&1 fi +# Kill LPD +kill $PID_LPD + + 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 index 3e0ee42d..4faea740 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter @@ -30,44 +30,44 @@ . /opt/openslx/config if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf ]; then - . ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf + . ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf fi function handlePersistentVM() { - if [[ "$(grep --extended-regexp \ - "<persistent param=\"(|.+:)$USER(|:.+)\"" "$1")" ]]; then - # If this virtual machine is useable as persistent version for current - # user we provide an additional persistent version. - local imageName=$(basename "$(grep -io '<image_name param=.*"' "$1" | \ - sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')") && \ - eval export SLX_VM_PERSISTENT_PATH="${SLX_VM_PERSISTENT_PATH}" && \ - local imagePath="${SLX_VM_PERSISTENT_PATH}${imageName}" - local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename \ - "$1")" && \ - local vmchooserFilePath="$(dirname "$0")/vmchooser-clc" && \ - if [ ! -f "$vmchooserFilePath" ]; then - vmchooserFilePath='/opt/openslx/plugin-repo/vmchooser/vmchooser-clc' - fi - bash "$vmchooserFilePath" "$1" "$persistentConfigVersionFilePath" \ - --create-persistent-config "$imagePath" && \ - echo "$persistentConfigVersionFilePath" - fi -} - -for FILE in $(find -L "$1" -iname "*.xml"); do - # filter all xmls which aren't set active - if [ $(grep "<active param=.*true.*" "$FILE" | wc -l) -eq 1 ]; then - if [ -n "${vmchooser_env}" ]; then - # filter all xmls with pool-param not equal to vmchooser::env - if [ $(grep "<pools param=\"${vmchooser_env}\"" "$FILE" | wc -l) -eq 1 ] - then - handlePersistentVM "$FILE" - echo "$FILE" - fi - else - handlePersistentVM "$FILE" - # if there is no pool set, just take all available xmls - echo "$FILE" - fi - fi -done + if [[ "$(grep --extended-regexp \ + "<persistent param=\"(|.+:)$USER(|:.+)\"" "$1")" ]]; then + # If this virtual machine is useable as persistent version for current + # user we provide an additional persistent version. + local imageName=$(basename "$(grep -io '<image_name param=.*"' "$1" | \ + sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')") && \ + eval export SLX_VM_PERSISTENT_PATH="${SLX_VM_PERSISTENT_PATH}" && \ + local imagePath="${SLX_VM_PERSISTENT_PATH}${imageName}" + local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename \ + "$1")" && \ + local vmchooserFilePath="$(dirname "$0")/vmchooser-clc" && \ + if [ ! -f "$vmchooserFilePath" ]; then + vmchooserFilePath='/opt/openslx/plugin-repo/vmchooser/vmchooser-clc' + fi + bash "$vmchooserFilePath" "$1" "$persistentConfigVersionFilePath" \ + --create-persistent-config "$imagePath" && \ + echo "$persistentConfigVersionFilePath" + fi + } + + for FILE in $(find -L "$1" -iname "*.xml"); do + # filter all xmls which aren't set active + grep -i -q "<active param=.*true.*" "$FILE" || continue + # HACK: filter all virtualbox images, as vbox is not ready yet + grep -i -q "<virtualmachine param=.*virtualbox.*" "$FILE" && continue + if [ -n "${vmchooser_env}" ]; then + # filter all xmls with pool-param not equal to vmchooser::env + if [ $(grep "<pools param=\"${vmchooser_env}\"" "$FILE" | wc -l) -eq 1 ]; then + handlePersistentVM "$FILE" + echo "$FILE" + fi + else + handlePersistentVM "$FILE" + # if there is no pool set, just take all available xmls + echo "$FILE" + fi + done |
