Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
evz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
evz
Commits
495c525c
Commit
495c525c
authored
Nov 17, 2017
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve vz list using (all, ALL for any cases)
parent
9d4aec7d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
20 deletions
+38
-20
evz
bin/evz
+38
-20
No files found.
bin/evz
View file @
495c525c
...
...
@@ -88,15 +88,37 @@ case "$1" in
;;
esac
line_filter
()
{
# https://stackoverflow.com/questions/1251999/how-can-i-replace-a-newline-n-using-sed
sed
-e
':a'
-e
'N'
-e
'$!ba'
-e
's/\n/ /g'
-e
"s|
\+
| |g"
-e
"s|^ ||g"
-e
"s|
$|
|g"
}
list_all
()
{
vzlist
-1
"
$@
"
vzlist
-1
"
$@
"
| line_filter
}
list_ALL
()
{
vzlist
-1
-a
"
$@
"
vzlist
-1
-a
"
$@
"
| line_filter
}
get_list
()
{
if
[
"
$1
"
=
"ALL"
]
;
then
list_ALL
return
fi
if
[
"
$1
"
=
"all"
]
;
then
list_all
return
fi
if
[
-n
"
$1
"
]
;
then
list_ALL
"
$@
"
return
fi
list_all
}
# TODO: add all support for all cases
...
...
@@ -105,7 +127,8 @@ CMD=$1
shift
case
$CMD
in
off
)
# HELPCMD: stop container(s) and disable start on boot
for
i
in
"
$@
"
;
do
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
info
"Stopping
$i
..."
vzctl stop
$i
# TODO: check if enabled
...
...
@@ -121,25 +144,29 @@ case $CMD in
done
;;
status
)
# HELPCMD: print container(s) status
info
"Do
$CMD
for
$*
..."
for
i
in
"
$@
"
;
do
LIST
=
$(
get_list
"
$@
"
)
info
"Do
$CMD
for
$LIST
..."
for
i
in
$LIST
;
do
vzctl
$CMD
$i
done
;;
compact
)
# HELPCMD: do named operation on container(s)
for
i
in
"
$@
"
;
do
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
info
"Do
$CMD
on
$i
..."
vzctl
$CMD
$i
done
;;
stop
)
# HELPCMD: stop container(s)
LIST
=
$(
get_list
"
$@
"
)
for
i
in
"
$@
"
;
do
info
"Stopping
$i
..."
vzctl stop
$i
done
;;
start
)
# HELPCMD: start container(s)
for
i
in
"
$@
"
;
do
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
info
"Starting
$i
..."
vzctl start
$i
done
...
...
@@ -148,12 +175,7 @@ case $CMD in
# if -q, just id list
if
[
-z
"
$verbose
"
]
||
[
"
$1
"
=
"-1"
]
||
[
"
$1
"
=
"-q"
]
;
then
[
-z
"
$verbose
"
]
||
shift
# some hack, TODO: drop all args
[
"
$1
"
=
"all"
]
&&
shift
LIST
=
"
$(
list_all
"
$@
"
)
"
[
"
$1
"
=
"ALL"
]
&&
LIST
=
"
$(
list_ALL
)
"
[
"
$1
"
=
"-a"
]
&&
LIST
=
"
$(
list_ALL
)
"
echo
"
$LIST
"
get_list
"
$@
"
exit
fi
vzlist
"
$@
"
...
...
@@ -161,9 +183,7 @@ case $CMD in
exec
)
# HELPCMD: execute command by list (all for all containers)
INCMD
=
"
$1
"
shift
LIST
=
"
$*
"
[
"
$1
"
=
"all"
]
&&
LIST
=
"
$(
list_all
)
"
[
"
$1
"
=
"ALL"
]
&&
LIST
=
"
$(
list_ALL
)
"
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
#info "Executing on $i ..."
#printf "%3d: %s" $i "$(vzctl exec $i "$INCMD")"
...
...
@@ -172,9 +192,7 @@ case $CMD in
done
;;
info
)
# HELPCMD: print containers(s) info (vzlist like)
LIST
=
"
$*
"
[
"
$1
"
=
"all"
]
&&
LIST
=
"
$(
list_all
)
"
[
"
$1
"
=
"ALL"
]
&&
LIST
=
"
$(
list_ALL
)
"
LIST
=
$(
get_list
"
$@
"
)
#for i in $LIST ; do
#info "Executing on $i ..."
#printf "%3d: %s" $i "$(vzctl exec $i "$INCMD")"
...
...
@@ -186,7 +204,7 @@ case $CMD in
;;
destroy
)
# HELPCMD: destroy container(s) by list
echo
"You request to destroy follow containers:"
vzlist
"
$@
"
vzlist
-a
"
$@
"
#local response
read
-r
-p
"Are you sure? [Yes/No]"
response
[
"
$response
"
=
"Yes"
]
||
fatal
"Have no receive your accept."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment