diff options
author | Simon Rettberg | 2013-12-02 14:33:10 +0100 |
---|---|---|
committer | Simon Rettberg | 2013-12-02 14:33:10 +0100 |
commit | 02b2d374548aa26a591ed5ae1467c892203c760d (patch) | |
tree | ae0e666875c4620f665ee12b2c4a9b47981644e1 /remote/modules/vmchooser | |
parent | Doc + comments ... (diff) | |
download | tm-scripts-02b2d374548aa26a591ed5ae1467c892203c760d.tar.gz tm-scripts-02b2d374548aa26a591ed5ae1467c892203c760d.tar.xz tm-scripts-02b2d374548aa26a591ed5ae1467c892203c760d.zip |
Checked and changed the shebang of some more scripts. As we want to use ash in out own scripts whenever possible, only use bash where the scripts require a certain bash feature. Also add a comment right below the bash shebang that says we're not accidentally using bash here, but for a reason.
Diffstat (limited to 'remote/modules/vmchooser')
4 files changed, 36 insertions, 33 deletions
diff --git a/remote/modules/vmchooser/data/opt/openslx/bin/clc.bash b/remote/modules/vmchooser/data/opt/openslx/bin/clc.bash index 7437c8d2..ee198c51 100755 --- a/remote/modules/vmchooser/data/opt/openslx/bin/clc.bash +++ b/remote/modules/vmchooser/data/opt/openslx/bin/clc.bash @@ -1,4 +1,5 @@ -#!/bin/ash +#!/bin/bash +# Needs full bash # region header diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc index 455d3707..337dee44 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc @@ -1,4 +1,4 @@ -#!/usr/bin/env busybox +#!/bin/bash # region header 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 5e997647..7e2eb5c5 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt @@ -1,4 +1,5 @@ #!/bin/bash +# Full bash required # ----------------------------------------------------------------------------- # Copyright (c) 2007..2010 - RZ Uni FR # Copyright (c) 2007..2011 - OpenSLX GmbH 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 15e4b8d7..5fd8acc5 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter @@ -1,4 +1,5 @@ -#!/bin/ash +#!/bin/bash +# Probably needs bash somewhere # ----------------------------------------------------------------------------- # Copyright (c) 2007..2009 - RZ Uni FR # Copyright (c) 2007..2011 - OpenSLX GmbH @@ -29,45 +30,45 @@ # include default directories . /opt/openslx/config -if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf ]; then - . ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.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 \ - "<persistent param=\"(|.+:)$USER(|:.+)\"" "$1")" ]]; then + if grep --extended-regexp -q "<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}" && \ + # TODO: This evil black magic needs to be rewritten some day (by someone who understands it) + local originalImagePath=$(grep -io '<image_name param=.*"' "$1" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }') + local imageName=$(basename "$originalImagePath") + 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" \ + local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename "$1")" + local vmchooserFilePath="$(dirname "$0")/vmchooser-clc" + if [ ! -f "$vmchooserFilePath" ]; then + vmchooserFilePath='/opt/openslx/scripts/vmchooser-clc' + fi + "$vmchooserFilePath" "$1" "$persistentConfigVersionFilePath" \ --create-persistent-config "$imagePath" && \ echo "$persistentConfigVersionFilePath" - fi - } + 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 "${SLX_VM_POOL_FILTER}" ]; then - # filter all xmls with pool-param not equal to vmchooser::env - if [ $(grep "<pools param=\"${SLX_VM_POOL_FILTER}\"" "$FILE" | wc -l) -eq 1 ]; then - handlePersistentVM "$FILE" - echo "$FILE" - fi - else +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 "${SLX_VM_POOL_FILTER}" ]; then + # filter all xmls with pool-param not equal to vmchooser::env + if [ $(grep "<pools param=\"${SLX_VM_POOL_FILTER}\"" "$FILE" | wc -l) -eq 1 ]; then handlePersistentVM "$FILE" - # if there is no pool set, just take all available xmls echo "$FILE" fi - done + else + handlePersistentVM "$FILE" + # if there is no pool set, just take all available xmls + echo "$FILE" + fi +done + |