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
...
@@ -88,15 +88,37 @@ case "$1" in
;;
;;
esac
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
()
list_all
()
{
{
vzlist
-1
"
$@
"
vzlist
-1
"
$@
"
| line_filter
}
}
list_ALL
()
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
# TODO: add all support for all cases
...
@@ -105,7 +127,8 @@ CMD=$1
...
@@ -105,7 +127,8 @@ CMD=$1
shift
shift
case
$CMD
in
case
$CMD
in
off
)
# HELPCMD: stop container(s) and disable start on boot
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
..."
info
"Stopping
$i
..."
vzctl stop
$i
vzctl stop
$i
# TODO: check if enabled
# TODO: check if enabled
...
@@ -121,25 +144,29 @@ case $CMD in
...
@@ -121,25 +144,29 @@ case $CMD in
done
done
;;
;;
status
)
# HELPCMD: print container(s) status
status
)
# HELPCMD: print container(s) status
info
"Do
$CMD
for
$*
..."
LIST
=
$(
get_list
"
$@
"
)
for
i
in
"
$@
"
;
do
info
"Do
$CMD
for
$LIST
..."
for
i
in
$LIST
;
do
vzctl
$CMD
$i
vzctl
$CMD
$i
done
done
;;
;;
compact
)
# HELPCMD: do named operation on container(s)
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
..."
info
"Do
$CMD
on
$i
..."
vzctl
$CMD
$i
vzctl
$CMD
$i
done
done
;;
;;
stop
)
# HELPCMD: stop container(s)
stop
)
# HELPCMD: stop container(s)
LIST
=
$(
get_list
"
$@
"
)
for
i
in
"
$@
"
;
do
for
i
in
"
$@
"
;
do
info
"Stopping
$i
..."
info
"Stopping
$i
..."
vzctl stop
$i
vzctl stop
$i
done
done
;;
;;
start
)
# HELPCMD: start container(s)
start
)
# HELPCMD: start container(s)
for
i
in
"
$@
"
;
do
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
info
"Starting
$i
..."
info
"Starting
$i
..."
vzctl start
$i
vzctl start
$i
done
done
...
@@ -148,12 +175,7 @@ case $CMD in
...
@@ -148,12 +175,7 @@ case $CMD in
# if -q, just id list
# if -q, just id list
if
[
-z
"
$verbose
"
]
||
[
"
$1
"
=
"-1"
]
||
[
"
$1
"
=
"-q"
]
;
then
if
[
-z
"
$verbose
"
]
||
[
"
$1
"
=
"-1"
]
||
[
"
$1
"
=
"-q"
]
;
then
[
-z
"
$verbose
"
]
||
shift
[
-z
"
$verbose
"
]
||
shift
# some hack, TODO: drop all args
get_list
"
$@
"
[
"
$1
"
=
"all"
]
&&
shift
LIST
=
"
$(
list_all
"
$@
"
)
"
[
"
$1
"
=
"ALL"
]
&&
LIST
=
"
$(
list_ALL
)
"
[
"
$1
"
=
"-a"
]
&&
LIST
=
"
$(
list_ALL
)
"
echo
"
$LIST
"
exit
exit
fi
fi
vzlist
"
$@
"
vzlist
"
$@
"
...
@@ -161,9 +183,7 @@ case $CMD in
...
@@ -161,9 +183,7 @@ case $CMD in
exec
)
# HELPCMD: execute command by list (all for all containers)
exec
)
# HELPCMD: execute command by list (all for all containers)
INCMD
=
"
$1
"
INCMD
=
"
$1
"
shift
shift
LIST
=
"
$*
"
LIST
=
$(
get_list
"
$@
"
)
[
"
$1
"
=
"all"
]
&&
LIST
=
"
$(
list_all
)
"
[
"
$1
"
=
"ALL"
]
&&
LIST
=
"
$(
list_ALL
)
"
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")"
...
@@ -172,9 +192,7 @@ case $CMD in
...
@@ -172,9 +192,7 @@ case $CMD in
done
done
;;
;;
info
)
# HELPCMD: print containers(s) info (vzlist like)
info
)
# HELPCMD: print containers(s) info (vzlist like)
LIST
=
"
$*
"
LIST
=
$(
get_list
"
$@
"
)
[
"
$1
"
=
"all"
]
&&
LIST
=
"
$(
list_all
)
"
[
"
$1
"
=
"ALL"
]
&&
LIST
=
"
$(
list_ALL
)
"
#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")"
...
@@ -186,7 +204,7 @@ case $CMD in
...
@@ -186,7 +204,7 @@ case $CMD in
;;
;;
destroy
)
# HELPCMD: destroy container(s) by list
destroy
)
# HELPCMD: destroy container(s) by list
echo
"You request to destroy follow containers:"
echo
"You request to destroy follow containers:"
vzlist
"
$@
"
vzlist
-a
"
$@
"
#local response
#local response
read
-r
-p
"Are you sure? [Yes/No]"
response
read
-r
-p
"Are you sure? [Yes/No]"
response
[
"
$response
"
=
"Yes"
]
||
fatal
"Have no receive your accept."
[
"
$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