From 342d38327d99faf364a0a876d6da0353a6718d8c Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Tue, 9 Nov 2010 14:59:46 +0000 Subject: [PATCH] Fix vsomething things. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2924 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- scripts/functions | 5 +++-- scripts/start-vservers | 30 ++++++++++++------------------ scripts/vapt-get | 5 ++--- scripts/vdispatch-conf | 5 ++--- scripts/vemerge | 5 ++--- scripts/vesync | 3 +-- scripts/vrpm | 5 ++--- scripts/vupdateworld | 5 ++--- 8 files changed, 26 insertions(+), 37 deletions(-) diff --git a/scripts/functions b/scripts/functions index 32863d8..69e289c 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 { @@ -553,6 +552,7 @@ function getAllVservers eval $1='( "${_ga_tmp[@]}" )' } +declare -r VS_ALLVSERVERS_ARGS=all,marked,unmarked,stopped,running,mark: ## Usage: getAllVserversByArg function getAllVserversByArg { @@ -579,7 +579,8 @@ function getAllVserversByArg shift ;; (--) break;; - (*) return 1;; + (*) set -- "$_gav_v" "$@" + return 1;; esac getAllVservers _gav_tmp "$_gav_mark" $_gav_extra diff --git a/scripts/start-vservers b/scripts/start-vservers index f02d3a3..a5f21e4 100755 --- a/scripts/start-vservers +++ b/scripts/start-vservers @@ -87,8 +87,6 @@ eval set -- "$tmp" declare -a tmp_vservers=() declare -r TAB=$(echo -en "\t") -OPTION_MARK= -OPTION_MARK_ANY=1 OPTION_PARALLEL=99 OPTION_DEBUG= NOOPTION_DEBUG=1 @@ -99,23 +97,32 @@ case "`basename $0`" in *) OPTION_FLAVOR=;; esac +gav_args=() while true; do - getAllVserversByArg tmp_vservers "$1" || \ case "$1" in (--help) showHelp $0 ;; (--version) showVersion $0 ;; (-c) CONFDIR=$2; shift;; - (-m) OPTION_MARK=$2; OPTION_MARK_ANY=; shift;; (-j) OPTION_PARALLEL=$2; shift;; (--start) OPTION_FLAVOR=start;; (--stop) OPTION_FLAVOR=stop;; (--debug) OPTION_DEBUG=1; NOOPTION_DEBUG=; set -x;; (--) shift; break;; - (*) echo $"$0: internal error; arg=='$1'" >&2; exit 1;; + (-m) gav_args=( "${gav_args[@]}" --mark "$2" ) + shift + ;; + (*) gav_args=( "${gav_args[@]}" "$1" );; esac shift done +if test "${#gav_args[@]}" -gt 0; then + if ! getAllVserversByArg tmp_vservers "${gav_args[@]}"; then + echo $"$0: internal error; arg=='$1'" >&2 + exit 1 + fi +fi + test -n "$OPTION_FLAVOR" || { echo "$0: unknown invocation method; aborting..." >&2 exit 1 @@ -123,19 +130,6 @@ test -n "$OPTION_FLAVOR" || { vservers=( "$@" "${tmp_vservers[@]}" ) -orig_vservers=$vservers -i=${#vservers[*]} - -while test $i -gt 0; do - let --i - d=$__CONFDIR/${vservers[$i]}/apps/init - f=$d/mark - { test -n "$OPTION_MARK_ANY"; } || \ - { test -n "$OPTION_MARK" -a -r "$f" && grep -qx "$OPTION_MARK" "$f"; } || \ - { test -z "$OPTION_MARK" && test ! -e "$f"; } || \ - unset vservers[$i] -done - makedir=$($_MKTEMPDIR vserver-init.XXXXXX) okfile=$($_MKTEMP vserver-init.XXXXXX) passedfile=$($_MKTEMP vserver-init.XXXXXX) diff --git a/scripts/vapt-get b/scripts/vapt-get index aa0f4fe..7e82249 100755 --- a/scripts/vapt-get +++ b/scripts/vapt-get @@ -46,7 +46,7 @@ the GNU General Public License. This program has absolutely no warranty." exit 0 } -tmp=$(getopt -o +q --long help,version,debug,quiet,all -n "$0" -- "$@") || exit 1 +tmp=$(getopt -o +q --long help,version,debug,quiet,$VS_ALLVSERVERS_ARGS -n "$0" -- "$@") || exit 1 eval set -- "$tmp" declare -a send_through vsomething_opts @@ -57,9 +57,8 @@ while true; do (--version) showVersion ;; (--debug) send_through=( "${send_through[@]}" "$1" ); set -x;; (--quiet|-q) send_through=( "${send_through[@]}" "$1" );; - (--all) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; (--) shift; break;; - (*) echo $"vapt-get: internal error; arg=='$1'" >&2; exit 1;; + (*) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; esac shift done diff --git a/scripts/vdispatch-conf b/scripts/vdispatch-conf index 3f21940..084c687 100755 --- a/scripts/vdispatch-conf +++ b/scripts/vdispatch-conf @@ -46,7 +46,7 @@ the GNU General Public License. This program has absolutely no warranty." exit 0 } -tmp=$(getopt -o +q --long help,version,debug,quiet,all -n "$0" -- "$@") || exit 1 +tmp=$(getopt -o +q --long help,version,debug,quiet,$VS_ALLVSERVERS_ARGS -n "$0" -- "$@") || exit 1 eval set -- "$tmp" declare -a send_through vsomething_opts @@ -57,9 +57,8 @@ while true; do (--version) showVersion ;; (--debug) send_through=( "${send_through[@]}" "$1" ); set -x;; (--quiet|-q) send_through=( "${send_through[@]}" "$1" );; - (--all) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; (--) test ${#vsomething_opts[@]} -eq 0 && shift; break;; - (*) echo $"vdispatch-conf: internal error; arg=='$1'" >&2; exit 1;; + (*) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; esac shift done diff --git a/scripts/vemerge b/scripts/vemerge index 1da3e92..36321ab 100755 --- a/scripts/vemerge +++ b/scripts/vemerge @@ -46,7 +46,7 @@ the GNU General Public License. This program has absolutely no warranty." exit 0 } -tmp=$(getopt -o +q --long help,version,debug,quiet,all -n "$0" -- "$@") || exit 1 +tmp=$(getopt -o +q --long help,version,debug,quiet,$VS_ALLVSERVERS_ARGS -n "$0" -- "$@") || exit 1 eval set -- "$tmp" declare -a send_through vsomething_opts @@ -57,9 +57,8 @@ while true; do (--version) showVersion ;; (--debug) send_through=( "${send_through[@]}" "$1" ); set -x;; (--quiet|-q) send_through=( "${send_through[@]}" "$1" );; - (--all) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; (--) test ${#vsomething_opts[@]} -eq 0 && shift; break;; - (*) echo $"vemerge: internal error; arg=='$1'" >&2; exit 1;; + (*) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; esac shift done diff --git a/scripts/vesync b/scripts/vesync index 60afba8..8720345 100755 --- a/scripts/vesync +++ b/scripts/vesync @@ -60,12 +60,11 @@ while true; do (--version) showVersion ;; (--debug) send_through=( "${send_through[@]}" "$1" ); set -x;; (--quiet|-q) send_through=( "${send_through[@]}" "$1" );; - (--all) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; (--overlay) overlay="${2%/}";; (--overlay-host) overlay_host="${2%/}";; (--overlay-only) overlay_only=1;; (--) test ${#vsomething_opts[@]} -eq 0 && shift; break;; - (*) echo $"vesync: internal error; arg=='$1'" >&2; exit 1;; + (*) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; esac shift done diff --git a/scripts/vrpm b/scripts/vrpm index ffff573..0bae9dd 100755 --- a/scripts/vrpm +++ b/scripts/vrpm @@ -46,7 +46,7 @@ the GNU General Public License. This program has absolutely no warranty." exit 0 } -tmp=$(getopt -o +q --long help,version,debug,quiet,all -n "$0" -- "$@") || exit 1 +tmp=$(getopt -o +q --long help,version,debug,quiet,$VS_ALLVSERVERS_ARGS -n "$0" -- "$@") || exit 1 eval set -- "$tmp" declare -a send_through vsomething_opts @@ -57,9 +57,8 @@ while true; do (--version) showVersion ;; (--debug) send_through=( "${send_through[@]}" "$1" ); set -x;; (--quiet|-q) send_through=( "${send_through[@]}" "$1" );; - (--all) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; (--) shift; break;; - (*) echo $"vrpm: internal error; arg=='$1'" >&2; exit 1;; + (*) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; esac shift done diff --git a/scripts/vupdateworld b/scripts/vupdateworld index a69b693..ebc5edf 100755 --- a/scripts/vupdateworld +++ b/scripts/vupdateworld @@ -46,7 +46,7 @@ the GNU General Public License. This program has absolutely no warranty." exit 0 } -tmp=$(getopt -o +q --long help,version,debug,quiet,all -n "$0" -- "$@") || exit 1 +tmp=$(getopt -o +q --long help,version,debug,quiet,$VS_ALLVSERVERS_ARGS -n "$0" -- "$@") || exit 1 eval set -- "$tmp" declare -a send_through vsomething_opts @@ -57,9 +57,8 @@ while true; do (--version) showVersion ;; (--debug) send_through=( "${send_through[@]}" "$1" ); set -x;; (--quiet|-q) send_through=( "${send_through[@]}" "$1" );; - (--all) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; (--) test ${#vsomething_opts[@]} -eq 0 && shift; break;; - (*) echo $"vupdateworld: internal error; arg=='$1'" >&2; exit 1;; + (*) vsomething_opts=( "${vsomething_opts[@]}" "$1" );; esac shift done -- 1.8.1.5