diff options
Diffstat (limited to 'os-plugins/plugins/vmgrid/files/run-vmgrid.sh')
-rw-r--r-- | os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 9e3cbf0a..b4830dc9 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -64,13 +64,14 @@ cleanexit () { ### Get XML file and dir ################################################################################ -# check if mem or graphical mode set +# check if mem, nice or graphical mode set headless=1 +unice=19 while [ $# -gt 0 ]; do case "$1" in -h|--help) echo -e "Usage: run-vmgrid.sh [-g] [--mem <memory size in MB>] \c" - echo -e "[/path/]filename[.xml]" + echo -e "[--nice <nice level>] [/path/]filename[.xml]" exit ;; -g) @@ -78,10 +79,25 @@ while [ $# -gt 0 ]; do ;; --mem) # get a result which can be divided through 4 - forcemem=$2 - echo $2 | grep -q '[1-9][0-9]\{2,3\}$' && forcemem=$(expr $2 / 4 \* 4) + if echo $2 | grep -qE \ + '^[2-9][0-9][0-9]$|^[1-9][0-9][0-9][0-9]$|^1[0-9][0-9][0-9][0-9]$'; + then + forcemem=$(expr $2 / 4 \* 4) + else + echo "memory $2 not supported (200-19999)!" + exit 1 + fi shift ;; + --nice) + # set nice level + if echo $2 | grep -qE '^-[1-9]$|-1[0-9]$|^-20$|^[0-9]$|^1[0-9]$'; then + unice=$2 + else + echo "nice level $2 does not exist!" + exit 1 + fi + shift *) xmlfile=$@ break @@ -399,11 +415,13 @@ if [ ${headless} -eq 0 ]; then cleanexit 1 fi writelog "Starting ${vmgrid_virt} in graphical mode..." - ${VIRTCMD} ${VIRTCMDOPTS} 2>/dev/null + # start /w low nice level + nice -n ${unice} ${VIRTCMD} ${VIRTCMDOPTS} 2>/dev/null # start headless elif [ -n "${VIRTCMDHL}" ]; then writelog "Starting ${vmgrid_virt} in headless mode..." - ${VIRTCMDHL} ${VIRTCMDOPTSHL} 2>/dev/null + # start /w low nice level + nice -n ${unice} ${VIRTCMDHL} ${VIRTCMDOPTSHL} 2>/dev/null else writelog "${vmgrid_virt}: No headless mode defined, exiting!" cleanexit 1 |