diff options
| -rwxr-xr-x | remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter | 76 |
1 files changed, 38 insertions, 38 deletions
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 fad8c064..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 - 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 + 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 |
