Fix vsomething things.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Tue, 9 Nov 2010 14:59:46 +0000 (14:59 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Tue, 9 Nov 2010 14:59:46 +0000 (14:59 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2924 94cd875c-1c1d-0410-91d2-eb244daf1a30

scripts/functions
scripts/start-vservers
scripts/vapt-get
scripts/vdispatch-conf
scripts/vemerge
scripts/vesync
scripts/vrpm
scripts/vupdateworld

index 32863d8..69e289c 100644 (file)
@@ -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 <var> <arg>
 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
index f02d3a3..a5f21e4 100755 (executable)
@@ -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)
index aa0f4fe..7e82249 100755 (executable)
@@ -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
index 3f21940..084c687 100755 (executable)
@@ -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
index 1da3e92..36321ab 100755 (executable)
@@ -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
index 60afba8..8720345 100755 (executable)
@@ -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
index ffff573..0bae9dd 100755 (executable)
@@ -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
index a69b693..ebc5edf 100755 (executable)
@@ -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