diff options
author | Jonathan Bauer | 2019-12-18 17:52:06 +0100 |
---|---|---|
committer | Jonathan Bauer | 2019-12-18 17:52:06 +0100 |
commit | 1ea9558daf64c70cb224a1e41eb15e4543b96373 (patch) | |
tree | 46cd1ff1dc02fcb2f81bd173177ef146d8bae0b2 | |
parent | [rfs-s32] only check for GPT part type (diff) | |
download | mltk-1ea9558daf64c70cb224a1e41eb15e4543b96373.tar.gz mltk-1ea9558daf64c70cb224a1e41eb15e4543b96373.tar.xz mltk-1ea9558daf64c70cb224a1e41eb15e4543b96373.zip |
[run-virt] fix bad VM_IDs
since /opt/openslx/scripts/vmchooser-run_virt is no longer a wrapper but
a symlink and we readlink'ed it, the script failed to find running
instances.
-rw-r--r-- | core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc index 7a469e42..a5c20aea 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc @@ -8,16 +8,12 @@ get_vm_id() { local script=${BASH_SOURCE[-1]} [ -z "$script" ] && script="$0" - if [ -n "$script" ]; then - script=$(readlink -f "$script") - if [ -n "$script" ] && [ -s "$script" ]; then - #bingo - declare -g VM_ID=$(ps ax | grep -F "$script" | grep -v 'grep' | grep -o -- "${script}.*\$" | sort -u | wc -l) - if [ "$VM_ID" -gt 0 ]; then - [ "${#VM_ID}" -eq 1 ] && VM_ID="0${VM_ID}" - [ "${#VM_ID}" -gt 2 ] && VM_ID="${VM_ID:0:2}" - [ "${#VM_ID}" -eq 2 ] && readonly VM_ID && return - fi + if [ -n "$script" ] && [ -s "$script" ]; then + declare -g VM_ID=$(ps ax | grep -F "$script" | grep -v 'grep' | grep -o -- "${script}.*\$" | sort -u | wc -l) + if [ "$VM_ID" -gt 0 ]; then + [ "${#VM_ID}" -eq 1 ] && VM_ID="0${VM_ID}" + [ "${#VM_ID}" -gt 2 ] && VM_ID="${VM_ID:0:2}" + [ "${#VM_ID}" -eq 2 ] && readonly VM_ID && return fi fi # fallback: take last two digits of current pid... |