Commit 18cd75a1 authored by Vitaly Lipatov's avatar Vitaly Lipatov

- evz: rewrite engines detection

- evz: add EVZCTL env. to force engine
parent 0d058ca3
...@@ -35,18 +35,23 @@ load_helper evz-functions ...@@ -35,18 +35,23 @@ load_helper evz-functions
check_tty check_tty
SUPPORTED_ENGINES="vzctl docker qm pct vboxmanage"
MCTL="" MCTL=""
[ -z "$MCTL" ] && which vzctl 2>/dev/null >/dev/null && MCTL="openvz" EVZCTL_supported=""
[ -z "$MCTL" ] && which docker 2>/dev/null >/dev/null && MCTL="docker" for i in $SUPPORTED_ENGINES ; do
[ -z "$MCTL" ] && which qm 2>/dev/null >/dev/null && MCTL="qm" which $i 2>/dev/null >/dev/null || continue
[ -z "$MCTL" ] && which pct 2>/dev/null >/dev/null && MCTL="pct" MCTL="$i"
[ "$EVZCTL" = "$i" ] && EVZCTL_supported="$EVZCTL" && break
done
[ -n "$EVZCTL_supported" ] && MCTL="$EVZCTL_supported"
[ -n "$MCTL" ] || warning "Can't detect supported virtualization tool"
# FIXME: override get_help # FIXME: override get_help
# print options description from HELPCMD/HELPOPT lines in the code # print options description from HELPCMD/HELPOPT lines in the code
get_help() get_help()
{ {
[ -z "$MCTL" ] && warning "Can't detect supported virtualization tool" && return
grep -v -h -- "^#" $0 $SHAREDIR/evz-$MCTL | grep -- "# $1" | while read n ; do grep -v -h -- "^#" $0 $SHAREDIR/evz-$MCTL | grep -- "# $1" | while read n ; do
opt=$(echo $n | sed -e "s|) # $1:.*||g") opt=$(echo $n | sed -e "s|) # $1:.*||g")
desc=$(echo $n | sed -e "s|.*) # $1:||g") desc=$(echo $n | sed -e "s|.*) # $1:||g")
...@@ -72,7 +77,7 @@ $(get_help HELPOPT) ...@@ -72,7 +77,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Etersoft vzctl & docker wrapper version @VERSION@" echo "Etersoft virtualization wrapper version @VERSION@"
echo "Copyright (c) Etersoft 2017, 2020" echo "Copyright (c) Etersoft 2017, 2020"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
} }
...@@ -80,7 +85,7 @@ print_version() ...@@ -80,7 +85,7 @@ print_version()
progname="${0##*/}" progname="${0##*/}"
Usage="Usage: $progname [options] [<command>] [params]..." Usage="Usage: $progname [options] [<command>] [params]..."
Descr="evz - vzctl & docker wrapper" Descr="evz - virtualization wrapper (supported engines: $SUPPORTED_ENGINES)"
progname="${0##*/}" progname="${0##*/}"
......
...@@ -36,6 +36,9 @@ Quiet mode ...@@ -36,6 +36,9 @@ Quiet mode
# evz destroy 5 10 - stop containers 5, 10 and destroy it # evz destroy 5 10 - stop containers 5, 10 and destroy it
# evz restart 10 20 - restart containers 10 20 # evz restart 10 20 - restart containers 10 20
.SH ENV
You can override autodetected virtualization engine with EVZCTL environment variable.
.SH BUGS .SH BUGS
Please report any bugs to lav@etersoft.ru Please report any bugs to lav@etersoft.ru
.SH EXIT STATUS .SH EXIT STATUS
......
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