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
done
;;
set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2"
shift 2
LIST="$(get_list "$@")"
for i in $LIST ; do
info "Do $CMD on $i ..."
todo vzctl $CMD $i $OPTIONS --save
......@@ -140,17 +137,32 @@ case $CMD in
info "See evz ports ID for print ports"
;;
exec) # HELPCMD: execute command by list (all for all containers)
INCMD="$1"
shift
LIST="$(get_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
showcmd docker exec -ti $SETLANG "$i" "$INCMD"
a= docker exec -ti $SETLANG "$i" "$INCMD"
showcmd docker exec -ti $SETLANG "$i" "$@"
a= docker exec -ti $SETLANG "$i" "$@"
done
;;
enter) # HELPCMD: enter in a container with ID
showcmd docker exec -ti $SETLANG "$1" bash
a= docker exec -ti $SETLANG "$1" bash
ID="$1"
shift
showcmd docker exec -ti $SETLANG "$ID" bash
a= docker exec -ti $SETLANG "$ID" bash
;;
log|logs) # HELPCMD: print container log
docmd docker logs "$1"
......
......@@ -41,3 +41,14 @@ get_list()
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
done
;;
set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2"
shift 2
LIST="$(get_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
info "Do $CMD on $i ..."
docmd pct set $i $OPTIONS
docmd pct set $i "$@"
done
;;
ubc|resources|show) # HELPCMD: print resource using
......@@ -154,11 +167,24 @@ case $CMD in
#info "See evz ports ID for print ports"
;;
exec) # HELPCMD: execute command by list (all for all containers)
INCMD="$1"
shift
LIST="$(get_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
docmd pct exec "$i" "$INCMD"
docmd pct exec "$i" "$@"
done
;;
enter) # HELPCMD: enter in a container with ID
......
......@@ -90,14 +90,26 @@ case $CMD in
done
;;
set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2"
shift 2
LIST="$(get_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
[ -n "$LIST" ] || docmd vboxmanage modifyvm
for i in $LIST ; do
info "Do $CMD on $i ..."
docmd vboxmanage modifyvm $i $OPTIONS
docmd vboxmanage modifyvm $i "$@"
done
;;
ubc|resources|show) # HELPCMD: print resource using by virtual machine(s)
......
......@@ -70,12 +70,23 @@ case $CMD in
done
;;
set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2"
shift 2
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
info "Do $CMD on $i ..."
a= vzctl $CMD $i $OPTIONS --save
docmd vzctl $CMD $i "$@" --save
done
;;
ubc|resources|show) # HELPCMD: print resource using via vzubc
......@@ -116,15 +127,27 @@ case $CMD in
a= vzlist "$@"
;;
exec) # HELPCMD: execute command by list (all for all containers)
INCMD="$1"
shift
LIST="$(get_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
#info "Executing on $i ..."
#printf "%3d: %s" $i "$(vzctl exec $i "$INCMD")"
#vzctl exec $i "$INCMD" | sed -e "s|^|$(printf "%3d: " $i)|g"
showcmd vzctl exec $i "$INCMD"
a= vzctl exec $i "$INCMD"
docmd vzctl exec $i "$@"
done
;;
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