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
Тимофей Смирнов
evz
Commits
bffdb9bf
Commit
bffdb9bf
authored
Feb 24, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
evz-docker: initial implement
parent
cea3c9c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
35 deletions
+58
-35
evz-docker
bin/evz-docker
+58
-26
evz-functions
bin/evz-functions
+0
-9
No files found.
bin/evz-docker
View file @
bffdb9bf
...
@@ -17,6 +17,35 @@
...
@@ -17,6 +17,35 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
SETLANG
=
ru_RU.UTF8
# list all running containers (or by arg list)
list_all
()
{
if
[
-n
"
$1
"
]
;
then
echo
"
$*
"
return
fi
docker ps
-q
| line_filter
}
# list all containers (or by arg list)
list_ALL
()
{
if
[
-n
"
$1
"
]
;
then
echo
"
$*
"
return
fi
docker ps
-a
-q
| line_filter
}
todo
()
{
warning
"
$@
"
}
# TODO: add all support for all cases
# TODO: add all support for all cases
evz_docker
()
evz_docker
()
...
@@ -27,32 +56,31 @@ case $CMD in
...
@@ -27,32 +56,31 @@ case $CMD in
off
)
# HELPCMD: stop container(s) and disable start on boot
off
)
# HELPCMD: stop container(s) and disable start on boot
LIST
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
for
i
in
$LIST
;
do
info
"Stopping
$i
..."
#info "Stopping $i ..."
vzctl stop
$i
docmd docker stop
$i
# TODO: check if enabled
docmd docker update
--restart
no
$i
vzctl
set
$i
--onboot
no
--save
done
done
;;
;;
on
)
# HELPCMD: enable start on boot and start container(s)
on
)
# HELPCMD: enable start on boot and start container(s)
for
i
in
"
$@
"
;
do
for
i
in
"
$@
"
;
do
info
"Starting
$i
..."
#
info "Starting $i ..."
# TODO: check if enabled
# TODO: check if enabled
vzctl
set
$i
--onboot
yes
--save
docmd docker update
--restart
always
$i
vzctl
start
$i
docmd docker
start
$i
done
done
;;
;;
status
)
# HELPCMD: print container(s) status
status
)
# HELPCMD: print container(s) status
LIST
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
info
"Do
$CMD
for
$LIST
..."
#
info "Do $CMD for $LIST ..."
for
i
in
$LIST
;
do
for
i
in
$LIST
;
do
vzctl
$CMD
$i
docmd docker stats
--no-stream
$i
done
done
;;
;;
compact
)
# HELPCMD: do named operation on container(s)
compact
)
# HELPCMD: do named operation on container(s)
LIST
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
for
i
in
$LIST
;
do
info
"Do
$CMD
on
$i
..."
info
"Do
$CMD
on
$i
..."
vzctl
$CMD
$i
todo
vzctl
$CMD
$i
done
done
;;
;;
set
)
# HELPCMD: set param. Use with --option param
set
)
# HELPCMD: set param. Use with --option param
...
@@ -61,60 +89,61 @@ case $CMD in
...
@@ -61,60 +89,61 @@ case $CMD in
LIST
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
for
i
in
$LIST
;
do
info
"Do
$CMD
on
$i
..."
info
"Do
$CMD
on
$i
..."
vzctl
$CMD
$i
$OPTIONS
--save
todo
vzctl
$CMD
$i
$OPTIONS
--save
done
done
;;
;;
ubc
)
# HELPCMD: print resource using via vzubc
ubc
)
# HELPCMD: print resource using via vzubc
LIST
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
showcmd docker stats
--no-stream
for
i
in
$LIST
;
do
for
i
in
$LIST
;
do
#info "Do $CMD on $i ..."
a
=
docker stats
--no-stream
$i
vzubc
$i
done
done
;;
;;
stop
)
# HELPCMD: stop container(s)
stop
)
# HELPCMD: stop container(s)
LIST
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
for
i
in
"
$@
"
;
do
for
i
in
"
$@
"
;
do
info
"Stopping
$i
..."
info
"Stopping
$i
..."
vzctl
stop
$i
docmd docker
stop
$i
done
done
;;
;;
start
)
# HELPCMD: start container(s)
start
)
# HELPCMD: start container(s)
LIST
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
for
i
in
$LIST
;
do
info
"Starting
$i
..."
info
"Starting
$i
..."
vzctl
start
$i
docmd docker
start
$i
done
done
;;
;;
restart
)
# HELPCMD: restart container(s)
restart
)
# HELPCMD: restart container(s)
LIST
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
for
i
in
$LIST
;
do
info
"Restarting
$i
..."
info
"Restarting
$i
..."
vzctl
restart
$i
docmd docker
restart
$i
done
done
;;
;;
list
)
# HELPCMD: list avaiable container(s) (use -q|-1 for list only ID, list ALL|-a for list ever stopped containers)
list
)
# HELPCMD: list avaiable container(s) (use -q|-1 for list only ID, list ALL|-a for list ever stopped containers)
# 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
#get_list "$@"
get_list
"
$@
"
docker ps
exit
exit
fi
fi
vzlist
"
$@
"
docmd docker ps
"
$@
"
;;
;;
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
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
for
i
in
$LIST
;
do
for
i
in
$LIST
;
do
docker
exec
-ti
"
$i
"
"
$INCMD
"
showcmd docker
exec
-ti
$SETLANG
"
$i
"
"
$INCMD
"
a
=
docker
exec
-ti
$SETLANG
"
$i
"
"
$INCMD
"
done
done
;;
;;
enter
)
# HELPCMD: enter in a container with ID
enter
)
# HELPCMD: enter in a container with ID
docker
exec
-ti
"
$1
"
bash
showcmd docker
exec
-ti
$SETLANG
"
$1
"
bash
a
=
docker
exec
-ti
$SETLANG
"
$1
"
bash
;;
;;
log|logs
)
# HELPCMD: print container log
log|logs
)
# HELPCMD: print container log
docker logs
"
$1
"
doc
md doc
ker logs
"
$1
"
;;
;;
info
)
# HELPCMD: print containers(s) info (vzlist like)
info
)
# HELPCMD: print containers(s) info (vzlist like)
LIST
=
$(
get_list
"
$@
"
)
LIST
=
$(
get_list
"
$@
"
)
...
@@ -129,15 +158,18 @@ case $CMD in
...
@@ -129,15 +158,18 @@ 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
-a
"
$@
"
# don't support all/ALL
#LIST=$(get_list "$@")
LIST
=
"
$@
"
echo
"
$LIST
"
#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."
for
i
in
"
$
@
"
;
do
for
i
in
"
$
LIST
"
;
do
info
"Stopping
$i
..."
info
"Stopping
$i
..."
vzctl
stop
$i
docmd docker
stop
$i
vzctl destroy
$i
docmd docker
rm
-f
-v
$i
done
done
;;
;;
*
)
*
)
...
...
bin/evz-functions
View file @
bffdb9bf
...
@@ -23,15 +23,6 @@ line_filter()
...
@@ -23,15 +23,6 @@ line_filter()
sed
-e
':a'
-e
'N'
-e
'$!ba'
-e
's/\n/ /g'
-e
"s|
\+
| |g"
-e
"s|^ ||g"
-e
"s|
$|
|g"
sed
-e
':a'
-e
'N'
-e
'$!ba'
-e
's/\n/ /g'
-e
"s|
\+
| |g"
-e
"s|^ ||g"
-e
"s|
$|
|g"
}
}
list_all
()
{
vzlist
-1
"
$@
"
| line_filter
}
list_ALL
()
{
vzlist
-1
-a
"
$@
"
| line_filter
}
get_list
()
get_list
()
{
{
...
...
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