diff options
author | Jonathan Bauer | 2018-04-13 18:13:25 +0200 |
---|---|---|
committer | Jonathan Bauer | 2018-04-13 18:13:25 +0200 |
commit | 0ed5e3423df24d5edac94288538033b7763f6dbc (patch) | |
tree | 6c2830b01ebccfb9ab1309881732c08a9f8de514 /core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc | |
parent | [run-virt] error msg for missing plugin dir (diff) | |
download | mltk-0ed5e3423df24d5edac94288538033b7763f6dbc.tar.gz mltk-0ed5e3423df24d5edac94288538033b7763f6dbc.tar.xz mltk-0ed5e3423df24d5edac94288538033b7763f6dbc.zip |
[vbox-src] more vbox plugin fixes
* use HW_CORES from /run/hwinfo
* add usb attach script [WIP]
* udev rule to trigger attach script when usb is connected
* edit_attr -> set_attr now always creating missing nodes/attributes
...and prolly more I cant think of now ...
Diffstat (limited to 'core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc')
-rwxr-xr-x | core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc index d30a0408..a1da3016 100755 --- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc +++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc @@ -47,26 +47,32 @@ add_node() { ${ATTRS_OPTS} \ "${TMPCONFIG}" } -# edit_attr [--create] <node_xpath> <attr=value> -# --create would create the node if it does not exist -edit_attr() { - local CREATE= - if [ "$1" = "--create" ]; then - CREATE=yo - shift - fi +# set_attr <node_xpath> <attr> <value> +set_attr() { if [ $# -ne 3 ]; then writelog "${FUNCNAME[0]} requires 3 args, $# given." cleanexit 1 fi - if notempty CREATE && ! node_exists "$1"; then + if ! node_exists "$1"; then + writelog "Node $1 missing" add_node "${1%/*}" "${1##*/}" \ "$2=$3" else - xmlstarlet ed -L -N x="${VBOX_NAMESPACE}" \ - -u "$(print_namespaced "x" "$1")/@$2" \ - -v "$3" \ - "${TMPCONFIG}" + if ! attr_exists "$1" "$2"; then + writelog "Attr $2 of $1 missing" + xmlstarlet ed -L -N x="${VBOX_NAMESPACE}" \ + -i "$(print_namespaced "x" "$1")" \ + -t attr -n "$2" -v "$3" \ + "${TMPCONFIG}" + writelog "Returned with $?" + else + writelog "Attr $2 exists" + xmlstarlet ed -L -N x="${VBOX_NAMESPACE}" \ + -u "$(print_namespaced "x" "$1")/@$2" \ + -v "$3" \ + "${TMPCONFIG}" + writelog "Returned with $?" + fi fi } del_node() { @@ -78,6 +84,15 @@ del_node() { -d "$(print_namespaced "x" "$1")" \ "${TMPCONFIG}" } +attr_exists() { + if [ $# -ne 2 ]; then + writelog "${FUNCNAME[0]} requires node and attribute as args, $# given." + cleanexit 1 + fi + xmlstarlet -q sel -N x="${VBOX_NAMESPACE}" \ + -t -v "$(print_namespaced "x" "$1")/@$2" \ + "${TMPCONFIG}" +} node_exists() { if [ $# -ne 1 ]; then writelog "${FUNCNAME[0]} requires one arg, $# given." |