Commit a03c8a09 authored by Vitaly Lipatov's avatar Vitaly Lipatov

detect containters id in set / exec group operations

parent 5d96d662
...@@ -91,9 +91,6 @@ case $CMD in ...@@ -91,9 +91,6 @@ case $CMD in
done done
;; ;;
set) # HELPCMD: set param. Use with --option param set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2"
shift 2
LIST="$(get_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 vzctl $CMD $i $OPTIONS --save
...@@ -140,17 +137,32 @@ case $CMD in ...@@ -140,17 +137,32 @@ 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)
INCMD="$1" ###################################
shift # the same code like in set)
LIST="$(get_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
showcmd docker exec -ti $SETLANG "$i" "$INCMD" showcmd docker exec -ti $SETLANG "$i" "$@"
a= docker exec -ti $SETLANG "$i" "$INCMD" a= docker exec -ti $SETLANG "$i" "$@"
done done
;; ;;
enter) # HELPCMD: enter in a container with ID enter) # HELPCMD: enter in a container with ID
showcmd docker exec -ti $SETLANG "$1" bash ID="$1"
a= docker exec -ti $SETLANG "$1" bash shift
showcmd docker exec -ti $SETLANG "$ID" bash
a= docker exec -ti $SETLANG "$ID" bash
;; ;;
log|logs) # HELPCMD: print container log log|logs) # HELPCMD: print container log
docmd docker logs "$1" docmd docker logs "$1"
......
...@@ -41,3 +41,14 @@ get_list() ...@@ -41,3 +41,14 @@ get_list()
list_all list_all
} }
arg_is_id()
{
echo " $(list_ALL) " | grep -q " $1 "
}
arg_is_all()
{
[ "$1" = "ALL" ] && return
[ "$1" = "all" ] && return
return 1
}
...@@ -89,12 +89,25 @@ case $CMD in ...@@ -89,12 +89,25 @@ case $CMD in
done done
;; ;;
set) # HELPCMD: set param. Use with --option param set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2" ###################################
shift 2 # the same code like in set)
LIST="$(get_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
info "Do $CMD on $i ..." info "Do $CMD on $i ..."
docmd pct set $i $OPTIONS docmd pct set $i "$@"
done done
;; ;;
ubc|resources|show) # HELPCMD: print resource using ubc|resources|show) # HELPCMD: print resource using
...@@ -154,11 +167,24 @@ case $CMD in ...@@ -154,11 +167,24 @@ 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)
INCMD="$1" ###################################
shift # the same code like in set)
LIST="$(get_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 pct exec "$i" "$INCMD" docmd pct exec "$i" "$@"
done done
;; ;;
enter) # HELPCMD: enter in a container with ID enter) # HELPCMD: enter in a container with ID
......
...@@ -90,14 +90,26 @@ case $CMD in ...@@ -90,14 +90,26 @@ case $CMD in
done done
;; ;;
set) # HELPCMD: set param. Use with --option param set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2" ###################################
shift 2 # the same code like in set)
LIST="$(get_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
###################################
# 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
info "Do $CMD on $i ..." docmd vboxmanage modifyvm $i "$@"
docmd vboxmanage modifyvm $i $OPTIONS
done done
;; ;;
ubc|resources|show) # HELPCMD: print resource using by virtual machine(s) ubc|resources|show) # HELPCMD: print resource using by virtual machine(s)
......
...@@ -70,12 +70,23 @@ case $CMD in ...@@ -70,12 +70,23 @@ case $CMD in
done done
;; ;;
set) # HELPCMD: set param. Use with --option param set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2" ###################################
shift 2 # get all args until ids or all/ALL
LIST="$(get_list "$@")" 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 ..." docmd vzctl $CMD $i "$@" --save
a= vzctl $CMD $i $OPTIONS --save
done done
;; ;;
ubc|resources|show) # HELPCMD: print resource using via vzubc ubc|resources|show) # HELPCMD: print resource using via vzubc
...@@ -116,15 +127,27 @@ case $CMD in ...@@ -116,15 +127,27 @@ case $CMD in
a= vzlist "$@" a= vzlist "$@"
;; ;;
exec) # HELPCMD: execute command by list (all for all containers) exec) # HELPCMD: execute command by list (all for all containers)
INCMD="$1" ###################################
shift # the same code like in set)
LIST="$(get_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
#info "Executing on $i ..." #info "Executing on $i ..."
#printf "%3d: %s" $i "$(vzctl exec $i "$INCMD")" #printf "%3d: %s" $i "$(vzctl exec $i "$INCMD")"
#vzctl exec $i "$INCMD" | sed -e "s|^|$(printf "%3d: " $i)|g" #vzctl exec $i "$INCMD" | sed -e "s|^|$(printf "%3d: " $i)|g"
showcmd vzctl exec $i "$INCMD" docmd vzctl exec $i "$@"
a= vzctl exec $i "$INCMD"
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