Commit 5a56feed authored by Vitaly Lipatov's avatar Vitaly Lipatov

add fill_args_list and use it intead of copy-paste code

parent 0dad37db
...@@ -102,9 +102,10 @@ case $CMD in ...@@ -102,9 +102,10 @@ case $CMD in
done done
;; ;;
set) # HELPCMD: set param. Use with --option param set) # HELPCMD: set param. Use with --option param
fill_args_list "$@"
for i in $LIST ; do for i in $LIST ; do
info "Do $CMD on $i ..." #info "Do $CMD on $i ..."
todo vzctl $CMD $i $OPTIONS --save todo docmdeval $CMD $i "$OPTARGS" --save
done done
;; ;;
ubc|resources|show) # HELPCMD: print resource using ubc|resources|show) # HELPCMD: print resource using
...@@ -149,24 +150,9 @@ case $CMD in ...@@ -149,24 +150,9 @@ case $CMD in
info "See evz ports ID for print ports" info "See evz ports ID for print ports"
;; ;;
exec) # HELPCMD: execute command by list (all for all containers) exec) # HELPCMD: execute command by list (all for all containers)
################################### fill_args_list "$@"
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
for i in $LIST ; do for i in $LIST ; do
docmd docker exec -ti $SETLANG "$i" "$@" docmdeval docker exec -ti $SETLANG "$i" "$QUOTEDARGS"
done done
;; ;;
enter) # HELPCMD: enter in a container with ID enter) # HELPCMD: enter in a container with ID
......
...@@ -74,3 +74,21 @@ quote_args() ...@@ -74,3 +74,21 @@ quote_args()
done done
} }
# will fill LIST with ids and QUOTEDARGS with other
fill_args_list()
{
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
QUOTEDARGS="$(quote_args "$@")"
}
...@@ -102,25 +102,10 @@ case $CMD in ...@@ -102,25 +102,10 @@ case $CMD in
done done
;; ;;
set) # HELPCMD: set param. Use with --option param set) # HELPCMD: set param. Use with --option param
################################### fill_args_list "$@"
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
for i in $LIST ; do for i in $LIST ; do
info "Do $CMD on $i ..." info "Do $CMD on $i ..."
docmd pct set $i "$@" docmdeval pct set $i "$QUOTEDARGS"
done done
;; ;;
ubc|resources|show) # HELPCMD: print resource using ubc|resources|show) # HELPCMD: print resource using
...@@ -184,24 +169,9 @@ case $CMD in ...@@ -184,24 +169,9 @@ case $CMD in
#info "See evz ports ID for print ports" #info "See evz ports ID for print ports"
;; ;;
exec) # HELPCMD: execute command by list (all for all containers) exec) # HELPCMD: execute command by list (all for all containers)
################################### fill_args_list "$@"
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
for i in $LIST ; do for i in $LIST ; do
docmd pct exec "$i" "$@" docmd pct exec "$i" "$QUOTEDARGS"
done done
;; ;;
enter) # HELPCMD: enter in a container with ID enter) # HELPCMD: enter in a container with ID
......
...@@ -100,12 +100,9 @@ case $CMD in ...@@ -100,12 +100,9 @@ case $CMD in
done done
;; ;;
set) # HELPCMD: set param. Use with --option param set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2" fill_args_list "$@"
shift 2
LIST="$(get_list "$@")"
for i in $LIST ; do for i in $LIST ; do
info "Do $CMD on $i ..." docmd vzctl $CMD $i "$QUOTEDARGS" --save
todo vzctl $CMD $i $OPTIONS --save
done done
;; ;;
ubc|resources|show) # HELPCMD: print resource using ubc|resources|show) # HELPCMD: print resource using
...@@ -150,9 +147,7 @@ case $CMD in ...@@ -150,9 +147,7 @@ case $CMD in
fi fi
;; ;;
exec) # HELPCMD: execute command by list (all for all containers) exec) # HELPCMD: execute command by list (all for all containers)
INCMD="$1" fill_args_list "$@"
shift
LIST="$(get_list "$@")"
for i in $LIST ; do for i in $LIST ; do
todo showcmd docker exec -ti $SETLANG "$i" "$INCMD" todo showcmd docker exec -ti $SETLANG "$i" "$INCMD"
#a= docker exec -ti $SETLANG "$i" "$INCMD" #a= docker exec -ti $SETLANG "$i" "$INCMD"
......
...@@ -104,26 +104,11 @@ case $CMD in ...@@ -104,26 +104,11 @@ case $CMD in
done done
;; ;;
set) # HELPCMD: set param. Use with --option param set) # HELPCMD: set param. Use with --option param
################################### fill_args_list "$@"
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
# show help if empty # show help if empty
[ -n "$LIST" ] || docmd vboxmanage modifyvm [ -n "$LIST" ] || docmd vboxmanage modifyvm
for i in $LIST ; do for i in $LIST ; do
docmd vboxmanage modifyvm $i "$@" docmdeval vboxmanage modifyvm $i "$QUOTEDARGS"
done done
;; ;;
ubc|resources|show) # HELPCMD: print resource using by virtual machine(s) ubc|resources|show) # HELPCMD: print resource using by virtual machine(s)
...@@ -185,9 +170,7 @@ case $CMD in ...@@ -185,9 +170,7 @@ case $CMD in
fi fi
;; ;;
exec) # HELPCMD: execute command by list (all for all virtual machines) exec) # HELPCMD: execute command by list (all for all virtual machines)
INCMD="$1" fill_args_list "$@"
shift
LIST="$(get_list "$@")"
for i in $LIST ; do for i in $LIST ; do
todo showcmd docker exec -ti $SETLANG "$i" "$INCMD" todo showcmd docker exec -ti $SETLANG "$i" "$INCMD"
todo a= docker exec -ti $SETLANG "$i" "$INCMD" todo a= docker exec -ti $SETLANG "$i" "$INCMD"
......
...@@ -80,23 +80,9 @@ case $CMD in ...@@ -80,23 +80,9 @@ case $CMD in
done done
;; ;;
set) # HELPCMD: set param. Use with --option param set) # HELPCMD: set param. Use with --option param
################################### fill_args_list "$@"
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
for i in $LIST ; do for i in $LIST ; do
docmd vzctl $CMD $i "$@" --save docmdeval vzctl set $i "$QUOTEDARGS" --save
done done
;; ;;
ubc|resources|show) # HELPCMD: print resource using via vzubc ubc|resources|show) # HELPCMD: print resource using via vzubc
...@@ -141,27 +127,9 @@ case $CMD in ...@@ -141,27 +127,9 @@ case $CMD in
fi fi
;; ;;
exec) # HELPCMD: execute command by list (all for all containers) exec) # HELPCMD: execute command by list (all for all containers)
################################### fill_args_list "$@"
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
for i in $LIST ; do for i in $LIST ; do
#info "Executing on $i ..." docmdeval vzctl exec $i "$QUOTEDARGS"
#printf "%3d: %s" $i "$(vzctl exec $i "$INCMD")"
#vzctl exec $i "$INCMD" | sed -e "s|^|$(printf "%3d: " $i)|g"
docmd vzctl exec $i "$@"
done done
;; ;;
enter) # HELPCMD: enter in a container with ID enter) # HELPCMD: enter in a container with ID
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment