X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=scripts%2Ffunctions;h=7d6278b73e07343ad0a36ce755f94dc459d16d80;hb=54edc50b584ade4f323c16bec6ef6320f129e531;hp=32863d85591bc01c53c694d9be40ddcc0bcfd1f0;hpb=cd841ad88a1deb62271fff26455c4c2bbd23c6e0;p=util-vserver.git diff --git a/scripts/functions b/scripts/functions index 32863d8..7d6278b 100644 --- a/scripts/functions +++ b/scripts/functions @@ -21,7 +21,6 @@ _VS_ERRFILE= _VS_NEWLINE=' ' declare -r _VS_NEWLINE=${_VS_NEWLINE:0-1} -declare -r VS_ALLVSERVERS_ARGS=all,marked,unmarked,stopped,running function findObject { @@ -527,6 +526,10 @@ function getAllVservers { local _ga_i declare -a _ga_tmp=() + local _ga_IFS="$IFS" + IFS=, + local -a _ga_marks=( $3 ) + IFS="$_ga_IFS" for _ga_i in $__CONFDIR/*; do isRegularFile "$_ga_i" -d || continue @@ -543,7 +546,19 @@ function getAllVservers (STOPPED) ! $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;; (RUNNING) $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;; (ALL) ;; - (MARK) test -s "$_ga_markfile" && grep -qx "$3" "$_ga_markfile" || _ga_doadd=;; + (MARK) local _ga_j + local _ga_mark + local _ga_f=false + local _ga_invert=false + for _ga_j in "${_ga_marks[@]}"; do + _ga_mark="$(echo "$_ga_j" | $_SED 's/^[!~]//')" + test "$_ga_j" = "$_ga_mark" || _ga_invert=true + test -s "$_ga_markfile" && $_GREP -qx "$_ga_mark" "$_ga_markfile" && \ + _ga_f=true || : + done + test $_ga_f = $_ga_invert && \ + _ga_doadd= + ;; (*) panic $"Unknown vserver tagging '$2'";; esac @@ -553,6 +568,7 @@ function getAllVservers eval $1='( "${_ga_tmp[@]}" )' } +declare -r VS_ALLVSERVERS_ARGS=all,marked,unmarked,stopped,running,mark: ## Usage: getAllVserversByArg function getAllVserversByArg { @@ -579,7 +595,8 @@ function getAllVserversByArg shift ;; (--) break;; - (*) return 1;; + (*) set -- "$_gav_v" "$@" + return 1;; esac getAllVservers _gav_tmp "$_gav_mark" $_gav_extra @@ -587,7 +604,8 @@ function getAllVserversByArg _gav_res=( "${_gav_tmp[@]}" ) else local _gav_i=0 - while test $_gav_i -lt "${#_gav_res[@]}"; do + local _gav_n="${#_gav_res[@]}" + while test $_gav_i -lt $_gav_n; do local _gav_found=0 for _gav_j in "${_gav_tmp[@]}"; do if test "$_gav_j" = "${_gav_res[$_gav_i]}"; then